2015-03-23 18:42:42 +00:00
|
|
|
/*
|
2018-03-20 13:00:17 +00:00
|
|
|
* Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
|
2015-03-23 18:42:42 +00:00
|
|
|
*
|
2016-05-17 19:38:09 +00:00
|
|
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
|
|
|
* this file except in compliance with the License. You can obtain a copy
|
|
|
|
* in the file LICENSE in the source distribution or at
|
|
|
|
* https://www.openssl.org/source/license.html
|
2015-03-23 18:42:42 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* Internal ASN1 structures and functions: not for application use */
|
|
|
|
|
|
|
|
/* ASN1 public key method structure */
|
|
|
|
|
|
|
|
struct evp_pkey_asn1_method_st {
|
|
|
|
int pkey_id;
|
|
|
|
int pkey_base_id;
|
|
|
|
unsigned long pkey_flags;
|
|
|
|
char *pem_str;
|
|
|
|
char *info;
|
|
|
|
int (*pub_decode) (EVP_PKEY *pk, X509_PUBKEY *pub);
|
|
|
|
int (*pub_encode) (X509_PUBKEY *pub, const EVP_PKEY *pk);
|
|
|
|
int (*pub_cmp) (const EVP_PKEY *a, const EVP_PKEY *b);
|
|
|
|
int (*pub_print) (BIO *out, const EVP_PKEY *pkey, int indent,
|
|
|
|
ASN1_PCTX *pctx);
|
2016-08-16 23:21:55 +00:00
|
|
|
int (*priv_decode) (EVP_PKEY *pk, const PKCS8_PRIV_KEY_INFO *p8inf);
|
2015-03-23 18:42:42 +00:00
|
|
|
int (*priv_encode) (PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pk);
|
|
|
|
int (*priv_print) (BIO *out, const EVP_PKEY *pkey, int indent,
|
|
|
|
ASN1_PCTX *pctx);
|
|
|
|
int (*pkey_size) (const EVP_PKEY *pk);
|
|
|
|
int (*pkey_bits) (const EVP_PKEY *pk);
|
|
|
|
int (*pkey_security_bits) (const EVP_PKEY *pk);
|
|
|
|
int (*param_decode) (EVP_PKEY *pkey,
|
|
|
|
const unsigned char **pder, int derlen);
|
|
|
|
int (*param_encode) (const EVP_PKEY *pkey, unsigned char **pder);
|
|
|
|
int (*param_missing) (const EVP_PKEY *pk);
|
|
|
|
int (*param_copy) (EVP_PKEY *to, const EVP_PKEY *from);
|
|
|
|
int (*param_cmp) (const EVP_PKEY *a, const EVP_PKEY *b);
|
|
|
|
int (*param_print) (BIO *out, const EVP_PKEY *pkey, int indent,
|
|
|
|
ASN1_PCTX *pctx);
|
|
|
|
int (*sig_print) (BIO *out,
|
|
|
|
const X509_ALGOR *sigalg, const ASN1_STRING *sig,
|
|
|
|
int indent, ASN1_PCTX *pctx);
|
|
|
|
void (*pkey_free) (EVP_PKEY *pkey);
|
|
|
|
int (*pkey_ctrl) (EVP_PKEY *pkey, int op, long arg1, void *arg2);
|
|
|
|
/* Legacy functions for old PEM */
|
|
|
|
int (*old_priv_decode) (EVP_PKEY *pkey,
|
|
|
|
const unsigned char **pder, int derlen);
|
|
|
|
int (*old_priv_encode) (const EVP_PKEY *pkey, unsigned char **pder);
|
|
|
|
/* Custom ASN1 signature verification */
|
|
|
|
int (*item_verify) (EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn,
|
|
|
|
X509_ALGOR *a, ASN1_BIT_STRING *sig, EVP_PKEY *pkey);
|
|
|
|
int (*item_sign) (EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn,
|
|
|
|
X509_ALGOR *alg1, X509_ALGOR *alg2,
|
|
|
|
ASN1_BIT_STRING *sig);
|
2017-04-21 14:56:34 +00:00
|
|
|
int (*siginf_set) (X509_SIG_INFO *siginf, const X509_ALGOR *alg,
|
|
|
|
const ASN1_STRING *sig);
|
2017-09-04 14:02:59 +00:00
|
|
|
/* Check */
|
|
|
|
int (*pkey_check) (const EVP_PKEY *pk);
|
2017-10-31 16:45:24 +00:00
|
|
|
int (*pkey_public_check) (const EVP_PKEY *pk);
|
|
|
|
int (*pkey_param_check) (const EVP_PKEY *pk);
|
2018-03-05 14:06:41 +00:00
|
|
|
/* Get/set raw private/public key data */
|
|
|
|
int (*set_priv_key) (EVP_PKEY *pk, const unsigned char *priv, size_t len);
|
|
|
|
int (*set_pub_key) (EVP_PKEY *pk, const unsigned char *pub, size_t len);
|
2018-06-01 11:22:28 +00:00
|
|
|
int (*get_priv_key) (const EVP_PKEY *pk, unsigned char *priv, size_t *len);
|
|
|
|
int (*get_pub_key) (const EVP_PKEY *pk, unsigned char *pub, size_t *len);
|
2015-03-23 18:42:42 +00:00
|
|
|
} /* EVP_PKEY_ASN1_METHOD */ ;
|
2015-03-15 16:26:04 +00:00
|
|
|
|
2016-01-07 17:02:20 +00:00
|
|
|
DEFINE_STACK_OF_CONST(EVP_PKEY_ASN1_METHOD)
|
2016-01-06 02:54:18 +00:00
|
|
|
|
2015-09-05 12:32:58 +00:00
|
|
|
extern const EVP_PKEY_ASN1_METHOD cmac_asn1_meth;
|
|
|
|
extern const EVP_PKEY_ASN1_METHOD dh_asn1_meth;
|
|
|
|
extern const EVP_PKEY_ASN1_METHOD dhx_asn1_meth;
|
2016-05-27 19:10:05 +00:00
|
|
|
extern const EVP_PKEY_ASN1_METHOD dsa_asn1_meths[5];
|
2015-09-05 12:32:58 +00:00
|
|
|
extern const EVP_PKEY_ASN1_METHOD eckey_asn1_meth;
|
2016-08-09 20:58:55 +00:00
|
|
|
extern const EVP_PKEY_ASN1_METHOD ecx25519_asn1_meth;
|
2018-02-28 14:59:44 +00:00
|
|
|
extern const EVP_PKEY_ASN1_METHOD ecx448_asn1_meth;
|
2017-04-05 15:48:32 +00:00
|
|
|
extern const EVP_PKEY_ASN1_METHOD ed25519_asn1_meth;
|
2018-02-28 14:59:44 +00:00
|
|
|
extern const EVP_PKEY_ASN1_METHOD ed448_asn1_meth;
|
2018-06-18 19:51:56 +00:00
|
|
|
extern const EVP_PKEY_ASN1_METHOD sm2_asn1_meth;
|
2016-12-16 22:00:43 +00:00
|
|
|
extern const EVP_PKEY_ASN1_METHOD poly1305_asn1_meth;
|
|
|
|
|
2015-09-05 12:32:58 +00:00
|
|
|
extern const EVP_PKEY_ASN1_METHOD hmac_asn1_meth;
|
2016-05-27 19:10:05 +00:00
|
|
|
extern const EVP_PKEY_ASN1_METHOD rsa_asn1_meths[2];
|
2016-11-24 21:42:49 +00:00
|
|
|
extern const EVP_PKEY_ASN1_METHOD rsa_pss_asn1_meth;
|
2017-01-11 21:38:44 +00:00
|
|
|
extern const EVP_PKEY_ASN1_METHOD siphash_asn1_meth;
|
2015-09-05 12:32:58 +00:00
|
|
|
|
2015-03-15 16:26:04 +00:00
|
|
|
/*
|
|
|
|
* These are used internally in the ASN1_OBJECT to keep track of whether the
|
|
|
|
* names and data need to be free()ed
|
|
|
|
*/
|
|
|
|
# define ASN1_OBJECT_FLAG_DYNAMIC 0x01/* internal use */
|
|
|
|
# define ASN1_OBJECT_FLAG_CRITICAL 0x02/* critical x509v3 object id */
|
|
|
|
# define ASN1_OBJECT_FLAG_DYNAMIC_STRINGS 0x04/* internal use */
|
|
|
|
# define ASN1_OBJECT_FLAG_DYNAMIC_DATA 0x08/* internal use */
|
|
|
|
struct asn1_object_st {
|
|
|
|
const char *sn, *ln;
|
|
|
|
int nid;
|
|
|
|
int length;
|
|
|
|
const unsigned char *data; /* data remains const after init */
|
|
|
|
int flags; /* Should we free this one */
|
|
|
|
};
|
2015-03-16 17:43:17 +00:00
|
|
|
|
|
|
|
/* ASN1 print context structure */
|
|
|
|
|
|
|
|
struct asn1_pctx_st {
|
|
|
|
unsigned long flags;
|
|
|
|
unsigned long nm_flags;
|
|
|
|
unsigned long cert_flags;
|
|
|
|
unsigned long oid_flags;
|
|
|
|
unsigned long str_flags;
|
|
|
|
} /* ASN1_PCTX */ ;
|
2016-07-03 20:41:57 +00:00
|
|
|
|
2016-11-18 17:17:20 +00:00
|
|
|
int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb);
|