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  *
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 int gnutls_pkcs12_generate_mac(gnutls_pkcs12_t pkcs12, const char *pass);
0054 int gnutls_pkcs12_generate_mac2(gnutls_pkcs12_t pkcs12,
0055                 gnutls_mac_algorithm_t mac, const char *pass);
0056 int gnutls_pkcs12_verify_mac(gnutls_pkcs12_t pkcs12, const char *pass);
0057 
0058 int gnutls_pkcs12_bag_decrypt(gnutls_pkcs12_bag_t bag, const char *pass);
0059 int gnutls_pkcs12_bag_encrypt(gnutls_pkcs12_bag_t bag, const char *pass,
0060                   unsigned int flags);
0061 
0062 int gnutls_pkcs12_bag_enc_info(gnutls_pkcs12_bag_t bag, unsigned int *schema,
0063                    unsigned int *cipher, void *salt,
0064                    unsigned int *salt_size,
0065                    unsigned int *iter_count, char **oid);
0066 int gnutls_pkcs12_mac_info(gnutls_pkcs12_t pkcs12, unsigned int *mac,
0067                void *salt, unsigned int *salt_size,
0068                unsigned int *iter_count, char **oid);
0069 
0070 #define GNUTLS_PKCS12_SP_INCLUDE_SELF_SIGNED 1
0071 int gnutls_pkcs12_simple_parse(gnutls_pkcs12_t p12, const char *password,
0072                    gnutls_x509_privkey_t *key,
0073                    gnutls_x509_crt_t **chain,
0074                    unsigned int *chain_len,
0075                    gnutls_x509_crt_t **extra_certs,
0076                    unsigned int *extra_certs_len,
0077                    gnutls_x509_crl_t *crl, unsigned int flags);
0078 
0079 /**
0080  * gnutls_pkcs12_bag_type_t:
0081  * @GNUTLS_BAG_EMPTY: Empty PKCS-12 bag.
0082  * @GNUTLS_BAG_PKCS8_ENCRYPTED_KEY: PKCS-12 bag with PKCS-8 encrypted key.
0083  * @GNUTLS_BAG_PKCS8_KEY: PKCS-12 bag with PKCS-8 key.
0084  * @GNUTLS_BAG_CERTIFICATE: PKCS-12 bag with certificate.
0085  * @GNUTLS_BAG_CRL: PKCS-12 bag with CRL.
0086  * @GNUTLS_BAG_SECRET: PKCS-12 bag with secret PKCS-9 keys.
0087  * @GNUTLS_BAG_ENCRYPTED: Encrypted PKCS-12 bag.
0088  * @GNUTLS_BAG_UNKNOWN: Unknown PKCS-12 bag.
0089  *
0090  * Enumeration of different PKCS 12 bag types.
0091  */
0092 typedef enum gnutls_pkcs12_bag_type_t {
0093     GNUTLS_BAG_EMPTY = 0,
0094     GNUTLS_BAG_PKCS8_ENCRYPTED_KEY = 1,
0095     GNUTLS_BAG_PKCS8_KEY = 2,
0096     GNUTLS_BAG_CERTIFICATE = 3,
0097     GNUTLS_BAG_CRL = 4,
0098     GNUTLS_BAG_SECRET = 5, /* Secret data. Underspecified in pkcs-12,
0099                  * gnutls extension. We use the PKCS-9
0100                  * random nonce ID 1.2.840.113549.1.9.25.3
0101                  * to store randomly generated keys.
0102                  */
0103     GNUTLS_BAG_ENCRYPTED = 10,
0104     GNUTLS_BAG_UNKNOWN = 20
0105 } gnutls_pkcs12_bag_type_t;
0106 
0107 int gnutls_pkcs12_bag_get_type(gnutls_pkcs12_bag_t bag, unsigned indx);
0108 int gnutls_pkcs12_bag_get_data(gnutls_pkcs12_bag_t bag, unsigned indx,
0109                    gnutls_datum_t *data);
0110 int gnutls_pkcs12_bag_set_data(gnutls_pkcs12_bag_t bag,
0111                    gnutls_pkcs12_bag_type_t type,
0112                    const gnutls_datum_t *data);
0113 int gnutls_pkcs12_bag_set_crl(gnutls_pkcs12_bag_t bag, gnutls_x509_crl_t crl);
0114 int gnutls_pkcs12_bag_set_crt(gnutls_pkcs12_bag_t bag, gnutls_x509_crt_t crt);
0115 
0116 int gnutls_pkcs12_bag_set_privkey(gnutls_pkcs12_bag_t bag,
0117                   gnutls_x509_privkey_t privkey,
0118                   const char *password, unsigned flags);
0119 
0120 int gnutls_pkcs12_bag_init(gnutls_pkcs12_bag_t *bag);
0121 void gnutls_pkcs12_bag_deinit(gnutls_pkcs12_bag_t bag);
0122 int gnutls_pkcs12_bag_get_count(gnutls_pkcs12_bag_t bag);
0123 
0124 int gnutls_pkcs12_bag_get_key_id(gnutls_pkcs12_bag_t bag, unsigned indx,
0125                  gnutls_datum_t *id);
0126 int gnutls_pkcs12_bag_set_key_id(gnutls_pkcs12_bag_t bag, unsigned indx,
0127                  const gnutls_datum_t *id);
0128 
0129 int gnutls_pkcs12_bag_get_friendly_name(gnutls_pkcs12_bag_t bag, unsigned indx,
0130                     char **name);
0131 int gnutls_pkcs12_bag_set_friendly_name(gnutls_pkcs12_bag_t bag, unsigned indx,
0132                     const char *name);
0133 
0134 #ifdef __cplusplus
0135 }
0136 #endif
0137 
0138 #endif /* GNUTLS_PKCS12_H */