VirtualBox

source: vbox/trunk/src/libs/openssl-3.1.2/include/crypto/asn1.h@ 101021

Last change on this file since 101021 was 101021, checked in by vboxsync, 15 months ago

openssl-3.1.2: Applied and adjusted our OpenSSL changes to 3.1.0. bugref:10519

File size: 6.6 KB
Line 
1/*
2 * Copyright 2015-2021 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8 */
9
10#ifndef OSSL_CRYPTO_ASN1_H
11# define OSSL_CRYPTO_ASN1_H
12# ifndef RT_WITHOUT_PRAGMA_ONCE /* VBOX */
13# pragma once
14# endif /* VBOX */
15
16# include <openssl/asn1.h>
17# include <openssl/core_dispatch.h> /* OSSL_FUNC_keymgmt_import() */
18
19/* Internal ASN1 structures and functions: not for application use */
20
21/* ASN1 public key method structure */
22
23#include <openssl/core.h>
24
25struct evp_pkey_asn1_method_st {
26 int pkey_id;
27 int pkey_base_id;
28 unsigned long pkey_flags;
29 char *pem_str;
30 char *info;
31 int (*pub_decode) (EVP_PKEY *pk, const X509_PUBKEY *pub);
32 int (*pub_encode) (X509_PUBKEY *pub, const EVP_PKEY *pk);
33 int (*pub_cmp) (const EVP_PKEY *a, const EVP_PKEY *b);
34 int (*pub_print) (BIO *out, const EVP_PKEY *pkey, int indent,
35 ASN1_PCTX *pctx);
36 int (*priv_decode) (EVP_PKEY *pk, const PKCS8_PRIV_KEY_INFO *p8inf);
37 int (*priv_encode) (PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pk);
38 int (*priv_print) (BIO *out, const EVP_PKEY *pkey, int indent,
39 ASN1_PCTX *pctx);
40 int (*pkey_size) (const EVP_PKEY *pk);
41 int (*pkey_bits) (const EVP_PKEY *pk);
42 int (*pkey_security_bits) (const EVP_PKEY *pk);
43 int (*param_decode) (EVP_PKEY *pkey,
44 const unsigned char **pder, int derlen);
45 int (*param_encode) (const EVP_PKEY *pkey, unsigned char **pder);
46 int (*param_missing) (const EVP_PKEY *pk);
47 int (*param_copy) (EVP_PKEY *to, const EVP_PKEY *from);
48 int (*param_cmp) (const EVP_PKEY *a, const EVP_PKEY *b);
49 int (*param_print) (BIO *out, const EVP_PKEY *pkey, int indent,
50 ASN1_PCTX *pctx);
51 int (*sig_print) (BIO *out,
52 const X509_ALGOR *sigalg, const ASN1_STRING *sig,
53 int indent, ASN1_PCTX *pctx);
54 void (*pkey_free) (EVP_PKEY *pkey);
55 int (*pkey_ctrl) (EVP_PKEY *pkey, int op, long arg1, void *arg2);
56 /* Legacy functions for old PEM */
57 int (*old_priv_decode) (EVP_PKEY *pkey,
58 const unsigned char **pder, int derlen);
59 int (*old_priv_encode) (const EVP_PKEY *pkey, unsigned char **pder);
60 /* Custom ASN1 signature verification */
61 int (*item_verify) (EVP_MD_CTX *ctx, const ASN1_ITEM *it, const void *data,
62 const X509_ALGOR *a, const ASN1_BIT_STRING *sig,
63 EVP_PKEY *pkey);
64 int (*item_sign) (EVP_MD_CTX *ctx, const ASN1_ITEM *it, const void *data,
65 X509_ALGOR *alg1, X509_ALGOR *alg2,
66 ASN1_BIT_STRING *sig);
67 int (*siginf_set) (X509_SIG_INFO *siginf, const X509_ALGOR *alg,
68 const ASN1_STRING *sig);
69 /* Check */
70 int (*pkey_check) (const EVP_PKEY *pk);
71 int (*pkey_public_check) (const EVP_PKEY *pk);
72 int (*pkey_param_check) (const EVP_PKEY *pk);
73 /* Get/set raw private/public key data */
74 int (*set_priv_key) (EVP_PKEY *pk, const unsigned char *priv, size_t len);
75 int (*set_pub_key) (EVP_PKEY *pk, const unsigned char *pub, size_t len);
76 int (*get_priv_key) (const EVP_PKEY *pk, unsigned char *priv, size_t *len);
77 int (*get_pub_key) (const EVP_PKEY *pk, unsigned char *pub, size_t *len);
78
79 /* Exports and imports to / from providers */
80 size_t (*dirty_cnt) (const EVP_PKEY *pk);
81 int (*export_to) (const EVP_PKEY *pk, void *to_keydata,
82 OSSL_FUNC_keymgmt_import_fn *importer,
83 OSSL_LIB_CTX *libctx, const char *propq);
84 OSSL_CALLBACK *import_from;
85 int (*copy) (EVP_PKEY *to, EVP_PKEY *from);
86
87 int (*priv_decode_ex) (EVP_PKEY *pk,
88 const PKCS8_PRIV_KEY_INFO *p8inf,
89 OSSL_LIB_CTX *libctx,
90 const char *propq);
91} /* EVP_PKEY_ASN1_METHOD */ ;
92
93DEFINE_STACK_OF_CONST(EVP_PKEY_ASN1_METHOD)
94
95extern const EVP_PKEY_ASN1_METHOD ossl_dh_asn1_meth;
96extern const EVP_PKEY_ASN1_METHOD ossl_dhx_asn1_meth;
97extern const EVP_PKEY_ASN1_METHOD ossl_dsa_asn1_meths[5];
98extern const EVP_PKEY_ASN1_METHOD ossl_eckey_asn1_meth;
99extern const EVP_PKEY_ASN1_METHOD ossl_ecx25519_asn1_meth;
100extern const EVP_PKEY_ASN1_METHOD ossl_ecx448_asn1_meth;
101extern const EVP_PKEY_ASN1_METHOD ossl_ed25519_asn1_meth;
102extern const EVP_PKEY_ASN1_METHOD ossl_ed448_asn1_meth;
103extern const EVP_PKEY_ASN1_METHOD ossl_sm2_asn1_meth;
104
105extern const EVP_PKEY_ASN1_METHOD ossl_rsa_asn1_meths[2];
106extern const EVP_PKEY_ASN1_METHOD ossl_rsa_pss_asn1_meth;
107
108/*
109 * These are used internally in the ASN1_OBJECT to keep track of whether the
110 * names and data need to be free()ed
111 */
112# define ASN1_OBJECT_FLAG_DYNAMIC 0x01/* internal use */
113# define ASN1_OBJECT_FLAG_CRITICAL 0x02/* critical x509v3 object id */
114# define ASN1_OBJECT_FLAG_DYNAMIC_STRINGS 0x04/* internal use */
115# define ASN1_OBJECT_FLAG_DYNAMIC_DATA 0x08/* internal use */
116struct asn1_object_st {
117 const char *sn, *ln;
118 int nid;
119 int length;
120 const unsigned char *data; /* data remains const after init */
121 int flags; /* Should we free this one */
122};
123
124/* ASN1 print context structure */
125
126struct asn1_pctx_st {
127 unsigned long flags;
128 unsigned long nm_flags;
129 unsigned long cert_flags;
130 unsigned long oid_flags;
131 unsigned long str_flags;
132} /* ASN1_PCTX */ ;
133
134/* ASN1 type functions */
135
136int ossl_asn1_type_set_octetstring_int(ASN1_TYPE *a, long num,
137 unsigned char *data, int len);
138int ossl_asn1_type_get_octetstring_int(const ASN1_TYPE *a, long *num,
139 unsigned char *data, int max_len);
140
141int ossl_x509_algor_new_from_md(X509_ALGOR **palg, const EVP_MD *md);
142const EVP_MD *ossl_x509_algor_get_md(X509_ALGOR *alg);
143X509_ALGOR *ossl_x509_algor_mgf1_decode(X509_ALGOR *alg);
144int ossl_x509_algor_md_to_mgf1(X509_ALGOR **palg, const EVP_MD *mgf1md);
145int ossl_asn1_time_print_ex(BIO *bp, const ASN1_TIME *tm, unsigned long flags);
146
147EVP_PKEY * ossl_d2i_PrivateKey_legacy(int keytype, EVP_PKEY **a,
148 const unsigned char **pp, long length,
149 OSSL_LIB_CTX *libctx, const char *propq);
150
151#endif /* ndef OSSL_CRYPTO_ASN1_H */
Note: See TracBrowser for help on using the repository browser.

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