From 2e2beb279d57ad35d51a15e1335eaea59c801f3f Mon Sep 17 00:00:00 2001 From: Juliusz Sosinowicz Date: Wed, 5 Aug 2020 14:32:55 +0200 Subject: [PATCH] WIP --- src/ssl.c | 49 ++++++++++++++++++++++++++++++++++++++++- wolfssl/openssl/ec.h | 3 +++ wolfssl/openssl/ssl.h | 4 ++++ wolfssl/ssl.h | 7 ++++++ wolfssl/wolfcrypt/asn.h | 1 + 5 files changed, 63 insertions(+), 1 deletion(-) diff --git a/src/ssl.c b/src/ssl.c index 793c1ee88..75a33fba6 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -22989,7 +22989,40 @@ int wolfSSL_X509_cmp(const WOLFSSL_X509 *a, const WOLFSSL_X509 *b) #endif /* XSNPRINTF */ #endif /* !NO_BIO */ -#endif /* OPENSSL_EXTRA */ + int wolfSSL_X509_signature_print(WOLFSSL_BIO *bp, + const WOLFSSL_X509_ALGOR *sigalg, const WOLFSSL_ASN1_STRING *sig) + { + WOLFSSL_ENTER("wolfSSL_X509_signature_print"); + + if (!bp || !sigalg || !sig) { + WOLFSSL_MSG("Bad parameter"); + return WOLFSSL_FAILURE; + } + + if (wolfSSL_BIO_puts(bp, " Signature Algorithm: ") <= 0) { + WOLFSSL_MSG("wolfSSL_BIO_puts error"); + return WOLFSSL_FAILURE; + } + + if (wolfSSL_i2a_ASN1_OBJECT(bp, sigalg->algorithm) <= 0) { + WOLFSSL_MSG("wolfSSL_i2a_ASN1_OBJECT error"); + return WOLFSSL_FAILURE; + } + + return WOLFSSL_SUCCESS; + } + +#ifndef NO_WOLFSSL_STUB + void wolfSSL_X509_get0_signature(const WOLFSSL_ASN1_BIT_STRING **psig, + const WOLFSSL_X509_ALGOR **palg, const WOLFSSL_X509 *x509) + { + (void)psig; + (void)palg; + (void)x509; + WOLFSSL_STUB("wolfSSL_X509_get0_signature"); + } +#endif + #endif /* !NO_CERTS */ #ifdef OPENSSL_EXTRA @@ -51159,6 +51192,20 @@ int wolfSSL_X509_REQ_add1_attr_by_NID(WOLFSSL_X509 *req, return WOLFSSL_FAILURE; } +int wolfSSL_X509_REQ_add1_attr_by_txt(WOLFSSL_X509 *req, + const char *attrname, int type, + const unsigned char *bytes, int len) +{ + WOLFSSL_ENTER("wolfSSL_X509_REQ_add1_attr_by_txt"); + WOLFSSL_STUB("wolfSSL_X509_REQ_add1_attr_by_txt"); + (void)req; + (void)attrname; + (void)type; + (void)bytes; + (void)len; + return WOLFSSL_FAILURE; +} + int wolfSSL_X509_REQ_get_attr_by_NID(const WOLFSSL_X509 *req, int nid, int lastpos) { diff --git a/wolfssl/openssl/ec.h b/wolfssl/openssl/ec.h index 477e06ea3..83a413639 100644 --- a/wolfssl/openssl/ec.h +++ b/wolfssl/openssl/ec.h @@ -301,6 +301,9 @@ char* wolfSSL_EC_POINT_point2hex(const WOLFSSL_EC_GROUP* group, #define EC_GROUP_get_order wolfSSL_EC_GROUP_get_order #define EC_GROUP_order_bits wolfSSL_EC_GROUP_order_bits #define EC_GROUP_method_of wolfSSL_EC_GROUP_method_of +#ifndef NO_WOLFSSL_STUB +#define EC_GROUP_set_point_conversion_form(...) +#endif #define EC_METHOD_get_field_type wolfSSL_EC_METHOD_get_field_type diff --git a/wolfssl/openssl/ssl.h b/wolfssl/openssl/ssl.h index 2736f39d3..6d3c10c6c 100644 --- a/wolfssl/openssl/ssl.h +++ b/wolfssl/openssl/ssl.h @@ -387,6 +387,7 @@ typedef STACK_OF(ACCESS_DESCRIPTION) AUTHORITY_INFO_ACCESS; #define X509_REQ_sign_ctx wolfSSL_X509_REQ_sign_ctx #define X509_REQ_add_extensions wolfSSL_X509_REQ_add_extensions #define X509_REQ_add1_attr_by_NID wolfSSL_X509_REQ_add1_attr_by_NID +#define X509_REQ_add1_attr_by_txt wolfSSL_X509_REQ_add1_attr_by_txt #define X509_REQ_get_attr_by_NID wolfSSL_X509_REQ_get_attr_by_NID #define X509_REQ_get_attr wolfSSL_X509_REQ_get_attr #define X509_to_X509_REQ wolfSSL_X509_to_X509_REQ @@ -443,6 +444,8 @@ typedef STACK_OF(ACCESS_DESCRIPTION) AUTHORITY_INFO_ACCESS; #define X509_print_ex wolfSSL_X509_print_ex #define X509_print_fp wolfSSL_X509_print_fp #define X509_REQ_print_fp wolfSSL_X509_print_fp +#define X509_signature_print wolfSSL_X509_signature_print +#define X509_get0_signature wolfSSL_X509_get0_signature #define X509_verify_cert_error_string wolfSSL_X509_verify_cert_error_string #define X509_verify_cert wolfSSL_X509_verify_cert #define X509_verify wolfSSL_X509_verify @@ -603,6 +606,7 @@ wolfSSL_X509_STORE_set_verify_cb((WOLFSSL_X509_STORE *)(s), (WOLFSSL_X509_STORE_ #define X509_CRL_get_REVOKED wolfSSL_X509_CRL_get_REVOKED #define X509_get_X509_PUBKEY wolfSSL_X509_get_X509_PUBKEY +#define X509_REQ_get_X509_PUBKEY wolfSSL_X509_get_X509_PUBKEY #define X509_get0_tbs_sigalg wolfSSL_X509_get0_tbs_sigalg #define X509_PUBKEY_get0_param wolfSSL_X509_PUBKEY_get0_param #define X509_PUBKEY_get wolfSSL_X509_PUBKEY_get diff --git a/wolfssl/ssl.h b/wolfssl/ssl.h index 2d65d76d6..55e49c6b1 100644 --- a/wolfssl/ssl.h +++ b/wolfssl/ssl.h @@ -1355,6 +1355,10 @@ WOLFSSL_API int wolfSSL_RSA_print(WOLFSSL_BIO* bio, WOLFSSL_RSA* rsa, int offset WOLFSSL_API int wolfSSL_X509_print_ex(WOLFSSL_BIO* bio, WOLFSSL_X509* x509, unsigned long nmflags, unsigned long cflag); WOLFSSL_API int wolfSSL_X509_print_fp(XFILE fp, WOLFSSL_X509 *x509); +WOLFSSL_API int wolfSSL_X509_signature_print(WOLFSSL_BIO *bp, + const WOLFSSL_X509_ALGOR *sigalg, const WOLFSSL_ASN1_STRING *sig); +WOLFSSL_API void wolfSSL_X509_get0_signature(const WOLFSSL_ASN1_BIT_STRING **psig, + const WOLFSSL_X509_ALGOR **palg, const WOLFSSL_X509 *x509); WOLFSSL_API int wolfSSL_X509_print(WOLFSSL_BIO* bio, WOLFSSL_X509* x509); WOLFSSL_ABI WOLFSSL_API char* wolfSSL_X509_NAME_oneline(WOLFSSL_X509_NAME*, char*, int); @@ -3594,6 +3598,9 @@ WOLFSSL_API int wolfSSL_X509_REQ_add1_attr_by_NID(WOLFSSL_X509 *req, int len); WOLFSSL_API int wolfSSL_X509_REQ_get_attr_by_NID(const WOLFSSL_X509 *req, int nid, int lastpos); +WOLFSSL_API int wolfSSL_X509_REQ_add1_attr_by_txt(WOLFSSL_X509 *req, + const char *attrname, int type, + const unsigned char *bytes, int len); WOLFSSL_API WOLFSSL_X509_ATTRIBUTE *wolfSSL_X509_REQ_get_attr( const WOLFSSL_X509 *req, int loc); diff --git a/wolfssl/wolfcrypt/asn.h b/wolfssl/wolfcrypt/asn.h index dc8112552..a1628c04a 100644 --- a/wolfssl/wolfcrypt/asn.h +++ b/wolfssl/wolfcrypt/asn.h @@ -229,6 +229,7 @@ enum NID_inhibit_any_policy = 168, /* 2.5.29.54 */ NID_tlsfeature = 1020, /* id-pe 24 */ NID_commonName = 0x03, /* matches ASN_COMMON_NAME in asn.h */ + NID_buildingName = 1494, NID_surname = 0x04, /* SN */