From 3f0a17b331290b9c87bfcc1a9b6aaee1f7b0441e Mon Sep 17 00:00:00 2001 From: Hideki Miyazaki Date: Thu, 19 Sep 2024 09:31:55 +0900 Subject: [PATCH] Update TSIP driver version to v1.21 Use ASN_TEMPLATE Extracting YEAR and MONTH from __DATE__ --- .../RX65N/GR-ROSE/common/user_settings.h | 2 - .../RX65N/GR-ROSE/common/wolfssl_dummy.c | 25 ++- .../RX65N/RSK/wolfssl_demo/key_data.c | 200 ++++++++++-------- .../RX65N/RSK/wolfssl_demo/user_settings.h | 16 +- .../RX65N/RSK/wolfssl_demo/wolfssl_demo.c | 29 ++- wolfcrypt/src/asn.c | 98 +++++---- 6 files changed, 219 insertions(+), 151 deletions(-) diff --git a/IDE/Renesas/e2studio/RX65N/GR-ROSE/common/user_settings.h b/IDE/Renesas/e2studio/RX65N/GR-ROSE/common/user_settings.h index 875afd165f..ecf532359e 100644 --- a/IDE/Renesas/e2studio/RX65N/GR-ROSE/common/user_settings.h +++ b/IDE/Renesas/e2studio/RX65N/GR-ROSE/common/user_settings.h @@ -271,5 +271,3 @@ #define XSTRCASECMP(s1,s2) strcmp((s1),(s2)) -/* use original ASN parsing */ -#define WOLFSSL_ASN_ORIGINAL diff --git a/IDE/Renesas/e2studio/RX65N/GR-ROSE/common/wolfssl_dummy.c b/IDE/Renesas/e2studio/RX65N/GR-ROSE/common/wolfssl_dummy.c index ae1a2ab6eb..b26cd7d6bc 100644 --- a/IDE/Renesas/e2studio/RX65N/GR-ROSE/common/wolfssl_dummy.c +++ b/IDE/Renesas/e2studio/RX65N/GR-ROSE/common/wolfssl_dummy.c @@ -18,18 +18,33 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA */ - #include -#define YEAR 2024 -#define MON 9 - static int tick = 0; +#define YEAR ( \ + ((__DATE__)[7] - '0') * 1000 + \ + ((__DATE__)[8] - '0') * 100 + \ + ((__DATE__)[9] - '0') * 10 + \ + ((__DATE__)[10] - '0') * 1 \ +) + +#define MONTH ( \ + __DATE__[2] == 'n' ? (__DATE__[1] == 'a' ? 1 : 6) \ + : __DATE__[2] == 'b' ? 2 \ + : __DATE__[2] == 'r' ? (__DATE__[0] == 'M' ? 3 : 4) \ + : __DATE__[2] == 'y' ? 5 \ + : __DATE__[2] == 'l' ? 7 \ + : __DATE__[2] == 'g' ? 8 \ + : __DATE__[2] == 'p' ? 9 \ + : __DATE__[2] == 't' ? 10 \ + : __DATE__[2] == 'v' ? 11 \ + : 12 \ + ) time_t time(time_t *t) { (void)t; - return ((YEAR-1970)*365+30*MON)*24*60*60 + tick++; + return ((YEAR-1970)*365+30*MONTH)*24*60*60 + tick++; } #include diff --git a/IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/key_data.c b/IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/key_data.c index 4d176ccaa7..9ddda19e44 100644 --- a/IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/key_data.c +++ b/IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/key_data.c @@ -37,7 +37,7 @@ const st_key_block_data_t g_key_block_data = }, /* uint8_t iv[R_TSIP_AES_CBC_IV_BYTE_SIZE]; */ { - 0xF6, 0xA9, 0x83, 0x5A, 0xA1, 0x65, 0x1D, 0x28, 0xC8, 0x1A, 0xA6, 0x9D, + 0xF6, 0xA9, 0x83, 0x5A, 0xA1, 0x65, 0x1D, 0x28, 0xC8, 0x1A, 0xA6, 0x9D, 0x34, 0xB2, 0x4D, 0x92 }, /* @@ -45,30 +45,30 @@ const st_key_block_data_t g_key_block_data = * encrypted_user_rsa2048_ne_key[R_TSIP_RSA2048_NE_KEY_BYTE_SIZE + 16]; */ { - 0xD9, 0x9A, 0x75, 0x0E, 0x9D, 0x4F, 0x63, 0xA4, 0x02, 0x96, 0xE1, 0xF1, - 0x49, 0x44, 0xB5, 0x90, 0x59, 0x24, 0xC4, 0x23, 0xF7, 0xA0, 0x32, 0x65, - 0x68, 0x7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B0, 0x66, 0xFF, 0xCD, 0x76, 0xC1, 0x28, 0x65, 0xC2, 0xA3, 0xE3, 0x45 }, /* uint8_t encrypted_user_update_key[R_TSIP_AES256_KEY_BYTE_SIZE + 16]; */ { @@ -78,7 +78,7 @@ const st_key_block_data_t g_key_block_data = * encrypted_user_rsa2048_public_key[R_TSIP_RSA2048_NE_KEY_BYTE_SIZE + 16] */ { - 0x22, 0xEC, 0xE3, 0x79, 0xD1, 0x0C, 0xB4, 0xED, 0xE0, 0xA9, 0x0F, 0xBD, + 0x22, 0xEC, 0xE3, 0x79, 0xD1, 0x0C, 0xB4, 0xED, 0xE0, 0xA9, 0x0F, 0xBD, 0xC7, 0x0B, 0xB4, 0x1E, 0x82, 0x27, 0x79, 0x20, 0x6A, 0x15, 0x56, 0xD6, 0x0F, 0xFA, 0xE4, 0x61, 0x04, 0xDA, 0x81, 0x33, 0x42, 0xBA, 0x6D, 0xB9, 0x34, 0x81, 0xFD, 0x67, 0xDF, 0x1D, 0xCB, 0x52, 0x64, 0x9A, 0x2E, 0x30, @@ -107,7 +107,7 @@ const st_key_block_data_t g_key_block_data = * encrypted_user_rsa2048_private_key[R_TSIP_RSA2048_ND_KEY_BYTE_SIZE + 16] */ { - 0x22, 0xEC, 0xE3, 0x79, 0xD1, 0x0C, 0xB4, 0xED, 0xE0, 0xA9, 0x0F, 0xBD, + 0x22, 0xEC, 0xE3, 0x79, 0xD1, 0x0C, 0xB4, 0xED, 0xE0, 0xA9, 0x0F, 0xBD, 0xC7, 0x0B, 0xB4, 0x1E, 0x82, 0x27, 0x79, 0x20, 0x6A, 0x15, 0x56, 0xD6, 0x0F, 0xFA, 0xE4, 0x61, 0x04, 0xDA, 0x81, 0x33, 0x42, 0xBA, 0x6D, 0xB9, 0x34, 0x81, 0xFD, 0x67, 0xDF, 0x1D, 0xCB, 0x52, 0x64, 0x9A, 0x2E, 0x30, @@ -187,84 +187,96 @@ const uint32_t encrypted_user_key_type = const unsigned char ca_ecc_cert_der_sig[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 0xFA, 0x00, 0xE4, 0x8D, 0x0C, 0xC7, 0xBC, + 0x16, 0x50, 0x84, 0xCE, 0x74, 0xAC, 0x67, 0x5E, 0xE0, 0x19, + 0xF3, 0xFC, 0xD2, 0x1D, 0x46, 0x00, 0x63, 0x5E, 0xF8, 0xAC, + 0x70, 0x82, 0x7C, 0x78, 0xD2, 0xD6, 0x42, 0xB0, 0xBC, 0x6E, + 0x41, 0xCC, 0x3E, 0x08, 0x39, 0x29, 0xF4, 0xA6, 0xF5, 0x3D, + 0x81, 0x0A, 0xF8, 0x12, 0xD8, 0xD1, 0x15, 0xA2, 0x4A, 0x4F, + 0x13, 0x07, 0x9A, 0x56, 0x92, 0x51, 0xA2, 0xD6, 0x6B, 0xD9, + 0xF9, 0x86, 0x8B, 0xBE, 0x05, 0xDE, 0x76, 0x66, 0x89, 0x73, + 0x02, 0x19, 0x5C, 0xAC, 0xDE, 0x1E, 0x52, 0x80, 0x65, 0x42, + 0x5D, 0xBB, 0xB4, 0xED, 0xCF, 0x1B, 0x5E, 0xED, 0xA1, 0xC2, + 0x24, 0xAB, 0xBD, 0x30, 0xB2, 0xAE, 0x65, 0x8D, 0xE1, 0xDC, + 0xA3, 0xC7, 0x43, 0xC0, 0xE4, 0xB9, 0x66, 0x91, 0x64, 0xFD, + 0x12, 0x42, 0x12, 0x18, 0x4D, 0x7D, 0xF4, 0x14, 0xE5, 0x9E, + 0x81, 0x38, 0xFB, 0x32, 0x3B, 0x54, 0xFA, 0x4A, 0x6F, 0x25, + 0xA7, 0x3F, 0x45, 0x5D, 0x99, 0xC5, 0x4A, 0xE1, 0xEF, 0x12, + 0x5E, 0x03, 0x30, 0xBC, 0x5C, 0x31 }; const int sizeof_ca_ecc_cert_sig = sizeof(ca_ecc_cert_der_sig); /* ./ca-cert.der.sign, */ const unsigned char ca_cert_der_sig[] = { - 0x97, 0x8f, 0x90, 0x03, 0x0b, 0xca, 0xdf, 0x8f, 0xe8, 0x51, 0x23, 0xba, - 0x14, 0xfb, 0x28, 0xb8, 0x5c, 0x58, 0x0d, 0x6e, 0x8b, 0x97, 0x0f, 0x89, - 0x63, 0xc2, 0xd6, 0xb3, 0xf0, 0x16, 0x35, 0x74, 0x9d, 0xb9, 0xd7, 0x18, - 0x14, 0x86, 0x91, 0xe0, 0xcd, 0xb3, 0x28, 0x63, 0x16, 0xf4, 0x6c, 0xb1, - 0xd3, 0x93, 0xb6, 0x6e, 0xd9, 0x66, 0xcd, 0x65, 0x39, 0x7b, 0x1b, 0x74, - 0x5c, 0xde, 0x20, 0xd4, 0x46, 0x60, 0x2f, 0xc0, 0x10, 0xf5, 0x49, 0x4a, - 0x8d, 0x31, 0x29, 0x9b, 0x8a, 0xea, 0xf4, 0x8a, 0xaf, 0xc4, 0x84, 0xd7, - 0x42, 0xef, 0xaf, 0x14, 0x17, 0x44, 0xed, 0x6e, 0x2b, 0xd9, 0x70, 0xed, - 0x3e, 0x40, 0xf0, 0xef, 0x75, 0x4c, 0x05, 0x1f, 0xc3, 0x37, 0xec, 0xc2, - 0xcd, 0xcc, 0xce, 0x39, 0x61, 0xa0, 0xea, 0x16, 0x84, 0x6d, 0xde, 0xe7, - 0xf4, 0x0d, 0x8c, 0xf7, 0x69, 0x81, 0x64, 0x09, 0x16, 0xa7, 0x5b, 0x34, - 0x83, 0xe5, 0x73, 0xcf, 0x02, 0xf4, 0x37, 0x96, 0x93, 0x27, 0x72, 0x47, - 0x71, 0xca, 0x56, 0xcd, 0xd2, 0x85, 0x48, 0xe5, 0x9e, 0x1f, 0x39, 0x52, - 0xc1, 0xc3, 0x9c, 0x6b, 0x98, 0x41, 0xc2, 0x0a, 0x77, 0x94, 0xe5, 0x84, - 0x44, 0xe7, 0x94, 0xee, 0x5f, 0x05, 0x62, 0xad, 0xe5, 0xe5, 0xc9, 0x7e, - 0x02, 0x31, 0x85, 0xca, 0x28, 0x2d, 0x0d, 0x7f, 0x30, 0x5d, 0xb5, 0xaa, - 0x12, 0x81, 0x25, 0x37, 0x4a, 0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B4, 0xB0, 0x18, 0xF1, 0x19, 0x1A, 0x19, 0xD9, 0xF0, 0x9D, + 0x72, 0xA6, 0x33, 0x9A, 0xA6, 0xC6, 0x74, 0xA9, 0x01, 0xE3, + 0xFF, 0x60, 0xFC, 0x6D, 0x0B, 0x4C, 0x5D, 0x52, 0x4D, 0xED, + 0x6C, 0xCC, 0xB9, 0x8D, 0x7B, 0x44, 0x3A, 0x1A, 0xD5, 0x8F, + 0x75, 0xAA, 0x6B, 0xEC, 0xBB, 0x94, 0x5D, 0xA3, 0x9D, 0x33, + 0x50, 0x1B, 0xBD, 0x04, 0x23, 0x05, 0x65, 0xA4, 0x5F, 0x21, + 0xDD, 0x27, 0x3A, 0xB7, 0xE6, 0x21, 0x54, 0xA1, 0x75, 0x3C, + 0x3D, 0x0E, 0x2F, 0xF5, 0x21, 0x7F, 0x02, 0x53, 0xB7, 0x14, + 0x41, 0xEE, 0x0D, 0xCE, 0xB7, 0x48, 0xE6, 0x9A, 0x2E, 0x77, + 0x9F, 0x94, 0x94, 0x00, 0x69, 0x28, 0xB4, 0xE9, 0xB1, 0x26, + 0x2B, 0x90, 0xB9, 0xCD, 0x21, 0x05, 0xB5, 0x01, 0x37, 0x45, + 0x32, 0x96, 0x80, 0xC3, 0x5A, 0xF1, 0x60, 0x9B, 0x97, 0x0D, + 0x58, 0x63, 0x84, 0xB0, 0xF9, 0xCA, 0xBB, 0x97, 0x53, 0xA4, + 0xC6, 0xE5, 0x6F, 0x59, 0x37, 0x81 }; const int sizeof_ca_cert_sig = sizeof(ca_cert_der_sig); /* ./client-cert.der.sign, */ const unsigned char client_cert_der_sign[] = { - 0x5D, 0x1F, 0x89, 0x41, 0xEC, 0x47, 0xC8, 0x90, 0x61, 0x79, 0x8A, 0x16, - 0x1F, 0x31, 0x96, 0x67, 0xD9, 0x3C, 0xEC, 0x6B, 0x58, 0xC6, 0x5A, 0xED, - 0x99, 0xB3, 0xEF, 0x27, 0x6F, 0x04, 0x8C, 0xD9, 0x68,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xC1, 0xE5, 0x4D, 0xD6, + 0xFF, 0xC8, 0xDF, 0x7A, 0x4F, 0x97, 0x5D, 0x46, 0x3A, 0x0A, + 0x38, 0xE8, 0x0C, 0x99, 0xE7, 0x97, 0xE7, 0x3F, 0xFE, 0xC8, + 0x6A, 0x93, 0x95, 0xD2, 0x32, 0xB1, 0x01, 0x00, 0x1C, 0x9A, + 0xCE, 0x5F, 0x2B, 0xA8, 0xB1, 0xC7, 0xDC, 0x1B, 0x04, 0x9F, + 0x58, 0x03, 0x57, 0x19, 0x9A, 0xDB, 0x58, 0x33, 0xBD, 0x9D, + 0x3E, 0xA0, 0x3D, 0x9A, 0x00, 0xA6, 0xE9, 0x2E, 0xCD, 0x45, + 0x97, 0xC1, 0xDF, 0xCF, 0xAF, 0x8A, 0x93, 0x52, 0xAA, 0x65, + 0x1C, 0xC2, 0x3C, 0xDD, 0xE1, 0xED, 0x4B, 0x8A, 0x05, 0x5A, + 0xBE, 0x84, 0xEE, 0xDF, 0xC0, 0x96, 0xD2, 0x5A, 0x60, 0x32, + 0xDF, 0xC9, 0x01, 0x7C, 0x83, 0x27, 0x2B, 0x4B, 0x18, 0x18, + 0x9F, 0x58, 0xE4, 0xF0, 0x0C, 0x36, 0xC1, 0xB4, 0x08, 0x70, + 0xFB, 0xDC, 0xCB, 0x70, 0x61, 0xAC }; const int sizeof_client_cert_der_sign = sizeof(client_cert_der_sign); - +uint32_t s_inst2[R_TSIP_SINST2_WORD_SIZE]= { 0 }; #endif diff --git a/IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/user_settings.h b/IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/user_settings.h index 840477a881..e35feacb90 100644 --- a/IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/user_settings.h +++ b/IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/user_settings.h @@ -38,9 +38,10 @@ * 114: TSIPv1.14 * 115: TSIPv1.15 * 117: TSIPv1.17 + * 121: TSIPv1.21 *----------------------------------------------------------------------------*/ #define WOLFSSL_RENESAS_TSIP - #define WOLFSSL_RENESAS_TSIP_VER 117 + #define WOLFSSL_RENESAS_TSIP_VER 121 /*-- TLS version definitions -------------------------------------------------- @@ -143,7 +144,7 @@ * *----------------------------------------------------------------------------*/ #define SIZEOF_LONG_LONG 8 - + #define WOLFSSL_SMALL_STACK /* * -- "NO_ASN_TIME" macro is to avoid certificate expiration validation -- @@ -233,7 +234,6 @@ #define WOLFSSL_RENESAS_TSIP_TLS #if !defined(NO_RENESAS_TSIP_CRYPT) - #define WOLFSSL_RENESAS_TSIP_CRYPTONLY #define HAVE_PK_CALLBACKS #define WOLF_CRYPTO_CB #if defined(WOLFSSL_RENESAS_TSIP_TLS) @@ -247,7 +247,14 @@ # undef WOLFSSL_RENESAS_TSIP_TLS # undef WOLFSSL_RENESAS_TSIP_CRYPT #endif - + /*------------------------------------------------------------------------- + * TSIP generates random numbers using the CRT-DRBG described + * in NIST SP800-90A. Recommend to define the CUSTOM_RAND_GENERATE_BLOCK + * so that wc_RNG_GenerateByte/Block() call TSIP random generatoion API + * directly. Comment out the macro will generate random number by + * wolfSSL Hash DRBG by using a seed which is generated by TSIP API. + *-----------------------------------------------------------------------*/ + #define CUSTOM_RAND_GENERATE_BLOCK wc_tsip_GenerateRandBlock #else #define OPENSSL_EXTRA #define WOLFSSL_GENSEED_FORTEST /* Warning: define your own seed gen */ @@ -263,3 +270,4 @@ /*-- strcasecmp */ #define XSTRCASECMP(s1,s2) strcmp((s1),(s2)) + diff --git a/IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/wolfssl_demo.c b/IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/wolfssl_demo.c index bbe486cbcf..1d9c1e1472 100644 --- a/IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/wolfssl_demo.c +++ b/IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/wolfssl_demo.c @@ -30,7 +30,6 @@ #include "platform/iot_network.h" #include "platform.h" - #include #include "wolfssl/ssl.h" #include @@ -59,22 +58,40 @@ static WOLFSSL_CTX* client_ctx; #endif /* TLS_CLIENT */ -#define TLSSERVER_IP "192.168.1.14" +#define TLSSERVER_IP "192.168.10.6" #define TLSSERVER_PORT 11111 -#define YEAR 2023 -#define MON 3 #define FREQ 10000 /* Hz */ static long tick; static int tmTick; +#define YEAR ( \ + ((__DATE__)[7] - '0') * 1000 + \ + ((__DATE__)[8] - '0') * 100 + \ + ((__DATE__)[9] - '0') * 10 + \ + ((__DATE__)[10] - '0') * 1 \ +) + +#define MONTH ( \ + __DATE__[2] == 'n' ? (__DATE__[1] == 'a' ? 1 : 6) \ + : __DATE__[2] == 'b' ? 2 \ + : __DATE__[2] == 'r' ? (__DATE__[0] == 'M' ? 3 : 4) \ + : __DATE__[2] == 'y' ? 5 \ + : __DATE__[2] == 'l' ? 7 \ + : __DATE__[2] == 'g' ? 8 \ + : __DATE__[2] == 'p' ? 9 \ + : __DATE__[2] == 't' ? 10 \ + : __DATE__[2] == 'v' ? 11 \ + : 12 \ + ) + /* time * returns seconds from EPOCH */ time_t time(time_t *t) { (void)t; - return ((YEAR-1970)*365+30*MON)*24*60*60 + tmTick++; + return ((YEAR-1970)*365+30*MONTH)*24*60*60 + tmTick++; } /* timeTick @@ -94,8 +111,6 @@ double current_time(int reset) return ((double)tick/FREQ) ; } - - /* --------------------------------------------------------*/ /* Benchmark_demo */ /* --------------------------------------------------------*/ diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index 3f76da8098..bea4c89d0e 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -9490,6 +9490,42 @@ int EncryptContent(byte* input, word32 inputSz, byte* out, word32* outSz, #endif /* NO_PWDBASED */ #ifndef NO_RSA +#ifdef WOLFSSL_ASN_TEMPLATE +/* ASN.1 template for an RSA public key. + * X.509: RFC 5280, 4.1 - SubjectPublicKeyInfo + * PKCS #1: RFC 8017, A.1.1 - RSAPublicKey + */ +static const ASNItem rsaPublicKeyASN[] = { +/* SEQ */ { 0, ASN_SEQUENCE, 1, 1, 0 }, +/* ALGOID_SEQ */ { 1, ASN_SEQUENCE, 1, 1, 0 }, +/* ALGOID_OID */ { 2, ASN_OBJECT_ID, 0, 0, 0 }, +/* ALGOID_NULL */ { 2, ASN_TAG_NULL, 0, 0, 1 }, +#ifdef WC_RSA_PSS +/* ALGOID_P_SEQ */ { 2, ASN_SEQUENCE, 1, 0, 1 }, +#endif +/* PUBKEY */ { 1, ASN_BIT_STRING, 0, 1, 0 }, + /* RSAPublicKey */ +/* PUBKEY_RSA_SEQ */ { 2, ASN_SEQUENCE, 1, 1, 0 }, +/* PUBKEY_RSA_N */ { 3, ASN_INTEGER, 0, 0, 0 }, +/* PUBKEY_RSA_E */ { 3, ASN_INTEGER, 0, 0, 0 }, +}; +enum { + RSAPUBLICKEYASN_IDX_SEQ = 0, + RSAPUBLICKEYASN_IDX_ALGOID_SEQ, + RSAPUBLICKEYASN_IDX_ALGOID_OID, + RSAPUBLICKEYASN_IDX_ALGOID_NULL, +#ifdef WC_RSA_PSS + RSAPUBLICKEYASN_IDX_ALGOID_P_SEQ, +#endif + RSAPUBLICKEYASN_IDX_PUBKEY, + RSAPUBLICKEYASN_IDX_PUBKEY_RSA_SEQ, + RSAPUBLICKEYASN_IDX_PUBKEY_RSA_N, + RSAPUBLICKEYASN_IDX_PUBKEY_RSA_E +}; + +/* Number of items in ASN.1 template for an RSA public key. */ +#define rsaPublicKeyASN_Length (sizeof(rsaPublicKeyASN) / sizeof(ASNItem)) +#endif #if defined(WOLFSSL_RENESAS_TSIP_TLS) || defined(WOLFSSL_RENESAS_FSPSM_TLS) /* This function is to retrieve key position information in a cert.* @@ -9500,9 +9536,10 @@ static int RsaPublicKeyDecodeRawIndex(const byte* input, word32* inOutIdx, word32* key_n_len, word32* key_e, word32* key_e_len) { - +#ifndef WOLFSSL_ASN_TEMPLATE int ret = 0; int length = 0; + #if defined(OPENSSL_EXTRA) || defined(RSA_DECODE_EXTRA) byte b; #endif @@ -9565,48 +9602,31 @@ static int RsaPublicKeyDecodeRawIndex(const byte* input, word32* inOutIdx, } if (key_e_len) *key_e_len = length; - return ret; -} -#endif /* WOLFSSL_RENESAS_TSIP */ - -#ifdef WOLFSSL_ASN_TEMPLATE -/* ASN.1 template for an RSA public key. - * X.509: RFC 5280, 4.1 - SubjectPublicKeyInfo - * PKCS #1: RFC 8017, A.1.1 - RSAPublicKey - */ -static const ASNItem rsaPublicKeyASN[] = { -/* SEQ */ { 0, ASN_SEQUENCE, 1, 1, 0 }, -/* ALGOID_SEQ */ { 1, ASN_SEQUENCE, 1, 1, 0 }, -/* ALGOID_OID */ { 2, ASN_OBJECT_ID, 0, 0, 0 }, -/* ALGOID_NULL */ { 2, ASN_TAG_NULL, 0, 0, 1 }, -#ifdef WC_RSA_PSS -/* ALGOID_P_SEQ */ { 2, ASN_SEQUENCE, 1, 0, 1 }, -#endif -/* PUBKEY */ { 1, ASN_BIT_STRING, 0, 1, 0 }, - /* RSAPublicKey */ -/* PUBKEY_RSA_SEQ */ { 2, ASN_SEQUENCE, 1, 1, 0 }, -/* PUBKEY_RSA_N */ { 3, ASN_INTEGER, 0, 0, 0 }, -/* PUBKEY_RSA_E */ { 3, ASN_INTEGER, 0, 0, 0 }, -}; -enum { - RSAPUBLICKEYASN_IDX_SEQ = 0, - RSAPUBLICKEYASN_IDX_ALGOID_SEQ, - RSAPUBLICKEYASN_IDX_ALGOID_OID, - RSAPUBLICKEYASN_IDX_ALGOID_NULL, -#ifdef WC_RSA_PSS - RSAPUBLICKEYASN_IDX_ALGOID_P_SEQ, -#endif - RSAPUBLICKEYASN_IDX_PUBKEY, - RSAPUBLICKEYASN_IDX_PUBKEY_RSA_SEQ, - RSAPUBLICKEYASN_IDX_PUBKEY_RSA_N, - RSAPUBLICKEYASN_IDX_PUBKEY_RSA_E -}; +#else + int ret = 0; + const byte* n = NULL; + const byte* e = NULL; /* pointer to modulus/exponent */ + word32 rawIndex = 0; -/* Number of items in ASN.1 template for an RSA public key. */ -#define rsaPublicKeyASN_Length (sizeof(rsaPublicKeyASN) / sizeof(ASNItem)) + ret = wc_RsaPublicKeyDecode_ex(input, inOutIdx, (word32)inSz, + &n, key_n_len, &e, key_e_len); + if (ret == 0) { + /* convert pointer to offset */ + if (key_n != NULL) { + rawIndex = n - input; + *key_n += rawIndex; + } + if (key_e != NULL) { + rawIndex = e - input; + *key_e += rawIndex; + } + } + return ret; #endif +} +#endif /* WOLFSSL_RENESAS_TSIP */ /* Decode RSA public key. * * X.509: RFC 5280, 4.1 - SubjectPublicKeyInfo