VirtualBox

source: vbox/trunk/src/libs/openssl-3.0.7/include/openssl/pkcs12.h.in@ 97673

最後變更 在這個檔案從97673是 94320,由 vboxsync 提交於 3 年 前

libs/openssl-3.0.1: Export to OSE and fix copyright headers in Makefiles, bugref:10128

檔案大小: 15.6 KB
 
1/*
2 * {- join("\n * ", @autowarntext) -}
3 *
4 * Copyright 1999-2021 The OpenSSL Project Authors. All Rights Reserved.
5 *
6 * Licensed under the Apache License 2.0 (the "License"). You may not use
7 * this file except in compliance with the License. You can obtain a copy
8 * in the file LICENSE in the source distribution or at
9 * https://www.openssl.org/source/license.html
10 */
11
12{-
13use OpenSSL::stackhash qw(generate_stack_macros);
14-}
15
16#ifndef OPENSSL_PKCS12_H
17# define OPENSSL_PKCS12_H
18# pragma once
19
20# include <openssl/macros.h>
21# ifndef OPENSSL_NO_DEPRECATED_3_0
22# define HEADER_PKCS12_H
23# endif
24
25# include <openssl/bio.h>
26# include <openssl/core.h>
27# include <openssl/x509.h>
28# include <openssl/pkcs12err.h>
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34# define PKCS12_KEY_ID 1
35# define PKCS12_IV_ID 2
36# define PKCS12_MAC_ID 3
37
38/* Default iteration count */
39# ifndef PKCS12_DEFAULT_ITER
40# define PKCS12_DEFAULT_ITER PKCS5_DEFAULT_ITER
41# endif
42
43# define PKCS12_MAC_KEY_LENGTH 20
44
45# define PKCS12_SALT_LEN 8
46
47/* It's not clear if these are actually needed... */
48# define PKCS12_key_gen PKCS12_key_gen_utf8
49# define PKCS12_add_friendlyname PKCS12_add_friendlyname_utf8
50
51/* MS key usage constants */
52
53# define KEY_EX 0x10
54# define KEY_SIG 0x80
55
56typedef struct PKCS12_MAC_DATA_st PKCS12_MAC_DATA;
57
58typedef struct PKCS12_st PKCS12;
59
60typedef struct PKCS12_SAFEBAG_st PKCS12_SAFEBAG;
61
62{-
63 generate_stack_macros("PKCS12_SAFEBAG");
64-}
65
66typedef struct pkcs12_bag_st PKCS12_BAGS;
67
68# define PKCS12_ERROR 0
69# define PKCS12_OK 1
70
71/* Compatibility macros */
72
73#ifndef OPENSSL_NO_DEPRECATED_1_1_0
74
75# define M_PKCS12_bag_type PKCS12_bag_type
76# define M_PKCS12_cert_bag_type PKCS12_cert_bag_type
77# define M_PKCS12_crl_bag_type PKCS12_cert_bag_type
78
79# define PKCS12_certbag2x509 PKCS12_SAFEBAG_get1_cert
80# define PKCS12_certbag2scrl PKCS12_SAFEBAG_get1_crl
81# define PKCS12_bag_type PKCS12_SAFEBAG_get_nid
82# define PKCS12_cert_bag_type PKCS12_SAFEBAG_get_bag_nid
83# define PKCS12_x5092certbag PKCS12_SAFEBAG_create_cert
84# define PKCS12_x509crl2certbag PKCS12_SAFEBAG_create_crl
85# define PKCS12_MAKE_KEYBAG PKCS12_SAFEBAG_create0_p8inf
86# define PKCS12_MAKE_SHKEYBAG PKCS12_SAFEBAG_create_pkcs8_encrypt
87
88#endif
89#ifndef OPENSSL_NO_DEPRECATED_1_1_0
90OSSL_DEPRECATEDIN_1_1_0 ASN1_TYPE *PKCS12_get_attr(const PKCS12_SAFEBAG *bag,
91 int attr_nid);
92#endif
93
94ASN1_TYPE *PKCS8_get_attr(PKCS8_PRIV_KEY_INFO *p8, int attr_nid);
95int PKCS12_mac_present(const PKCS12 *p12);
96void PKCS12_get0_mac(const ASN1_OCTET_STRING **pmac,
97 const X509_ALGOR **pmacalg,
98 const ASN1_OCTET_STRING **psalt,
99 const ASN1_INTEGER **piter,
100 const PKCS12 *p12);
101
102const ASN1_TYPE *PKCS12_SAFEBAG_get0_attr(const PKCS12_SAFEBAG *bag,
103 int attr_nid);
104const ASN1_OBJECT *PKCS12_SAFEBAG_get0_type(const PKCS12_SAFEBAG *bag);
105int PKCS12_SAFEBAG_get_nid(const PKCS12_SAFEBAG *bag);
106int PKCS12_SAFEBAG_get_bag_nid(const PKCS12_SAFEBAG *bag);
107const ASN1_TYPE *PKCS12_SAFEBAG_get0_bag_obj(const PKCS12_SAFEBAG *bag);
108const ASN1_OBJECT *PKCS12_SAFEBAG_get0_bag_type(const PKCS12_SAFEBAG *bag);
109
110X509 *PKCS12_SAFEBAG_get1_cert(const PKCS12_SAFEBAG *bag);
111X509_CRL *PKCS12_SAFEBAG_get1_crl(const PKCS12_SAFEBAG *bag);
112const STACK_OF(PKCS12_SAFEBAG) *
113PKCS12_SAFEBAG_get0_safes(const PKCS12_SAFEBAG *bag);
114const PKCS8_PRIV_KEY_INFO *PKCS12_SAFEBAG_get0_p8inf(const PKCS12_SAFEBAG *bag);
115const X509_SIG *PKCS12_SAFEBAG_get0_pkcs8(const PKCS12_SAFEBAG *bag);
116
117PKCS12_SAFEBAG *PKCS12_SAFEBAG_create_cert(X509 *x509);
118PKCS12_SAFEBAG *PKCS12_SAFEBAG_create_crl(X509_CRL *crl);
119PKCS12_SAFEBAG *PKCS12_SAFEBAG_create_secret(int type, int vtype, const unsigned char *value, int len);
120PKCS12_SAFEBAG *PKCS12_SAFEBAG_create0_p8inf(PKCS8_PRIV_KEY_INFO *p8);
121PKCS12_SAFEBAG *PKCS12_SAFEBAG_create0_pkcs8(X509_SIG *p8);
122PKCS12_SAFEBAG *PKCS12_SAFEBAG_create_pkcs8_encrypt(int pbe_nid,
123 const char *pass,
124 int passlen,
125 unsigned char *salt,
126 int saltlen, int iter,
127 PKCS8_PRIV_KEY_INFO *p8inf);
128PKCS12_SAFEBAG *PKCS12_SAFEBAG_create_pkcs8_encrypt_ex(int pbe_nid,
129 const char *pass,
130 int passlen,
131 unsigned char *salt,
132 int saltlen, int iter,
133 PKCS8_PRIV_KEY_INFO *p8inf,
134 OSSL_LIB_CTX *ctx,
135 const char *propq);
136
137PKCS12_SAFEBAG *PKCS12_item_pack_safebag(void *obj, const ASN1_ITEM *it,
138 int nid1, int nid2);
139PKCS8_PRIV_KEY_INFO *PKCS8_decrypt(const X509_SIG *p8, const char *pass,
140 int passlen);
141PKCS8_PRIV_KEY_INFO *PKCS8_decrypt_ex(const X509_SIG *p8, const char *pass,
142 int passlen, OSSL_LIB_CTX *ctx,
143 const char *propq);
144PKCS8_PRIV_KEY_INFO *PKCS12_decrypt_skey(const PKCS12_SAFEBAG *bag,
145 const char *pass, int passlen);
146PKCS8_PRIV_KEY_INFO *PKCS12_decrypt_skey_ex(const PKCS12_SAFEBAG *bag,
147 const char *pass, int passlen,
148 OSSL_LIB_CTX *ctx,
149 const char *propq);
150X509_SIG *PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher,
151 const char *pass, int passlen, unsigned char *salt,
152 int saltlen, int iter, PKCS8_PRIV_KEY_INFO *p8);
153X509_SIG *PKCS8_encrypt_ex(int pbe_nid, const EVP_CIPHER *cipher,
154 const char *pass, int passlen, unsigned char *salt,
155 int saltlen, int iter, PKCS8_PRIV_KEY_INFO *p8,
156 OSSL_LIB_CTX *ctx, const char *propq);
157X509_SIG *PKCS8_set0_pbe(const char *pass, int passlen,
158 PKCS8_PRIV_KEY_INFO *p8inf, X509_ALGOR *pbe);
159X509_SIG *PKCS8_set0_pbe_ex(const char *pass, int passlen,
160 PKCS8_PRIV_KEY_INFO *p8inf, X509_ALGOR *pbe,
161 OSSL_LIB_CTX *ctx, const char *propq);
162PKCS7 *PKCS12_pack_p7data(STACK_OF(PKCS12_SAFEBAG) *sk);
163STACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7data(PKCS7 *p7);
164PKCS7 *PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen,
165 unsigned char *salt, int saltlen, int iter,
166 STACK_OF(PKCS12_SAFEBAG) *bags);
167PKCS7 *PKCS12_pack_p7encdata_ex(int pbe_nid, const char *pass, int passlen,
168 unsigned char *salt, int saltlen, int iter,
169 STACK_OF(PKCS12_SAFEBAG) *bags,
170 OSSL_LIB_CTX *ctx, const char *propq);
171
172STACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7encdata(PKCS7 *p7, const char *pass,
173 int passlen);
174
175int PKCS12_pack_authsafes(PKCS12 *p12, STACK_OF(PKCS7) *safes);
176STACK_OF(PKCS7) *PKCS12_unpack_authsafes(const PKCS12 *p12);
177
178int PKCS12_add_localkeyid(PKCS12_SAFEBAG *bag, unsigned char *name,
179 int namelen);
180int PKCS12_add_friendlyname_asc(PKCS12_SAFEBAG *bag, const char *name,
181 int namelen);
182int PKCS12_add_friendlyname_utf8(PKCS12_SAFEBAG *bag, const char *name,
183 int namelen);
184int PKCS12_add_CSPName_asc(PKCS12_SAFEBAG *bag, const char *name,
185 int namelen);
186int PKCS12_add_friendlyname_uni(PKCS12_SAFEBAG *bag,
187 const unsigned char *name, int namelen);
188int PKCS12_add1_attr_by_NID(PKCS12_SAFEBAG *bag, int nid, int type,
189 const unsigned char *bytes, int len);
190int PKCS12_add1_attr_by_txt(PKCS12_SAFEBAG *bag, const char *attrname, int type,
191 const unsigned char *bytes, int len);
192int PKCS8_add_keyusage(PKCS8_PRIV_KEY_INFO *p8, int usage);
193ASN1_TYPE *PKCS12_get_attr_gen(const STACK_OF(X509_ATTRIBUTE) *attrs,
194 int attr_nid);
195char *PKCS12_get_friendlyname(PKCS12_SAFEBAG *bag);
196const STACK_OF(X509_ATTRIBUTE) *
197PKCS12_SAFEBAG_get0_attrs(const PKCS12_SAFEBAG *bag);
198unsigned char *PKCS12_pbe_crypt(const X509_ALGOR *algor,
199 const char *pass, int passlen,
200 const unsigned char *in, int inlen,
201 unsigned char **data, int *datalen,
202 int en_de);
203unsigned char *PKCS12_pbe_crypt_ex(const X509_ALGOR *algor,
204 const char *pass, int passlen,
205 const unsigned char *in, int inlen,
206 unsigned char **data, int *datalen,
207 int en_de, OSSL_LIB_CTX *libctx,
208 const char *propq);
209void *PKCS12_item_decrypt_d2i(const X509_ALGOR *algor, const ASN1_ITEM *it,
210 const char *pass, int passlen,
211 const ASN1_OCTET_STRING *oct, int zbuf);
212void *PKCS12_item_decrypt_d2i_ex(const X509_ALGOR *algor, const ASN1_ITEM *it,
213 const char *pass, int passlen,
214 const ASN1_OCTET_STRING *oct, int zbuf,
215 OSSL_LIB_CTX *libctx,
216 const char *propq);
217ASN1_OCTET_STRING *PKCS12_item_i2d_encrypt(X509_ALGOR *algor,
218 const ASN1_ITEM *it,
219 const char *pass, int passlen,
220 void *obj, int zbuf);
221ASN1_OCTET_STRING *PKCS12_item_i2d_encrypt_ex(X509_ALGOR *algor,
222 const ASN1_ITEM *it,
223 const char *pass, int passlen,
224 void *obj, int zbuf,
225 OSSL_LIB_CTX *ctx,
226 const char *propq);
227PKCS12 *PKCS12_init(int mode);
228PKCS12 *PKCS12_init_ex(int mode, OSSL_LIB_CTX *ctx, const char *propq);
229
230int PKCS12_key_gen_asc(const char *pass, int passlen, unsigned char *salt,
231 int saltlen, int id, int iter, int n,
232 unsigned char *out, const EVP_MD *md_type);
233int PKCS12_key_gen_asc_ex(const char *pass, int passlen, unsigned char *salt,
234 int saltlen, int id, int iter, int n,
235 unsigned char *out, const EVP_MD *md_type,
236 OSSL_LIB_CTX *ctx, const char *propq);
237int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt,
238 int saltlen, int id, int iter, int n,
239 unsigned char *out, const EVP_MD *md_type);
240int PKCS12_key_gen_uni_ex(unsigned char *pass, int passlen, unsigned char *salt,
241 int saltlen, int id, int iter, int n,
242 unsigned char *out, const EVP_MD *md_type,
243 OSSL_LIB_CTX *ctx, const char *propq);
244int PKCS12_key_gen_utf8(const char *pass, int passlen, unsigned char *salt,
245 int saltlen, int id, int iter, int n,
246 unsigned char *out, const EVP_MD *md_type);
247int PKCS12_key_gen_utf8_ex(const char *pass, int passlen, unsigned char *salt,
248 int saltlen, int id, int iter, int n,
249 unsigned char *out, const EVP_MD *md_type,
250 OSSL_LIB_CTX *ctx, const char *propq);
251
252int PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
253 ASN1_TYPE *param, const EVP_CIPHER *cipher,
254 const EVP_MD *md_type, int en_de);
255int PKCS12_PBE_keyivgen_ex(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
256 ASN1_TYPE *param, const EVP_CIPHER *cipher,
257 const EVP_MD *md_type, int en_de,
258 OSSL_LIB_CTX *libctx, const char *propq);
259int PKCS12_gen_mac(PKCS12 *p12, const char *pass, int passlen,
260 unsigned char *mac, unsigned int *maclen);
261int PKCS12_verify_mac(PKCS12 *p12, const char *pass, int passlen);
262int PKCS12_set_mac(PKCS12 *p12, const char *pass, int passlen,
263 unsigned char *salt, int saltlen, int iter,
264 const EVP_MD *md_type);
265int PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt,
266 int saltlen, const EVP_MD *md_type);
267unsigned char *OPENSSL_asc2uni(const char *asc, int asclen,
268 unsigned char **uni, int *unilen);
269char *OPENSSL_uni2asc(const unsigned char *uni, int unilen);
270unsigned char *OPENSSL_utf82uni(const char *asc, int asclen,
271 unsigned char **uni, int *unilen);
272char *OPENSSL_uni2utf8(const unsigned char *uni, int unilen);
273
274DECLARE_ASN1_FUNCTIONS(PKCS12)
275DECLARE_ASN1_FUNCTIONS(PKCS12_MAC_DATA)
276DECLARE_ASN1_FUNCTIONS(PKCS12_SAFEBAG)
277DECLARE_ASN1_FUNCTIONS(PKCS12_BAGS)
278
279DECLARE_ASN1_ITEM(PKCS12_SAFEBAGS)
280DECLARE_ASN1_ITEM(PKCS12_AUTHSAFES)
281
282void PKCS12_PBE_add(void);
283int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert,
284 STACK_OF(X509) **ca);
285PKCS12 *PKCS12_create(const char *pass, const char *name, EVP_PKEY *pkey,
286 X509 *cert, STACK_OF(X509) *ca, int nid_key, int nid_cert,
287 int iter, int mac_iter, int keytype);
288PKCS12 *PKCS12_create_ex(const char *pass, const char *name, EVP_PKEY *pkey,
289 X509 *cert, STACK_OF(X509) *ca, int nid_key, int nid_cert,
290 int iter, int mac_iter, int keytype,
291 OSSL_LIB_CTX *ctx, const char *propq);
292
293PKCS12_SAFEBAG *PKCS12_add_cert(STACK_OF(PKCS12_SAFEBAG) **pbags, X509 *cert);
294PKCS12_SAFEBAG *PKCS12_add_key(STACK_OF(PKCS12_SAFEBAG) **pbags,
295 EVP_PKEY *key, int key_usage, int iter,
296 int key_nid, const char *pass);
297PKCS12_SAFEBAG *PKCS12_add_key_ex(STACK_OF(PKCS12_SAFEBAG) **pbags,
298 EVP_PKEY *key, int key_usage, int iter,
299 int key_nid, const char *pass,
300 OSSL_LIB_CTX *ctx, const char *propq);
301
302PKCS12_SAFEBAG *PKCS12_add_secret(STACK_OF(PKCS12_SAFEBAG) **pbags,
303 int nid_type, const unsigned char *value, int len);
304int PKCS12_add_safe(STACK_OF(PKCS7) **psafes, STACK_OF(PKCS12_SAFEBAG) *bags,
305 int safe_nid, int iter, const char *pass);
306int PKCS12_add_safe_ex(STACK_OF(PKCS7) **psafes, STACK_OF(PKCS12_SAFEBAG) *bags,
307 int safe_nid, int iter, const char *pass,
308 OSSL_LIB_CTX *ctx, const char *propq);
309
310PKCS12 *PKCS12_add_safes(STACK_OF(PKCS7) *safes, int p7_nid);
311PKCS12 *PKCS12_add_safes_ex(STACK_OF(PKCS7) *safes, int p7_nid,
312 OSSL_LIB_CTX *ctx, const char *propq);
313
314int i2d_PKCS12_bio(BIO *bp, const PKCS12 *p12);
315# ifndef OPENSSL_NO_STDIO
316int i2d_PKCS12_fp(FILE *fp, const PKCS12 *p12);
317# endif
318PKCS12 *d2i_PKCS12_bio(BIO *bp, PKCS12 **p12);
319# ifndef OPENSSL_NO_STDIO
320PKCS12 *d2i_PKCS12_fp(FILE *fp, PKCS12 **p12);
321# endif
322int PKCS12_newpass(PKCS12 *p12, const char *oldpass, const char *newpass);
323
324# ifdef __cplusplus
325}
326# endif
327#endif
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette