diff options
author | Paul Yang <yang.yang@baishancloud.com> | 2019-06-05 14:46:48 +0800 |
---|---|---|
committer | Paul Yang <yang.yang@baishancloud.com> | 2019-06-28 18:58:19 +0800 |
commit | bc42bd6298702a1abf70aa6383d36886dd5af4b3 (patch) | |
tree | f75b4cdda42ccc9ebeb01cf9d1d4bc5c0c05764e /crypto/x509/x_req.c | |
parent | 53a11c6da09988efba93eccfdd10bf7edf1d53b2 (diff) |
Support SM2 certificate signing
SM2 certificate signing request can be created and signed by OpenSSL
now, both in library and apps.
Documentation and test cases are added.
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/9085)
Diffstat (limited to 'crypto/x509/x_req.c')
-rw-r--r-- | crypto/x509/x_req.c | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/crypto/x509/x_req.c b/crypto/x509/x_req.c index 7fb844827e..5bda794a82 100644 --- a/crypto/x509/x_req.c +++ b/crypto/x509/x_req.c @@ -45,6 +45,29 @@ static int rinf_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, return 1; } +static int req_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, + void *exarg) +{ +#ifndef OPENSSL_NO_SM2 + X509_REQ *ret = (X509_REQ *)*pval; + + switch (operation) { + case ASN1_OP_D2I_PRE: + ASN1_OCTET_STRING_free(ret->sm2_id); + /* fall thru */ + case ASN1_OP_NEW_POST: + ret->sm2_id = NULL; + break; + + case ASN1_OP_FREE_POST: + ASN1_OCTET_STRING_free(ret->sm2_id); + break; + } +#endif + + return 1; +} + ASN1_SEQUENCE_enc(X509_REQ_INFO, enc, rinf_cb) = { ASN1_SIMPLE(X509_REQ_INFO, version, ASN1_INTEGER), ASN1_SIMPLE(X509_REQ_INFO, subject, X509_NAME), @@ -57,7 +80,7 @@ ASN1_SEQUENCE_enc(X509_REQ_INFO, enc, rinf_cb) = { IMPLEMENT_ASN1_FUNCTIONS(X509_REQ_INFO) -ASN1_SEQUENCE_ref(X509_REQ, 0) = { +ASN1_SEQUENCE_ref(X509_REQ, req_cb) = { ASN1_EMBED(X509_REQ, req_info, X509_REQ_INFO), ASN1_EMBED(X509_REQ, sig_alg, X509_ALGOR), ASN1_SIMPLE(X509_REQ, signature, ASN1_BIT_STRING) @@ -66,3 +89,16 @@ ASN1_SEQUENCE_ref(X509_REQ, 0) = { IMPLEMENT_ASN1_FUNCTIONS(X509_REQ) IMPLEMENT_ASN1_DUP_FUNCTION(X509_REQ) + +#ifndef OPENSSL_NO_SM2 +void X509_REQ_set0_sm2_id(X509_REQ *x, ASN1_OCTET_STRING *sm2_id) +{ + ASN1_OCTET_STRING_free(x->sm2_id); + x->sm2_id = sm2_id; +} + +ASN1_OCTET_STRING *X509_REQ_get0_sm2_id(X509_REQ *x) +{ + return x->sm2_id; +} +#endif |