Latest update.

This commit is contained in:
2020-04-15 18:45:34 +09:00
parent be29e7bcc6
commit 2015c00c43
573 changed files with 22943 additions and 6714 deletions
@@ -14,6 +14,7 @@
#include <openssl/types.h>
#include <openssl/x509.h> /* i2d_X509_PUBKEY_bio() */
#include "crypto/bn.h" /* bn_get_words() */
#include "crypto/ecx.h"
#include "prov/bio.h" /* ossl_prov_bio_printf() */
#include "prov/implementations.h"
#include "prov/providercommonerr.h" /* PROV_R_READ_KEY */
@@ -26,6 +26,14 @@ void ecx_get_new_free_import(ECX_KEY_TYPE type,
*ecx_new = ossl_prov_get_keymgmt_new(x448_keymgmt_functions);
*ecx_free = ossl_prov_get_keymgmt_free(x448_keymgmt_functions);
*ecx_import = ossl_prov_get_keymgmt_import(x448_keymgmt_functions);
} else if (type == ECX_KEY_TYPE_ED25519) {
*ecx_new = ossl_prov_get_keymgmt_new(ed25519_keymgmt_functions);
*ecx_free = ossl_prov_get_keymgmt_free(ed25519_keymgmt_functions);
*ecx_import = ossl_prov_get_keymgmt_import(ed25519_keymgmt_functions);
} else if (type == ECX_KEY_TYPE_ED448) {
*ecx_new = ossl_prov_get_keymgmt_new(ed448_keymgmt_functions);
*ecx_free = ossl_prov_get_keymgmt_free(ed448_keymgmt_functions);
*ecx_import = ossl_prov_get_keymgmt_import(ed448_keymgmt_functions);
} else {
*ecx_new = NULL;
*ecx_free = NULL;
@@ -40,23 +48,35 @@ int ossl_prov_print_ecx(BIO *out, ECX_KEY *ecxkey, enum ecx_print_type type)
switch (type) {
case ecx_print_priv:
switch (ecxkey->keylen) {
case X25519_KEYLEN:
switch (ecxkey->type) {
case ECX_KEY_TYPE_X25519:
type_label = "X25519 Private-Key";
break;
case X448_KEYLEN:
case ECX_KEY_TYPE_X448:
type_label = "X448 Private-Key";
break;
case ECX_KEY_TYPE_ED25519:
type_label = "ED25519 Private-Key";
break;
case ECX_KEY_TYPE_ED448:
type_label = "ED448 Private-Key";
break;
}
break;
case ecx_print_pub:
switch (ecxkey->keylen) {
case X25519_KEYLEN:
switch (ecxkey->type) {
case ECX_KEY_TYPE_X25519:
type_label = "X25519 Public-Key";
break;
case X448_KEYLEN:
case ECX_KEY_TYPE_X448:
type_label = "X448 Public-Key";
break;
case ECX_KEY_TYPE_ED25519:
type_label = "ED25519 Public-Key";
break;
case ECX_KEY_TYPE_ED448:
type_label = "ED448 Public-Key";
break;
}
break;
}
@@ -13,12 +13,15 @@
#include <openssl/pem.h>
#include <openssl/types.h>
#include <openssl/params.h>
#include "crypto/ecx.h"
#include "prov/bio.h"
#include "prov/implementations.h"
#include "serializer_local.h"
static OSSL_OP_serializer_newctx_fn x25519_priv_newctx;
static OSSL_OP_serializer_newctx_fn x448_priv_newctx;
static OSSL_OP_serializer_newctx_fn ed25519_priv_newctx;
static OSSL_OP_serializer_newctx_fn ed448_priv_newctx;
static OSSL_OP_serializer_freectx_fn ecx_priv_freectx;
static OSSL_OP_serializer_set_ctx_params_fn ecx_priv_set_ctx_params;
static OSSL_OP_serializer_settable_ctx_params_fn ecx_priv_settable_ctx_params;
@@ -65,6 +68,16 @@ static void *x448_priv_newctx(void *provctx)
return ecx_priv_newctx(provctx, ECX_KEY_TYPE_X448);
}
static void *ed25519_priv_newctx(void *provctx)
{
return ecx_priv_newctx(provctx, ECX_KEY_TYPE_ED25519);
}
static void *ed448_priv_newctx(void *provctx)
{
return ecx_priv_newctx(provctx, ECX_KEY_TYPE_ED448);
}
static void ecx_priv_freectx(void *vctx)
{
struct ecx_priv_ctx_st *ctx = vctx;
@@ -150,14 +163,13 @@ static int ecx_priv_der(void *vctx, void *vecxkey, BIO *out,
struct ecx_priv_ctx_st *ctx = vctx;
ECX_KEY *ecxkey = vecxkey;
int ret;
int type = (ctx->type == ECX_KEY_TYPE_X25519) ? EVP_PKEY_X25519
: EVP_PKEY_X448;
int nid = KEYTYPE2NID(ctx->type);
ctx->sc.cb = cb;
ctx->sc.cbarg = cbarg;
ret = ossl_prov_write_priv_der_from_obj(out, ecxkey,
type,
nid,
NULL,
ossl_prov_ecx_priv_to_der,
&ctx->sc);
@@ -194,14 +206,13 @@ static int ecx_priv_pem(void *vctx, void *ecxkey, BIO *out,
{
struct ecx_priv_ctx_st *ctx = vctx;
int ret;
int type = (ctx->type == ECX_KEY_TYPE_X25519) ? EVP_PKEY_X25519
: EVP_PKEY_X448;
int nid = KEYTYPE2NID(ctx->type);
ctx->sc.cb = cb;
ctx->sc.cbarg = cbarg;
ret = ossl_prov_write_priv_pem_from_obj(out, ecxkey,
type,
nid,
NULL,
ossl_prov_ecx_priv_to_der,
&ctx->sc);
@@ -268,3 +279,5 @@ static int ecx_priv_print(void *ctx, void *ecxkey, BIO *out,
MAKE_SERIALIZER_FUNCTIONS_GROUP(x25519)
MAKE_SERIALIZER_FUNCTIONS_GROUP(x448)
MAKE_SERIALIZER_FUNCTIONS_GROUP(ed25519)
MAKE_SERIALIZER_FUNCTIONS_GROUP(ed448)
@@ -12,12 +12,15 @@
#include <openssl/pem.h>
#include <openssl/types.h>
#include <openssl/params.h>
#include "crypto/ecx.h"
#include "prov/bio.h"
#include "prov/implementations.h"
#include "serializer_local.h"
static OSSL_OP_serializer_newctx_fn x25519_pub_newctx;
static OSSL_OP_serializer_newctx_fn x448_pub_newctx;
static OSSL_OP_serializer_newctx_fn ed25519_pub_newctx;
static OSSL_OP_serializer_newctx_fn ed448_pub_newctx;
static OSSL_OP_serializer_freectx_fn ecx_pub_freectx;
static OSSL_OP_serializer_serialize_data_fn ecx_pub_der_data;
static OSSL_OP_serializer_serialize_object_fn ecx_pub_der;
@@ -57,6 +60,16 @@ static void *x448_pub_newctx(void *provctx)
return ecx_pub_newctx(provctx, ECX_KEY_TYPE_X448);
}
static void *ed25519_pub_newctx(void *provctx)
{
return ecx_pub_newctx(provctx, ECX_KEY_TYPE_ED25519);
}
static void *ed448_pub_newctx(void *provctx)
{
return ecx_pub_newctx(provctx, ECX_KEY_TYPE_ED448);
}
static void ecx_pub_freectx(void *ctx)
{
OPENSSL_free(ctx);
@@ -92,8 +105,7 @@ static int ecx_pub_der(void *vctx, void *ecxkey, BIO *out,
struct ecx_pub_ctx_st *ctx = vctx;
return ossl_prov_write_pub_der_from_obj(out, ecxkey,
ctx->type == ECX_KEY_TYPE_X25519
? EVP_PKEY_X25519 : EVP_PKEY_X448,
KEYTYPE2NID(ctx->type),
NULL,
ossl_prov_ecx_pub_to_der);
}
@@ -128,8 +140,7 @@ static int ecx_pub_pem(void *vctx, void *ecxkey, BIO *out,
struct ecx_pub_ctx_st *ctx = vctx;
return ossl_prov_write_pub_pem_from_obj(out, ecxkey,
ctx->type == ECX_KEY_TYPE_X25519
? EVP_PKEY_X25519 : EVP_PKEY_X448,
KEYTYPE2NID(ctx->type),
NULL,
ossl_prov_ecx_pub_to_der);
@@ -182,3 +193,5 @@ static int ecx_pub_print(void *ctx, void *ecxkey, BIO *out,
MAKE_SERIALIZER_FUNCTIONS_GROUP(x25519)
MAKE_SERIALIZER_FUNCTIONS_GROUP(x448)
MAKE_SERIALIZER_FUNCTIONS_GROUP(ed25519)
MAKE_SERIALIZER_FUNCTIONS_GROUP(ed448)
@@ -31,11 +31,6 @@ struct pkcs8_encrypt_ctx_st {
void *cbarg;
};
typedef enum {
ECX_KEY_TYPE_X25519,
ECX_KEY_TYPE_X448
} ECX_KEY_TYPE;
OSSL_OP_keymgmt_new_fn *ossl_prov_get_keymgmt_new(const OSSL_DISPATCH *fns);
OSSL_OP_keymgmt_free_fn *ossl_prov_get_keymgmt_free(const OSSL_DISPATCH *fns);
OSSL_OP_keymgmt_import_fn *ossl_prov_get_keymgmt_import(const OSSL_DISPATCH *fns);
@@ -64,12 +59,14 @@ int ossl_prov_prepare_dh_params(const void *dh, int nid,
int ossl_prov_dh_pub_to_der(const void *dh, unsigned char **pder);
int ossl_prov_dh_priv_to_der(const void *dh, unsigned char **pder);
#ifndef OPENSSL_NO_EC
void ecx_get_new_free_import(ECX_KEY_TYPE type,
OSSL_OP_keymgmt_new_fn **ecx_new,
OSSL_OP_keymgmt_free_fn **ecx_free,
OSSL_OP_keymgmt_import_fn **ecx_import);
int ossl_prov_ecx_pub_to_der(const void *ecxkey, unsigned char **pder);
int ossl_prov_ecx_priv_to_der(const void *ecxkey, unsigned char **pder);
#endif
int ossl_prov_prepare_dsa_params(const void *dsa, int nid,
void **pstr, int *pstrtype);
@@ -110,4 +110,3 @@ int ossl_prov_print_rsa(BIO *out, RSA *rsa, int priv)
sk_BIGNUM_const_free(coeffs);
return ret;
}