]>
Commit | Line | Data |
---|---|---|
5fe736e5 | 1 | /* |
b0edda11 | 2 | * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved. |
5fe736e5 | 3 | * |
aa6bb135 RS |
4 | * Licensed under the OpenSSL license (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 | |
5fe736e5 DSH |
8 | */ |
9 | ||
10 | /* Internal ASN1 structures and functions: not for application use */ | |
11 | ||
12 | /* ASN1 public key method structure */ | |
13 | ||
14 | struct evp_pkey_asn1_method_st { | |
15 | int pkey_id; | |
16 | int pkey_base_id; | |
17 | unsigned long pkey_flags; | |
18 | char *pem_str; | |
19 | char *info; | |
20 | int (*pub_decode) (EVP_PKEY *pk, X509_PUBKEY *pub); | |
21 | int (*pub_encode) (X509_PUBKEY *pub, const EVP_PKEY *pk); | |
22 | int (*pub_cmp) (const EVP_PKEY *a, const EVP_PKEY *b); | |
23 | int (*pub_print) (BIO *out, const EVP_PKEY *pkey, int indent, | |
24 | ASN1_PCTX *pctx); | |
245c6bc3 | 25 | int (*priv_decode) (EVP_PKEY *pk, const PKCS8_PRIV_KEY_INFO *p8inf); |
5fe736e5 DSH |
26 | int (*priv_encode) (PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pk); |
27 | int (*priv_print) (BIO *out, const EVP_PKEY *pkey, int indent, | |
28 | ASN1_PCTX *pctx); | |
29 | int (*pkey_size) (const EVP_PKEY *pk); | |
30 | int (*pkey_bits) (const EVP_PKEY *pk); | |
31 | int (*pkey_security_bits) (const EVP_PKEY *pk); | |
32 | int (*param_decode) (EVP_PKEY *pkey, | |
33 | const unsigned char **pder, int derlen); | |
34 | int (*param_encode) (const EVP_PKEY *pkey, unsigned char **pder); | |
35 | int (*param_missing) (const EVP_PKEY *pk); | |
36 | int (*param_copy) (EVP_PKEY *to, const EVP_PKEY *from); | |
37 | int (*param_cmp) (const EVP_PKEY *a, const EVP_PKEY *b); | |
38 | int (*param_print) (BIO *out, const EVP_PKEY *pkey, int indent, | |
39 | ASN1_PCTX *pctx); | |
40 | int (*sig_print) (BIO *out, | |
41 | const X509_ALGOR *sigalg, const ASN1_STRING *sig, | |
42 | int indent, ASN1_PCTX *pctx); | |
43 | void (*pkey_free) (EVP_PKEY *pkey); | |
44 | int (*pkey_ctrl) (EVP_PKEY *pkey, int op, long arg1, void *arg2); | |
45 | /* Legacy functions for old PEM */ | |
46 | int (*old_priv_decode) (EVP_PKEY *pkey, | |
47 | const unsigned char **pder, int derlen); | |
48 | int (*old_priv_encode) (const EVP_PKEY *pkey, unsigned char **pder); | |
49 | /* Custom ASN1 signature verification */ | |
50 | int (*item_verify) (EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn, | |
51 | X509_ALGOR *a, ASN1_BIT_STRING *sig, EVP_PKEY *pkey); | |
52 | int (*item_sign) (EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn, | |
53 | X509_ALGOR *alg1, X509_ALGOR *alg2, | |
54 | ASN1_BIT_STRING *sig); | |
786dd2c2 DSH |
55 | int (*siginf_set) (X509_SIG_INFO *siginf, const X509_ALGOR *alg, |
56 | const ASN1_STRING *sig); | |
2aee35d3 PY |
57 | /* Check */ |
58 | int (*pkey_check) (const EVP_PKEY *pk); | |
b0004708 PY |
59 | int (*pkey_public_check) (const EVP_PKEY *pk); |
60 | int (*pkey_param_check) (const EVP_PKEY *pk); | |
a08802ce MC |
61 | /* Get/set raw private/public key data */ |
62 | int (*set_priv_key) (EVP_PKEY *pk, const unsigned char *priv, size_t len); | |
63 | int (*set_pub_key) (EVP_PKEY *pk, const unsigned char *pub, size_t len); | |
5fe736e5 | 64 | } /* EVP_PKEY_ASN1_METHOD */ ; |
2e430277 | 65 | |
a8eba56e | 66 | DEFINE_STACK_OF_CONST(EVP_PKEY_ASN1_METHOD) |
4a1f3f27 | 67 | |
df2ee0e2 BL |
68 | extern const EVP_PKEY_ASN1_METHOD cmac_asn1_meth; |
69 | extern const EVP_PKEY_ASN1_METHOD dh_asn1_meth; | |
70 | extern const EVP_PKEY_ASN1_METHOD dhx_asn1_meth; | |
578b5514 | 71 | extern const EVP_PKEY_ASN1_METHOD dsa_asn1_meths[5]; |
df2ee0e2 | 72 | extern const EVP_PKEY_ASN1_METHOD eckey_asn1_meth; |
262bd85f | 73 | extern const EVP_PKEY_ASN1_METHOD ecx25519_asn1_meth; |
13735cfe | 74 | extern const EVP_PKEY_ASN1_METHOD ecx448_asn1_meth; |
a13727e5 | 75 | extern const EVP_PKEY_ASN1_METHOD ed25519_asn1_meth; |
13735cfe | 76 | extern const EVP_PKEY_ASN1_METHOD ed448_asn1_meth; |
52ad5b60 TS |
77 | extern const EVP_PKEY_ASN1_METHOD poly1305_asn1_meth; |
78 | ||
df2ee0e2 | 79 | extern const EVP_PKEY_ASN1_METHOD hmac_asn1_meth; |
578b5514 | 80 | extern const EVP_PKEY_ASN1_METHOD rsa_asn1_meths[2]; |
4e8ba747 | 81 | extern const EVP_PKEY_ASN1_METHOD rsa_pss_asn1_meth; |
3f5616d7 | 82 | extern const EVP_PKEY_ASN1_METHOD siphash_asn1_meth; |
df2ee0e2 | 83 | |
2e430277 DSH |
84 | /* |
85 | * These are used internally in the ASN1_OBJECT to keep track of whether the | |
86 | * names and data need to be free()ed | |
87 | */ | |
88 | # define ASN1_OBJECT_FLAG_DYNAMIC 0x01/* internal use */ | |
89 | # define ASN1_OBJECT_FLAG_CRITICAL 0x02/* critical x509v3 object id */ | |
90 | # define ASN1_OBJECT_FLAG_DYNAMIC_STRINGS 0x04/* internal use */ | |
91 | # define ASN1_OBJECT_FLAG_DYNAMIC_DATA 0x08/* internal use */ | |
92 | struct asn1_object_st { | |
93 | const char *sn, *ln; | |
94 | int nid; | |
95 | int length; | |
96 | const unsigned char *data; /* data remains const after init */ | |
97 | int flags; /* Should we free this one */ | |
98 | }; | |
2743e38c DSH |
99 | |
100 | /* ASN1 print context structure */ | |
101 | ||
102 | struct asn1_pctx_st { | |
103 | unsigned long flags; | |
104 | unsigned long nm_flags; | |
105 | unsigned long cert_flags; | |
106 | unsigned long oid_flags; | |
107 | unsigned long str_flags; | |
108 | } /* ASN1_PCTX */ ; | |
5bd5dcd4 | 109 | |
86f7b042 | 110 | int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb); |