Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:17:45

0001 /*
0002  * Copyright (C) 2003-2012 Free Software Foundation, Inc.
0003  *
0004  * Author: Nikos Mavrogiannopoulos
0005  *
0006  * This file is part of GnuTLS.
0007  *
0008  * The GnuTLS is free software; you can redistribute it and/or
0009  * modify it under the terms of the GNU Lesser General Public License
0010  * as published by the Free Software Foundation; either version 2.1 of
0011  * the License, or (at your option) any later version.
0012  *
0013  * This library is distributed in the hope that it will be useful, but
0014  * WITHOUT ANY WARRANTY; without even the implied warranty of
0015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0016  * Lesser General Public License for more details.
0017  *
0018  * You should have received a copy of the GNU Lesser General Public License
0019  * along with this program.  If not, see <https://www.gnu.org/licenses/>
0020  *
0021  */
0022 
0023 #ifndef GNUTLS_PKCS12_H
0024 #define GNUTLS_PKCS12_H
0025 
0026 #include <gnutls/x509.h>
0027 
0028 #ifdef __cplusplus
0029 extern "C" {
0030 #endif
0031 
0032 /* PKCS12 structures handling
0033      */
0034 struct gnutls_pkcs12_int;
0035 typedef struct gnutls_pkcs12_int *gnutls_pkcs12_t;
0036 
0037 struct gnutls_pkcs12_bag_int;
0038 typedef struct gnutls_pkcs12_bag_int *gnutls_pkcs12_bag_t;
0039 
0040 int gnutls_pkcs12_init(gnutls_pkcs12_t *pkcs12);
0041 void gnutls_pkcs12_deinit(gnutls_pkcs12_t pkcs12);
0042 int gnutls_pkcs12_import(gnutls_pkcs12_t pkcs12, const gnutls_datum_t *data,
0043              gnutls_x509_crt_fmt_t format, unsigned int flags);
0044 int gnutls_pkcs12_export(gnutls_pkcs12_t pkcs12, gnutls_x509_crt_fmt_t format,
0045              void *output_data, size_t *output_data_size);
0046 int gnutls_pkcs12_export2(gnutls_pkcs12_t pkcs12, gnutls_x509_crt_fmt_t format,
0047               gnutls_datum_t *out);
0048 
0049 int gnutls_pkcs12_get_bag(gnutls_pkcs12_t pkcs12, int indx,
0050               gnutls_pkcs12_bag_t bag);
0051 int gnutls_pkcs12_set_bag(gnutls_pkcs12_t pkcs12, gnutls_pkcs12_bag_t bag);
0052 
0053 typedef enum gnutls_pkcs12_flags_t {
0054     GNUTLS_PKCS12_USE_PBMAC1 = 1
0055 } gnutls_pkcs12_flags_t;
0056 
0057 int gnutls_pkcs12_generate_mac(gnutls_pkcs12_t pkcs12, const char *pass);
0058 int gnutls_pkcs12_generate_mac2(gnutls_pkcs12_t pkcs12,
0059                 gnutls_mac_algorithm_t mac, const char *pass);
0060 int gnutls_pkcs12_generate_mac3(gnutls_pkcs12_t pkcs12,
0061                 gnutls_mac_algorithm_t mac, const char *pass,
0062                 unsigned int flags);
0063 int gnutls_pkcs12_verify_mac(gnutls_pkcs12_t pkcs12, const char *pass);
0064 
0065 int gnutls_pkcs12_bag_decrypt(gnutls_pkcs12_bag_t bag, const char *pass);
0066 int gnutls_pkcs12_bag_encrypt(gnutls_pkcs12_bag_t bag, const char *pass,
0067                   unsigned int flags);
0068 
0069 int gnutls_pkcs12_bag_enc_info(gnutls_pkcs12_bag_t bag, unsigned int *schema,
0070                    unsigned int *cipher, void *salt,
0071                    unsigned int *salt_size,
0072                    unsigned int *iter_count, char **oid);
0073 int gnutls_pkcs12_mac_info(gnutls_pkcs12_t pkcs12, unsigned int *mac,
0074                void *salt, unsigned int *salt_size,
0075                unsigned int *iter_count, char **oid);
0076 
0077 #define GNUTLS_PKCS12_SP_INCLUDE_SELF_SIGNED 1
0078 int gnutls_pkcs12_simple_parse(gnutls_pkcs12_t p12, const char *password,
0079                    gnutls_x509_privkey_t *key,
0080                    gnutls_x509_crt_t **chain,
0081                    unsigned int *chain_len,
0082                    gnutls_x509_crt_t **extra_certs,
0083                    unsigned int *extra_certs_len,
0084                    gnutls_x509_crl_t *crl, unsigned int flags);
0085 
0086 /**
0087  * gnutls_pkcs12_bag_type_t:
0088  * @GNUTLS_BAG_EMPTY: Empty PKCS-12 bag.
0089  * @GNUTLS_BAG_PKCS8_ENCRYPTED_KEY: PKCS-12 bag with PKCS-8 encrypted key.
0090  * @GNUTLS_BAG_PKCS8_KEY: PKCS-12 bag with PKCS-8 key.
0091  * @GNUTLS_BAG_CERTIFICATE: PKCS-12 bag with certificate.
0092  * @GNUTLS_BAG_CRL: PKCS-12 bag with CRL.
0093  * @GNUTLS_BAG_SECRET: PKCS-12 bag with secret PKCS-9 keys.
0094  * @GNUTLS_BAG_ENCRYPTED: Encrypted PKCS-12 bag.
0095  * @GNUTLS_BAG_UNKNOWN: Unknown PKCS-12 bag.
0096  *
0097  * Enumeration of different PKCS 12 bag types.
0098  */
0099 typedef enum gnutls_pkcs12_bag_type_t {
0100     GNUTLS_BAG_EMPTY = 0,
0101     GNUTLS_BAG_PKCS8_ENCRYPTED_KEY = 1,
0102     GNUTLS_BAG_PKCS8_KEY = 2,
0103     GNUTLS_BAG_CERTIFICATE = 3,
0104     GNUTLS_BAG_CRL = 4,
0105     GNUTLS_BAG_SECRET = 5, /* Secret data. Underspecified in pkcs-12,
0106                  * gnutls extension. We use the PKCS-9
0107                  * random nonce ID 1.2.840.113549.1.9.25.3
0108                  * to store randomly generated keys.
0109                  */
0110     GNUTLS_BAG_ENCRYPTED = 10,
0111     GNUTLS_BAG_UNKNOWN = 20
0112 } gnutls_pkcs12_bag_type_t;
0113 
0114 int gnutls_pkcs12_bag_get_type(gnutls_pkcs12_bag_t bag, unsigned indx);
0115 int gnutls_pkcs12_bag_get_data(gnutls_pkcs12_bag_t bag, unsigned indx,
0116                    gnutls_datum_t *data);
0117 int gnutls_pkcs12_bag_set_data(gnutls_pkcs12_bag_t bag,
0118                    gnutls_pkcs12_bag_type_t type,
0119                    const gnutls_datum_t *data);
0120 int gnutls_pkcs12_bag_set_crl(gnutls_pkcs12_bag_t bag, gnutls_x509_crl_t crl);
0121 int gnutls_pkcs12_bag_set_crt(gnutls_pkcs12_bag_t bag, gnutls_x509_crt_t crt);
0122 
0123 int gnutls_pkcs12_bag_set_privkey(gnutls_pkcs12_bag_t bag,
0124                   gnutls_x509_privkey_t privkey,
0125                   const char *password, unsigned flags);
0126 
0127 int gnutls_pkcs12_bag_init(gnutls_pkcs12_bag_t *bag);
0128 void gnutls_pkcs12_bag_deinit(gnutls_pkcs12_bag_t bag);
0129 int gnutls_pkcs12_bag_get_count(gnutls_pkcs12_bag_t bag);
0130 
0131 int gnutls_pkcs12_bag_get_key_id(gnutls_pkcs12_bag_t bag, unsigned indx,
0132                  gnutls_datum_t *id);
0133 int gnutls_pkcs12_bag_set_key_id(gnutls_pkcs12_bag_t bag, unsigned indx,
0134                  const gnutls_datum_t *id);
0135 
0136 int gnutls_pkcs12_bag_get_friendly_name(gnutls_pkcs12_bag_t bag, unsigned indx,
0137                     char **name);
0138 int gnutls_pkcs12_bag_set_friendly_name(gnutls_pkcs12_bag_t bag, unsigned indx,
0139                     const char *name);
0140 
0141 #ifdef __cplusplus
0142 }
0143 #endif
0144 
0145 #endif /* GNUTLS_PKCS12_H */