Latest update.
This commit is contained in:
@@ -11,6 +11,8 @@
|
||||
|
||||
/* ASN1 public key method structure */
|
||||
|
||||
#include <openssl/core.h>
|
||||
|
||||
struct evp_pkey_asn1_method_st {
|
||||
int pkey_id;
|
||||
int pkey_base_id;
|
||||
@@ -68,10 +70,12 @@ struct evp_pkey_asn1_method_st {
|
||||
* TODO: Make sure these functions are defined for key types that are
|
||||
* implemented in providers.
|
||||
*/
|
||||
/* Exports to providers */
|
||||
/* Exports and imports to / from providers */
|
||||
size_t (*dirty_cnt) (const EVP_PKEY *pk);
|
||||
int (*export_to) (const EVP_PKEY *pk, void *to_keydata,
|
||||
EVP_KEYMGMT *to_keymgmt);
|
||||
EVP_KEYMGMT *to_keymgmt, OPENSSL_CTX *libctx,
|
||||
const char *propq);
|
||||
OSSL_CALLBACK *import_from;
|
||||
} /* EVP_PKEY_ASN1_METHOD */ ;
|
||||
|
||||
DEFINE_STACK_OF_CONST(EVP_PKEY_ASN1_METHOD)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include <openssl/core.h>
|
||||
#include <openssl/dh.h>
|
||||
#include "internal/ffc.h"
|
||||
|
||||
@@ -19,7 +20,10 @@ int dh_generate_public_key(BN_CTX *ctx, DH *dh, const BIGNUM *priv_key,
|
||||
|
||||
FFC_PARAMS *dh_get0_params(DH *dh);
|
||||
int dh_get0_nid(const DH *dh);
|
||||
int dh_key_fromdata(DH *dh, const OSSL_PARAM params[]);
|
||||
|
||||
int dh_check_pub_key_partial(const DH *dh, const BIGNUM *pub_key, int *ret);
|
||||
int dh_check_priv_key(const DH *dh, const BIGNUM *priv_key, int *ret);
|
||||
int dh_check_pairwise(DH *dh);
|
||||
|
||||
const DH_METHOD *dh_get_method(const DH *dh);
|
||||
@@ -7,6 +7,7 @@
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include <openssl/core.h>
|
||||
#include <openssl/dsa.h>
|
||||
#include "internal/ffc.h"
|
||||
|
||||
@@ -24,6 +25,7 @@ int dsa_sign_int(int type, const unsigned char *dgst,
|
||||
const unsigned char *dsa_algorithmidentifier_encoding(int md_nid, size_t *len);
|
||||
|
||||
FFC_PARAMS *dsa_get0_params(DSA *dsa);
|
||||
int dsa_key_fromdata(DSA *dsa, const OSSL_PARAM params[]);
|
||||
|
||||
int dsa_generate_public_key(BN_CTX *ctx, const DSA *dsa, const BIGNUM *priv_key,
|
||||
BIGNUM *pub_key);
|
||||
|
||||
+15
-1
@@ -14,7 +14,7 @@
|
||||
# include <openssl/opensslconf.h>
|
||||
|
||||
# ifndef OPENSSL_NO_EC
|
||||
|
||||
# include <openssl/core.h>
|
||||
# include <openssl/ec.h>
|
||||
|
||||
/*-
|
||||
@@ -50,5 +50,19 @@ int ecdh_KDF_X9_63(unsigned char *out, size_t outlen,
|
||||
const EVP_MD *md);
|
||||
|
||||
int ec_generate_key(OPENSSL_CTX *libctx, EC_KEY *eckey, int pairwise_test);
|
||||
int ec_key_public_check(const EC_KEY *eckey, BN_CTX *ctx);
|
||||
int ec_key_private_check(const EC_KEY *eckey);
|
||||
int ec_key_pairwise_check(const EC_KEY *eckey, BN_CTX *ctx);
|
||||
OPENSSL_CTX *ec_key_get_libctx(const EC_KEY *eckey);
|
||||
const char *ec_curve_nid2name(int nid);
|
||||
int ec_curve_name2nid(const char *name);
|
||||
const unsigned char *ecdsa_algorithmidentifier_encoding(int md_nid, size_t *len);
|
||||
|
||||
/* Backend support */
|
||||
int ec_key_fromdata(EC_KEY *ecx, const OSSL_PARAM params[], int include_private);
|
||||
int ec_key_domparams_fromdata(EC_KEY *ecx, const OSSL_PARAM params[]);
|
||||
int ec_key_otherparams_fromdata(EC_KEY *ec, const OSSL_PARAM params[]);
|
||||
int ec_set_param_ecdh_cofactor_mode(EC_KEY *ec, const OSSL_PARAM *p);
|
||||
|
||||
# endif /* OPENSSL_NO_EC */
|
||||
#endif
|
||||
+56
-12
@@ -15,40 +15,64 @@
|
||||
|
||||
# ifndef OPENSSL_NO_EC
|
||||
|
||||
# include <openssl/core.h>
|
||||
# include <openssl/e_os2.h>
|
||||
# include <openssl/crypto.h>
|
||||
# include "internal/refcount.h"
|
||||
|
||||
# define X25519_KEYLEN 32
|
||||
# define X448_KEYLEN 56
|
||||
# define ED25519_KEYLEN 32
|
||||
# define ED448_KEYLEN 57
|
||||
# define X25519_KEYLEN 32
|
||||
# define X448_KEYLEN 56
|
||||
# define ED25519_KEYLEN 32
|
||||
# define ED448_KEYLEN 57
|
||||
|
||||
# define MAX_KEYLEN ED448_KEYLEN
|
||||
|
||||
# define X25519_BITS 253
|
||||
# define X25519_SECURITY_BITS 128
|
||||
# define X25519_BITS 253
|
||||
# define X25519_SECURITY_BITS 128
|
||||
|
||||
# define ED25519_SIGSIZE 64
|
||||
# define X448_BITS 448
|
||||
# define X448_SECURITY_BITS 224
|
||||
|
||||
# define X448_BITS 448
|
||||
# define ED448_BITS 456
|
||||
# define X448_SECURITY_BITS 224
|
||||
# define ED25519_BITS 256
|
||||
/* RFC8032 Section 8.5 */
|
||||
# define ED25519_SECURITY_BITS 128
|
||||
# define ED25519_SIGSIZE 64
|
||||
|
||||
# define ED448_SIGSIZE 114
|
||||
# define ED448_BITS 456
|
||||
/* RFC8032 Section 8.5 */
|
||||
# define ED448_SECURITY_BITS 224
|
||||
# define ED448_SIGSIZE 114
|
||||
|
||||
|
||||
typedef enum {
|
||||
ECX_KEY_TYPE_X25519,
|
||||
ECX_KEY_TYPE_X448,
|
||||
ECX_KEY_TYPE_ED25519,
|
||||
ECX_KEY_TYPE_ED448
|
||||
} ECX_KEY_TYPE;
|
||||
|
||||
#define KEYTYPE2NID(type) \
|
||||
((type) == ECX_KEY_TYPE_X25519 \
|
||||
? EVP_PKEY_X25519 \
|
||||
: ((type) == ECX_KEY_TYPE_X448 \
|
||||
? EVP_PKEY_X448 \
|
||||
: ((type) == ECX_KEY_TYPE_ED25519 \
|
||||
? EVP_PKEY_ED25519 \
|
||||
: EVP_PKEY_ED448)))
|
||||
|
||||
struct ecx_key_st {
|
||||
unsigned int haspubkey:1;
|
||||
unsigned char pubkey[MAX_KEYLEN];
|
||||
unsigned char *privkey;
|
||||
size_t keylen;
|
||||
ECX_KEY_TYPE type;
|
||||
CRYPTO_REF_COUNT references;
|
||||
CRYPTO_RWLOCK *lock;
|
||||
};
|
||||
|
||||
typedef struct ecx_key_st ECX_KEY;
|
||||
|
||||
ECX_KEY *ecx_key_new(size_t keylen, int haspubkey);
|
||||
ECX_KEY *ecx_key_new(ECX_KEY_TYPE type, int haspubkey);
|
||||
unsigned char *ecx_key_allocate_privkey(ECX_KEY *key);
|
||||
void ecx_key_free(ECX_KEY *key);
|
||||
int ecx_key_up_ref(ECX_KEY *key);
|
||||
@@ -58,6 +82,22 @@ int X25519(uint8_t out_shared_key[32], const uint8_t private_key[32],
|
||||
void X25519_public_from_private(uint8_t out_public_value[32],
|
||||
const uint8_t private_key[32]);
|
||||
|
||||
int ED25519_sign(uint8_t *out_sig, const uint8_t *message, size_t message_len,
|
||||
const uint8_t public_key[32], const uint8_t private_key[32],
|
||||
OPENSSL_CTX *libctx, const char *propq);
|
||||
int ED25519_verify(const uint8_t *message, size_t message_len,
|
||||
const uint8_t signature[64], const uint8_t public_key[32],
|
||||
OPENSSL_CTX *libctx, const char *propq);
|
||||
|
||||
int ED448_sign(OPENSSL_CTX *ctx, uint8_t *out_sig, const uint8_t *message,
|
||||
size_t message_len, const uint8_t public_key[57],
|
||||
const uint8_t private_key[57], const uint8_t *context,
|
||||
size_t context_len);
|
||||
|
||||
int ED448_verify(OPENSSL_CTX *ctx, const uint8_t *message, size_t message_len,
|
||||
const uint8_t signature[114], const uint8_t public_key[57],
|
||||
const uint8_t *context, size_t context_len);
|
||||
|
||||
int X448(uint8_t out_shared_key[56], const uint8_t private_key[56],
|
||||
const uint8_t peer_public_value[56]);
|
||||
void X448_public_from_private(uint8_t out_public_value[56],
|
||||
@@ -70,5 +110,9 @@ int s390x_x448_mul(unsigned char u_dst[56],
|
||||
const unsigned char u_src[56],
|
||||
const unsigned char d_src[56]);
|
||||
|
||||
/* Backend support */
|
||||
int ecx_key_fromdata(ECX_KEY *ecx, const OSSL_PARAM params[],
|
||||
int include_private);
|
||||
|
||||
# endif /* OPENSSL_NO_EC */
|
||||
#endif
|
||||
+72
-25
@@ -23,17 +23,19 @@ struct evp_pkey_ctx_st {
|
||||
int operation;
|
||||
|
||||
/*
|
||||
* Library context, Key type name and properties associated
|
||||
* with this context
|
||||
* Library context, property query, keytype and keymgmt associated with
|
||||
* this context
|
||||
*/
|
||||
OPENSSL_CTX *libctx;
|
||||
const char *keytype;
|
||||
const char *propquery;
|
||||
|
||||
/* cached key manager */
|
||||
const char *keytype;
|
||||
EVP_KEYMGMT *keymgmt;
|
||||
|
||||
union {
|
||||
struct {
|
||||
void *genctx;
|
||||
} keymgmt;
|
||||
|
||||
struct {
|
||||
EVP_KEYEXCH *exchange;
|
||||
void *exchprovctx;
|
||||
@@ -50,6 +52,14 @@ struct evp_pkey_ctx_st {
|
||||
} ciph;
|
||||
} op;
|
||||
|
||||
/* Application specific data, usually used by the callback */
|
||||
void *app_data;
|
||||
/* Keygen callback */
|
||||
EVP_PKEY_gen_cb *pkey_gencb;
|
||||
/* implementation specific keygen data */
|
||||
int *keygen_info;
|
||||
int keygen_info_count;
|
||||
|
||||
/* Legacy fields below */
|
||||
|
||||
/* Method associated with this operation */
|
||||
@@ -62,13 +72,8 @@ struct evp_pkey_ctx_st {
|
||||
EVP_PKEY *peerkey;
|
||||
/* Algorithm specific data */
|
||||
void *data;
|
||||
/* Application specific data */
|
||||
void *app_data;
|
||||
/* Keygen callback */
|
||||
EVP_PKEY_gen_cb *pkey_gencb;
|
||||
/* implementation specific keygen data */
|
||||
int *keygen_info;
|
||||
int keygen_info_count;
|
||||
/* Indicator if digest_custom needs to be called */
|
||||
unsigned int flag_call_digest_custom:1;
|
||||
} /* EVP_PKEY_CTX */ ;
|
||||
|
||||
#define EVP_PKEY_FLAG_DYNAMIC 1
|
||||
@@ -497,14 +502,31 @@ const EVP_CIPHER *EVP_##cname##_ecb(void) { return &cname##_ecb; }
|
||||
cipher##_init_key, NULL, NULL, NULL, NULL)
|
||||
|
||||
/*
|
||||
* Type needs to be a bit field Sub-type needs to be for variations on the
|
||||
* method, as in, can it do arbitrary encryption....
|
||||
* An EVP_PKEY can have the following states:
|
||||
*
|
||||
* untyped & empty:
|
||||
*
|
||||
* type == EVP_PKEY_NONE && keymgmt == NULL
|
||||
*
|
||||
* typed & empty:
|
||||
*
|
||||
* (type != EVP_PKEY_NONE && pkey.ptr == NULL) ## legacy (libcrypto only)
|
||||
* || (keymgmt != NULL && keydata == NULL) ## provider side
|
||||
*
|
||||
* fully assigned:
|
||||
*
|
||||
* (type != EVP_PKEY_NONE && pkey.ptr != NULL) ## legacy (libcrypto only)
|
||||
* || (keymgmt != NULL && keydata != NULL) ## provider side
|
||||
*
|
||||
* The easiest way to detect a legacy key is: type != EVP_PKEY_NONE
|
||||
* The easiest way to detect a provider side key is: keymgmt != NULL
|
||||
*/
|
||||
struct evp_pkey_st {
|
||||
/* == Legacy attributes == */
|
||||
int type;
|
||||
int save_type;
|
||||
|
||||
# ifndef FIPS_MODE
|
||||
/*
|
||||
* Legacy key "origin" is composed of a pointer to an EVP_PKEY_ASN1_METHOD,
|
||||
* a pointer to a low level key and possibly a pointer to an engine.
|
||||
@@ -514,26 +536,30 @@ struct evp_pkey_st {
|
||||
ENGINE *pmeth_engine; /* If not NULL public key ENGINE to use */
|
||||
union {
|
||||
void *ptr;
|
||||
# ifndef OPENSSL_NO_RSA
|
||||
# ifndef OPENSSL_NO_RSA
|
||||
struct rsa_st *rsa; /* RSA */
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_DSA
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_DSA
|
||||
struct dsa_st *dsa; /* DSA */
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_DH
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_DH
|
||||
struct dh_st *dh; /* DH */
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_EC
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_EC
|
||||
struct ec_key_st *ec; /* ECC */
|
||||
ECX_KEY *ecx; /* X25519, X448, Ed25519, Ed448 */
|
||||
# endif
|
||||
# endif
|
||||
} pkey;
|
||||
# endif
|
||||
|
||||
/* == Common attributes == */
|
||||
CRYPTO_REF_COUNT references;
|
||||
CRYPTO_RWLOCK *lock;
|
||||
STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */
|
||||
int save_parameters;
|
||||
#ifndef FIPS_MODE
|
||||
CRYPTO_EX_DATA ex_data;
|
||||
#endif
|
||||
|
||||
/* == Provider attributes == */
|
||||
|
||||
@@ -596,6 +622,10 @@ struct evp_pkey_st {
|
||||
((ctx)->operation == EVP_PKEY_OP_ENCRYPT \
|
||||
|| (ctx)->operation == EVP_PKEY_OP_DECRYPT)
|
||||
|
||||
#define EVP_PKEY_CTX_IS_GEN_OP(ctx) \
|
||||
((ctx)->operation == EVP_PKEY_OP_PARAMGEN \
|
||||
|| (ctx)->operation == EVP_PKEY_OP_KEYGEN)
|
||||
|
||||
void openssl_add_all_ciphers_int(void);
|
||||
void openssl_add_all_digests_int(void);
|
||||
void evp_cleanup_int(void);
|
||||
@@ -603,9 +633,10 @@ void evp_app_cleanup_int(void);
|
||||
void *evp_pkey_export_to_provider(EVP_PKEY *pk, OPENSSL_CTX *libctx,
|
||||
EVP_KEYMGMT **keymgmt,
|
||||
const char *propquery);
|
||||
void *evp_pkey_upgrade_to_provider(EVP_PKEY *pk, OPENSSL_CTX *libctx,
|
||||
EVP_KEYMGMT **keymgmt,
|
||||
const char *propquery);
|
||||
#ifndef FIPS_MODE
|
||||
int evp_pkey_downgrade(EVP_PKEY *pk);
|
||||
void evp_pkey_free_legacy(EVP_PKEY *x);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* KEYMGMT utility functions
|
||||
@@ -622,6 +653,8 @@ void *evp_keymgmt_util_fromdata(EVP_PKEY *target, EVP_KEYMGMT *keymgmt,
|
||||
int evp_keymgmt_util_has(EVP_PKEY *pk, int selection);
|
||||
int evp_keymgmt_util_match(EVP_PKEY *pk1, EVP_PKEY *pk2, int selection);
|
||||
int evp_keymgmt_util_copy(EVP_PKEY *to, EVP_PKEY *from, int selection);
|
||||
void *evp_keymgmt_util_gen(EVP_PKEY *target, EVP_KEYMGMT *keymgmt,
|
||||
void *genctx, OSSL_CALLBACK *cb, void *cbarg);
|
||||
|
||||
|
||||
/*
|
||||
@@ -636,6 +669,20 @@ int evp_keymgmt_set_params(const EVP_KEYMGMT *keymgmt,
|
||||
void *keydata, const OSSL_PARAM params[]);
|
||||
const OSSL_PARAM *evp_keymgmt_settable_params(const EVP_KEYMGMT *keymgmt);
|
||||
|
||||
void *evp_keymgmt_gen_init(const EVP_KEYMGMT *keymgmt, int selection);
|
||||
int evp_keymgmt_gen_set_template(const EVP_KEYMGMT *keymgmt, void *genctx,
|
||||
void *template);
|
||||
int evp_keymgmt_gen_set_params(const EVP_KEYMGMT *keymgmt, void *genctx,
|
||||
const OSSL_PARAM params[]);
|
||||
const OSSL_PARAM *
|
||||
evp_keymgmt_gen_settable_params(const EVP_KEYMGMT *keymgmt);
|
||||
int evp_keymgmt_gen_get_params(const EVP_KEYMGMT *keymgmt, void *genctx,
|
||||
OSSL_PARAM params[]);
|
||||
const OSSL_PARAM *
|
||||
evp_keymgmt_gen_gettable_params(const EVP_KEYMGMT *keymgmt);
|
||||
void *evp_keymgmt_gen(const EVP_KEYMGMT *keymgmt, void *genctx,
|
||||
OSSL_CALLBACK *cb, void *cbarg);
|
||||
void evp_keymgmt_gen_cleanup(const EVP_KEYMGMT *keymgmt, void *genctx);
|
||||
|
||||
int evp_keymgmt_has(const EVP_KEYMGMT *keymgmt, void *keyddata, int selection);
|
||||
int evp_keymgmt_validate(const EVP_KEYMGMT *keymgmt, void *keydata,
|
||||
|
||||
+10
-3
@@ -10,6 +10,7 @@
|
||||
#ifndef OSSL_INTERNAL_RSA_H
|
||||
# define OSSL_INTERNAL_RSA_H
|
||||
|
||||
#include <openssl/core.h>
|
||||
#include <openssl/rsa.h>
|
||||
|
||||
RSA *rsa_new_with_ctx(OPENSSL_CTX *libctx);
|
||||
@@ -20,10 +21,12 @@ int rsa_set0_all_params(RSA *r, const STACK_OF(BIGNUM) *primes,
|
||||
int rsa_get0_all_params(RSA *r, STACK_OF(BIGNUM_const) *primes,
|
||||
STACK_OF(BIGNUM_const) *exps,
|
||||
STACK_OF(BIGNUM_const) *coeffs);
|
||||
int rsa_fromdata(RSA *rsa, const OSSL_PARAM params[]);
|
||||
|
||||
int rsa_padding_check_PKCS1_type_2_TLS(unsigned char *to, size_t tlen,
|
||||
const unsigned char *from, size_t flen,
|
||||
int client_version, int alt_version);
|
||||
int rsa_padding_check_PKCS1_type_2_TLS(OPENSSL_CTX *ctx, unsigned char *to,
|
||||
size_t tlen, const unsigned char *from,
|
||||
size_t flen, int client_version,
|
||||
int alt_version);
|
||||
|
||||
int rsa_validate_public(const RSA *key);
|
||||
int rsa_validate_private(const RSA *key);
|
||||
@@ -37,4 +40,8 @@ int int_rsa_verify(int dtype, const unsigned char *m,
|
||||
const unsigned char *rsa_digestinfo_encoding(int md_nid, size_t *len);
|
||||
const unsigned char *rsa_algorithmidentifier_encoding(int md_nid, size_t *len);
|
||||
|
||||
extern const char *rsa_mp_factor_names[];
|
||||
extern const char *rsa_mp_exp_names[];
|
||||
extern const char *rsa_mp_coeff_names[];
|
||||
|
||||
#endif
|
||||
+14
-8
@@ -71,9 +71,9 @@ struct X509_req_st {
|
||||
ASN1_BIT_STRING *signature; /* signature */
|
||||
CRYPTO_REF_COUNT references;
|
||||
CRYPTO_RWLOCK *lock;
|
||||
# ifndef OPENSSL_NO_SM2
|
||||
ASN1_OCTET_STRING *sm2_id;
|
||||
# endif
|
||||
|
||||
/* Set on live certificates for authentication purposes */
|
||||
ASN1_OCTET_STRING *distinguishing_id;
|
||||
};
|
||||
|
||||
struct X509_crl_info_st {
|
||||
@@ -186,9 +186,9 @@ struct x509_st {
|
||||
X509_CERT_AUX *aux;
|
||||
CRYPTO_RWLOCK *lock;
|
||||
volatile int ex_cached;
|
||||
# ifndef OPENSSL_NO_SM2
|
||||
ASN1_OCTET_STRING *sm2_id;
|
||||
# endif
|
||||
|
||||
/* Set on live certificates for authentication purposes */
|
||||
ASN1_OCTET_STRING *distinguishing_id;
|
||||
} /* X509 */ ;
|
||||
|
||||
/*
|
||||
@@ -227,8 +227,11 @@ struct x509_store_ctx_st { /* X509_STORE_CTX */
|
||||
int (*cert_crl) (X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x);
|
||||
/* Check policy status of the chain */
|
||||
int (*check_policy) (X509_STORE_CTX *ctx);
|
||||
STACK_OF(X509) *(*lookup_certs) (X509_STORE_CTX *ctx, X509_NAME *nm);
|
||||
STACK_OF(X509_CRL) *(*lookup_crls) (X509_STORE_CTX *ctx, X509_NAME *nm);
|
||||
STACK_OF(X509) *(*lookup_certs) (X509_STORE_CTX *ctx,
|
||||
const X509_NAME *nm);
|
||||
/* cannot constify 'ctx' param due to lookup_certs_sk() in x509_vfy.c */
|
||||
STACK_OF(X509_CRL) *(*lookup_crls) (const X509_STORE_CTX *ctx,
|
||||
const X509_NAME *nm);
|
||||
int (*cleanup) (X509_STORE_CTX *ctx);
|
||||
/* The following is built up */
|
||||
/* if 0, rebuild chain */
|
||||
@@ -259,6 +262,9 @@ struct x509_store_ctx_st { /* X509_STORE_CTX */
|
||||
SSL_DANE *dane;
|
||||
/* signed via bare TA public key, rather than CA certificate */
|
||||
int bare_ta_signed;
|
||||
|
||||
OPENSSL_CTX *libctx;
|
||||
char *propq;
|
||||
};
|
||||
|
||||
/* PKCS#8 private key info structure */
|
||||
|
||||
Reference in New Issue
Block a user