Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:00:17

0001 /*
0002  * Copyright (C) 2003-2012 Free Software Foundation, Inc.
0003  * Copyright (C) 2015 Red Hat, Inc.
0004  *
0005  * Author: Nikos Mavrogiannopoulos
0006  *
0007  * This file is part of GnuTLS.
0008  *
0009  * The GnuTLS is free software; you can redistribute it and/or
0010  * modify it under the terms of the GNU Lesser General Public License
0011  * as published by the Free Software Foundation; either version 2.1 of
0012  * the License, or (at your option) any later version.
0013  *
0014  * This library is distributed in the hope that it will be useful, but
0015  * WITHOUT ANY WARRANTY; without even the implied warranty of
0016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0017  * Lesser General Public License for more details.
0018  *
0019  * You should have received a copy of the GNU Lesser General Public License
0020  * along with this program.  If not, see <https://www.gnu.org/licenses/>
0021  *
0022  */
0023 
0024 /* This file contains the types and prototypes for the X.509
0025  * certificate and CRL handling functions.
0026  */
0027 
0028 #ifndef GNUTLS_PKCS7_H
0029 #define GNUTLS_PKCS7_H
0030 
0031 #include <gnutls/gnutls.h>
0032 #include <gnutls/x509.h>
0033 
0034 #ifdef __cplusplus
0035 extern "C" {
0036 #endif
0037 
0038 /* PKCS7 structures handling
0039  */
0040 struct gnutls_pkcs7_int;
0041 typedef struct gnutls_pkcs7_int *gnutls_pkcs7_t;
0042 
0043 int gnutls_pkcs7_init(gnutls_pkcs7_t *pkcs7);
0044 void gnutls_pkcs7_deinit(gnutls_pkcs7_t pkcs7);
0045 int gnutls_pkcs7_import(gnutls_pkcs7_t pkcs7, const gnutls_datum_t *data,
0046             gnutls_x509_crt_fmt_t format);
0047 int gnutls_pkcs7_export(gnutls_pkcs7_t pkcs7, gnutls_x509_crt_fmt_t format,
0048             void *output_data, size_t *output_data_size);
0049 int gnutls_pkcs7_export2(gnutls_pkcs7_t pkcs7, gnutls_x509_crt_fmt_t format,
0050              gnutls_datum_t *out);
0051 
0052 int gnutls_pkcs7_get_signature_count(gnutls_pkcs7_t pkcs7);
0053 
0054 #define GNUTLS_PKCS7_EDATA_GET_RAW (1 << 24)
0055 int gnutls_pkcs7_get_embedded_data(gnutls_pkcs7_t pkcs7, unsigned flags,
0056                    gnutls_datum_t *data);
0057 
0058 const char *gnutls_pkcs7_get_embedded_data_oid(gnutls_pkcs7_t pkcs7);
0059 
0060 int gnutls_pkcs7_get_crt_count(gnutls_pkcs7_t pkcs7);
0061 int gnutls_pkcs7_get_crt_raw(gnutls_pkcs7_t pkcs7, unsigned indx,
0062                  void *certificate, size_t *certificate_size);
0063 
0064 int gnutls_pkcs7_set_crt_raw(gnutls_pkcs7_t pkcs7, const gnutls_datum_t *crt);
0065 int gnutls_pkcs7_set_crt(gnutls_pkcs7_t pkcs7, gnutls_x509_crt_t crt);
0066 int gnutls_pkcs7_delete_crt(gnutls_pkcs7_t pkcs7, int indx);
0067 
0068 int gnutls_pkcs7_get_crl_raw(gnutls_pkcs7_t pkcs7, unsigned indx, void *crl,
0069                  size_t *crl_size);
0070 int gnutls_pkcs7_get_crl_count(gnutls_pkcs7_t pkcs7);
0071 
0072 int gnutls_pkcs7_set_crl_raw(gnutls_pkcs7_t pkcs7, const gnutls_datum_t *crl);
0073 int gnutls_pkcs7_set_crl(gnutls_pkcs7_t pkcs7, gnutls_x509_crl_t crl);
0074 int gnutls_pkcs7_delete_crl(gnutls_pkcs7_t pkcs7, int indx);
0075 
0076 typedef struct gnutls_pkcs7_attrs_st *gnutls_pkcs7_attrs_t;
0077 
0078 typedef struct gnutls_pkcs7_signature_info_st {
0079     gnutls_sign_algorithm_t algo;
0080     gnutls_datum_t sig;
0081     gnutls_datum_t issuer_dn;
0082     gnutls_datum_t signer_serial;
0083     gnutls_datum_t issuer_keyid;
0084     time_t signing_time;
0085     gnutls_pkcs7_attrs_t signed_attrs;
0086     gnutls_pkcs7_attrs_t unsigned_attrs;
0087     char pad[64];
0088 } gnutls_pkcs7_signature_info_st;
0089 
0090 void gnutls_pkcs7_signature_info_deinit(gnutls_pkcs7_signature_info_st *info);
0091 int gnutls_pkcs7_get_signature_info(gnutls_pkcs7_t pkcs7, unsigned idx,
0092                     gnutls_pkcs7_signature_info_st *info);
0093 
0094 int gnutls_pkcs7_verify_direct(gnutls_pkcs7_t pkcs7, gnutls_x509_crt_t signer,
0095                    unsigned idx, const gnutls_datum_t *data,
0096                    unsigned flags);
0097 int gnutls_pkcs7_verify(gnutls_pkcs7_t pkcs7, gnutls_x509_trust_list_t tl,
0098             gnutls_typed_vdata_st *vdata, unsigned int vdata_size,
0099             unsigned idx, const gnutls_datum_t *data,
0100             unsigned flags);
0101 
0102 #define GNUTLS_PKCS7_ATTR_ENCODE_OCTET_STRING 1
0103 int gnutls_pkcs7_add_attr(gnutls_pkcs7_attrs_t *list, const char *oid,
0104               gnutls_datum_t *data, unsigned flags);
0105 void gnutls_pkcs7_attrs_deinit(gnutls_pkcs7_attrs_t list);
0106 int gnutls_pkcs7_get_attr(gnutls_pkcs7_attrs_t list, unsigned idx, char **oid,
0107               gnutls_datum_t *data, unsigned flags);
0108 
0109 /**
0110  * gnutls_pkcs7_sign_flags:
0111  * @GNUTLS_PKCS7_EMBED_DATA: The signed data will be embedded in the structure.
0112  * @GNUTLS_PKCS7_INCLUDE_TIME: The signing time will be included in the structure.
0113  * @GNUTLS_PKCS7_INCLUDE_CERT: The signer's certificate will be included in the cert list.
0114  * @GNUTLS_PKCS7_WRITE_SPKI: Use the signer's key identifier instead of name.
0115  *
0116  * Enumeration of the different PKCS #7 signature flags.
0117  */
0118 typedef enum gnutls_pkcs7_sign_flags {
0119     GNUTLS_PKCS7_EMBED_DATA = 1,
0120     GNUTLS_PKCS7_INCLUDE_TIME = (1 << 1),
0121     GNUTLS_PKCS7_INCLUDE_CERT = (1 << 2),
0122     GNUTLS_PKCS7_WRITE_SPKI = (1 << 3)
0123 } gnutls_pkcs7_sign_flags;
0124 
0125 int gnutls_pkcs7_sign(gnutls_pkcs7_t pkcs7, gnutls_x509_crt_t signer,
0126               gnutls_privkey_t signer_key, const gnutls_datum_t *data,
0127               gnutls_pkcs7_attrs_t signed_attrs,
0128               gnutls_pkcs7_attrs_t unsigned_attrs,
0129               gnutls_digest_algorithm_t dig, unsigned flags);
0130 
0131 int gnutls_pkcs7_get_crt_raw2(gnutls_pkcs7_t pkcs7, unsigned indx,
0132                   gnutls_datum_t *cert);
0133 int gnutls_pkcs7_get_crl_raw2(gnutls_pkcs7_t pkcs7, unsigned indx,
0134                   gnutls_datum_t *crl);
0135 
0136 int gnutls_pkcs7_print(gnutls_pkcs7_t pkcs7,
0137                gnutls_certificate_print_formats_t format,
0138                gnutls_datum_t *out);
0139 
0140 int gnutls_pkcs7_print_signature_info(gnutls_pkcs7_signature_info_st *info,
0141                       gnutls_certificate_print_formats_t format,
0142                       gnutls_datum_t *out);
0143 
0144 #ifdef __cplusplus
0145 }
0146 #endif
0147 
0148 #endif /* GNUTLS_PKCS7_H */