Add sm2 and otp command

try `gmssl sm2 -help` and `gmssl otp -help`
This commit is contained in:
Zhi Guan
2018-12-19 10:01:38 +08:00
parent 5bc22a1f3e
commit 74a729aa77
17 changed files with 376 additions and 5597 deletions

View File

@@ -55,6 +55,7 @@
#include <openssl/asn1t.h>
#include <openssl/objects.h>
#include <openssl/obj_mac.h>
#include "../ec/ec_lcl.h"
#include "sm2_lcl.h"
@@ -119,3 +120,15 @@ int SM2_ciphertext_size(const EC_KEY *ec_key, size_t inlen)
ret = ASN1_object_size(1, len, V_ASN1_SEQUENCE);
return ret;
}
#ifndef OPENSSL_NO_STDIO
SM2CiphertextValue *d2i_SM2CiphertextValue_fp(FILE *fp, SM2CiphertextValue **a)
{
return ASN1_item_d2i_fp(ASN1_ITEM_rptr(SM2CiphertextValue), fp, a);
}
int i2d_SM2CiphertextValue_fp(FILE *fp, SM2CiphertextValue *a)
{
return ASN1_item_i2d_fp(ASN1_ITEM_rptr(SM2CiphertextValue), fp, a);
}
#endif

View File

@@ -59,20 +59,25 @@
static const EC_KEY_METHOD gmssl_ec_key_method = {
"GmSSL EC_KEY method",
EC_KEY_METHOD_SM2,
0,0,0,0,0,0,
ossl_ec_key_gen,
NULL,
SM2_sign_ex,
SM2_sign_setup,
SM2_do_sign_ex,
SM2_verify,
SM2_do_verify,
SM2_encrypt,
NULL,
SM2_decrypt,
NULL,
"SM2 method", /* name */
EC_KEY_METHOD_SM2, /* flags */
NULL, /* init */
NULL, /* finish */
0, /* copy */
0, /* set_group */
0, /* set_private */
0, /* set_public */
ossl_ec_key_gen, /* keygen */
NULL, /* compute_key */
SM2_sign_ex, /* sign */
SM2_sign_setup, /* sign_setup */
SM2_do_sign_ex, /* sign_sig */
SM2_verify, /* verify */
SM2_do_verify, /* verify_sig */
SM2_encrypt, /* encrypt */
NULL, /* do_encrypt */
SM2_decrypt, /* decrypt */
NULL, /* do_decrypt */
};
const EC_KEY_METHOD *EC_KEY_GmSSL(void)