mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-06-13 08:23:50 +08:00
jni api
This commit is contained in:
@@ -1004,7 +1004,7 @@ int EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off);
|
||||
EVP_PKEY_OP_PARAMGEN|EVP_PKEY_OP_KEYGEN, \
|
||||
EVP_PKEY_CTRL_EC_PARAM_ENC, flag, NULL)
|
||||
|
||||
# ifndef OPENSSL_NO_GMSSL
|
||||
# ifndef NO_GMSSL
|
||||
# define EVP_PKEY_CTX_set_ec_sign_type(ctx, type) \
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
|
||||
EVP_PKEY_OP_SIGN|EVP_PKEY_OP_SIGNCTX| \
|
||||
@@ -1036,7 +1036,7 @@ int EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off);
|
||||
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
|
||||
EVP_PKEY_OP_DERIVE, \
|
||||
EVP_PKEY_CTRL_EC_DH_TYPE, -2, NULL);
|
||||
# endif /* OPENSSL_NO_GMSSL */
|
||||
# endif /* NO_GMSSL */
|
||||
|
||||
|
||||
|
||||
@@ -1101,7 +1101,7 @@ int EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off);
|
||||
# define EVP_PKEY_CTRL_EC_KDF_UKM (EVP_PKEY_ALG_CTRL + 9)
|
||||
# define EVP_PKEY_CTRL_GET_EC_KDF_UKM (EVP_PKEY_ALG_CTRL + 10)
|
||||
|
||||
# ifndef OPENSSL_NO_GMSSL
|
||||
# ifndef NO_GMSSL
|
||||
# define EVP_PKEY_CTRL_EC_SIGN_TYPE (EVP_PKEY_ALG_CTRL + 11)
|
||||
# define EVP_PKEY_CTRL_GET_EC_SIGN_TYPE (EVP_PKEY_ALG_CTRL + 12)
|
||||
# define EVP_PKEY_CTRL_EC_ENC_TYPE (EVP_PKEY_ALG_CTRL + 13)
|
||||
|
||||
@@ -613,7 +613,7 @@ const EVP_PKEY_ASN1_METHOD eckey_asn1_meth = {
|
||||
EVP_PKEY_EC,
|
||||
0,
|
||||
"EC",
|
||||
#ifndef OPENSSL_NO_GMSSL
|
||||
#ifndef NO_GMSSL
|
||||
"GmSSL EC/SM2 algorithm",
|
||||
#else
|
||||
"OpenSSL EC algorithm",
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/asn1t.h>
|
||||
#include <openssl/objects.h>
|
||||
#ifndef OPENSSL_NO_GMSSL
|
||||
#ifndef NO_GMSSL
|
||||
#include <openssl/evp.h>
|
||||
#endif
|
||||
|
||||
|
||||
@@ -2835,7 +2835,7 @@ static const struct {
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef OPENSSL_NO_GMSSL
|
||||
#ifndef NO_GMSSL
|
||||
static const struct {
|
||||
EC_CURVE_DATA h;
|
||||
unsigned char data[0 + 32 * 6];
|
||||
@@ -3112,7 +3112,7 @@ static const ec_list_element curve_list[] = {
|
||||
"RFC 5639 curve over a 512 bit prime field"},
|
||||
{NID_brainpoolP512t1, &_EC_brainpoolP512t1.h, 0,
|
||||
"RFC 5639 curve over a 512 bit prime field"},
|
||||
#ifndef OPENSSL_NO_GMSSL
|
||||
#ifndef NO_GMSSL
|
||||
{NID_sm2p256v1, &_EC_SM2_PRIME_256V1.h, 0,
|
||||
"SM2 curve over a 256 bit prime field"},
|
||||
{NID_wapip192v1, &_EC_WAPI_PRIME_192V1.h, 0,
|
||||
|
||||
@@ -88,15 +88,21 @@ typedef struct {
|
||||
size_t kdf_ukmlen;
|
||||
/* KDF output length */
|
||||
size_t kdf_outlen;
|
||||
#ifndef NO_GMSSL
|
||||
/* SECG, SM2 or other standards */
|
||||
int sign_type;
|
||||
int enc_type;
|
||||
int dh_type;
|
||||
union {
|
||||
void *ptr;
|
||||
ECIES_PARAMS *ecies;
|
||||
SM2_ENC_PARAMS *sm2;
|
||||
} enc_param;
|
||||
|
||||
unsigned char sm2_id_dgst[EVP_MAX_MD_SIZE];
|
||||
size_t sm2_id_dgstlen;
|
||||
|
||||
union {
|
||||
void *ptr;
|
||||
ECIES_PARAMS *ecies;
|
||||
SM2_ENC_PARAMS *sm2;
|
||||
} enc_param;
|
||||
#endif
|
||||
} EC_PKEY_CTX;
|
||||
|
||||
static int pkey_ec_init(EVP_PKEY_CTX *ctx)
|
||||
@@ -115,11 +121,13 @@ static int pkey_ec_init(EVP_PKEY_CTX *ctx)
|
||||
dctx->kdf_outlen = 0;
|
||||
dctx->kdf_ukm = NULL;
|
||||
dctx->kdf_ukmlen = 0;
|
||||
#ifndef NO_GMSSL
|
||||
dctx->sign_type = NID_sm_scheme;
|
||||
dctx->enc_type = NID_sm_scheme;
|
||||
dctx->dh_type = NID_sm_scheme;
|
||||
dctx->enc_param.ptr = NULL;
|
||||
|
||||
dctx->enc_type = NID_sm_scheme;
|
||||
dctx->dh_type = NID_sm_scheme;
|
||||
dctx->sm2_id_dgstlen = 0;
|
||||
dctx->enc_param.ptr = NULL;
|
||||
#endif
|
||||
ctx->data = dctx;
|
||||
|
||||
return 1;
|
||||
@@ -157,6 +165,7 @@ static int pkey_ec_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src)
|
||||
dctx->sign_type = sctx->sign_type;
|
||||
dctx->enc_type = sctx->enc_type;
|
||||
dctx->dh_type = sctx->dh_type;
|
||||
// fixme
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -256,8 +265,7 @@ static int pkey_ec_signctx_init(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx)
|
||||
unsigned char zid[EVP_MAX_MD_SIZE];
|
||||
unsigned int zidlen = sizeof(zid);
|
||||
|
||||
|
||||
|
||||
//FIXME: it is wrong to do it here!
|
||||
if (dctx->sign_type == NID_sm_scheme) {
|
||||
if (!SM2_compute_id_digest(md, zid, &zidlen, ec_key)) {
|
||||
ECerr(EC_F_PKEY_EC_SIGNCTX_INIT, ERR_R_SM2_LIB);
|
||||
@@ -272,7 +280,6 @@ static int pkey_ec_signctx_init(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -595,13 +602,16 @@ static int pkey_ec_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
|
||||
dctx->kdf_type = p1;
|
||||
return 1;
|
||||
|
||||
#ifndef OPENSSL_NO_GMSSL
|
||||
#ifndef NO_GMSSL
|
||||
case EVP_PKEY_CTRL_EC_SIGN_TYPE:
|
||||
if (p1 == -2)
|
||||
return dctx->sign_type;
|
||||
if (p1 != NID_secg_scheme && p1 != NID_sm_scheme)
|
||||
return -2;
|
||||
dctx->sign_type = p1;
|
||||
|
||||
//SM2_compute_id_digest();
|
||||
//set this data to pkey_ctx
|
||||
return 1;
|
||||
|
||||
case EVP_PKEY_CTRL_GET_EC_SIGN_TYPE:
|
||||
@@ -670,7 +680,7 @@ static int pkey_ec_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
|
||||
EVP_MD_type((const EVP_MD *)p2) != NID_ecdsa_with_SHA1 &&
|
||||
EVP_MD_type((const EVP_MD *)p2) != NID_sha224 &&
|
||||
EVP_MD_type((const EVP_MD *)p2) != NID_sha256 &&
|
||||
#ifndef OPENSSL_NO_GMSSL
|
||||
#ifndef NO_GMSSL
|
||||
EVP_MD_type((const EVP_MD *)p2) != NID_sm3 &&
|
||||
#endif
|
||||
EVP_MD_type((const EVP_MD *)p2) != NID_sha384 &&
|
||||
@@ -722,7 +732,7 @@ static int pkey_ec_ctrl_str(EVP_PKEY_CTX *ctx,
|
||||
else
|
||||
return -2;
|
||||
return EVP_PKEY_CTX_set_ec_param_enc(ctx, param_enc);
|
||||
#ifndef OPENSSL_NO_GMSSL
|
||||
#ifndef NO_GMSSL
|
||||
} else if (!strcmp(type, "ec_sign_algor")) {
|
||||
int sign_type;
|
||||
if (!strcmp(value, "ecdsa"))
|
||||
|
||||
Reference in New Issue
Block a user