From e111aa55d27d0d3d315d593c8ee9f1c98a95c009 Mon Sep 17 00:00:00 2001 From: Hideki Miyazaki Date: Thu, 15 Aug 2024 19:18:38 +0900 Subject: [PATCH] update rx64n gr-rose key and signed cert add a script to generate signed cert --- .../RX65N/GR-ROSE/common/user_settings.h | 19 +- .../RX65N/GR-ROSE/common/wolfssl_dummy.c | 4 +- .../RX65N/GR-ROSE/test/src/key_data.c | 198 ++++++++++-------- .../e2studio/RX65N/GR-ROSE/tools/README.md | 39 ++++ .../tools/example_keys/generate_SignedCA.sh | 44 ++++ .../tools/example_keys/rsa_private.pem | 27 +++ .../GR-ROSE/tools/example_keys/rsa_public.pem | 9 + 7 files changed, 239 insertions(+), 101 deletions(-) create mode 100644 IDE/Renesas/e2studio/RX65N/GR-ROSE/tools/README.md create mode 100755 IDE/Renesas/e2studio/RX65N/GR-ROSE/tools/example_keys/generate_SignedCA.sh create mode 100644 IDE/Renesas/e2studio/RX65N/GR-ROSE/tools/example_keys/rsa_private.pem create mode 100644 IDE/Renesas/e2studio/RX65N/GR-ROSE/tools/example_keys/rsa_public.pem 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 043c031933..54111aae11 100644 --- a/IDE/Renesas/e2studio/RX65N/GR-ROSE/common/user_settings.h +++ b/IDE/Renesas/e2studio/RX65N/GR-ROSE/common/user_settings.h @@ -229,7 +229,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) @@ -243,10 +242,20 @@ # 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 */ + #if !defined(min) + #define min(data1, data2) _builtin_min(data1, data2) + #endif #endif @@ -260,7 +269,5 @@ #define XSTRCASECMP(s1,s2) strcmp((s1),(s2)) -#if !defined(WOLFSSL_RENESAS_TSIP_TLS) - #define min(x,y) ((x)<(y)?(x):(y)) -#endif - +/* 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 db2911cf3a..857f9c346a 100644 --- a/IDE/Renesas/e2studio/RX65N/GR-ROSE/common/wolfssl_dummy.c +++ b/IDE/Renesas/e2studio/RX65N/GR-ROSE/common/wolfssl_dummy.c @@ -21,8 +21,8 @@ #include -#define YEAR 2023 -#define MON 6 +#define YEAR 2024 +#define MON 7 static int tick = 0; diff --git a/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/key_data.c b/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/key_data.c index 951e76e921..10b0ad4c83 100644 --- a/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/key_data.c +++ b/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/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, 0x7B, 0x70, 0xE7, 0xA5, 0xC8, 0x12, 0xD1, 0xCD, 0x55, 0x36, 0x5F, - 0xE6, 0xEB, 0xD0, 0xAD, 0x5A, 0x7F, 0x9F, 0x41, 0x79, 0x8B, 0x2F, 0x3B, - 0x17, 0xC9, 0xEE, 0xA7, 0xCB, 0xB5, 0x40, 0xFA, 0x3B, 0x43, 0x1D, 0xF8, - 0x34, 0xCC, 0xB1, 0xB4, 0x8E, 0x67, 0xF6, 0xA0, 0x49, 0xAA, 0x76, 0x33, - 0xA4, 0x56, 0xCD, 0x16, 0xE9, 0x76, 0x16, 0x92, 0xBE, 0x3F, 0x3A, 0x3A, - 0xD7, 0x7A, 0xCD, 0xC9, 0xE2, 0xA0, 0xC8, 0x16, 0x2A, 0x0D, 0xBD, 0x3C, - 0xEA, 0xC8, 0x26, 0x82, 0xDA, 0x5D, 0x19, 0x71, 0x7B, 0x90, 0x03, 0xEF, - 0x1E, 0x24, 0x01, 0x62, 0x15, 0x3D, 0x2B, 0x4C, 0xA7, 0x8F, 0xBC, 0xD3, - 0xD9, 0xC8, 0x9F, 0xBB, 0x4A, 0x62, 0x57, 0xE8, 0xE2, 0x86, 0x8C, 0x56, - 0x36, 0x64, 0xE7, 0xB9, 0x47, 0x5C, 0x02, 0xF4, 0x87, 0x50, 0x16, 0x9C, - 0xFB, 0xF6, 0xE9, 0x73, 0x96, 0x78, 0x94, 0x59, 0x12, 0x28, 0x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0, 0xBD, + 0xF6, 0xC3, 0x78, 0x80, 0x3B, 0x1F, 0xC8, 0xBA, 0x0F, 0x58, 0xF7, 0x1E, + 0x9C, 0xFB, 0x53, 0xCA, 0xA2, 0xBF, 0x9A, 0x18, 0xEE, 0x26, 0xD2, 0xA8, + 0x88, 0x64, 0x13, 0xC8, 0xEE, 0xD2, 0x79, 0xB5, 0x67, 0xD4, 0x10, 0xB3, + 0xF4, 0xC9, 0xCC, 0xCE, 0x4A, 0xE2, 0x38, 0x8B, 0x77, 0xEB, 0xD2, 0x89, + 0xB0, 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, @@ -186,83 +186,95 @@ const uint32_t encrypted_user_key_type = const unsigned char ca_ecc_cert_der_sig[] = { - 0xc0, 0x3c, 0x28, 0xef, 0x6c, 0xd5, 0x6c, 0x36, 0xc5, 0xe5, 0xb0, 0xaa, - 0xd0, 0x6a, 0x33, 0x1d, 0x7b, 0x28, 0x9f, 0xb2, 0x12, 0x8c, 0x0c, 0x5c, - 0x30, 0xdf, 0x8f, 0x3f, 0x2e, 0x72, 0x0f, 0x3d, 0x8d, 0x4a, 0x1d, 0xa6, - 0xc5, 0x1f, 0xb4, 0xf2, 0x18, 0xf1, 0x65, 0x40, 0x8e, 0xf2, 0x06, 0x0a, - 0xda, 0xa4, 0xd6, 0x3d, 0x87, 0x61, 0x00, 0xd6, 0x89, 0x4e, 0x77, 0xbd, - 0x57, 0xd7, 0x5f, 0x04, 0xe9, 0x0c, 0x96, 0x68, 0xa9, 0x72, 0xa2, 0xba, - 0x46, 0x3f, 0x35, 0xeb, 0xf9, 0x4f, 0x10, 0xfd, 0x51, 0x39, 0x7c, 0x44, - 0xa8, 0xa8, 0xd3, 0x62, 0x81, 0x2f, 0x82, 0x90, 0x3e, 0xea, 0xe9, 0xbc, - 0x2e, 0xd1, 0x19, 0xc0, 0xb6, 0xd7, 0xc0, 0x22, 0x7c, 0xc1, 0x64, 0x61, - 0xd2, 0x79, 0x01, 0x2d, 0x19, 0x7a, 0xf0, 0x34, 0x68, 0x78, 0x01, 0x35, - 0x7f, 0xe2, 0xbe, 0x11, 0x8f, 0x0d, 0x04, 0xa8, 0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xFB, 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, 0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, + 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[] = { - 0x9a, 0x0e, 0xbc, 0x0f, 0x7a, 0xbe, 0xb6, 0x47, 0x79, 0x71, 0xcc, 0x51, - 0x87, 0xaa, 0x28, 0xbd, 0x9c, 0x04, 0x08, 0x0b, 0xb9, 0x78, 0x84, 0xeb, - 0x1d, 0xf9, 0x0e, 0x38, 0x23, 0xfe, 0x8f, 0x6e, 0x75, 0x21, 0xcc, 0x39, - 0x79, 0xf8, 0x9d, 0x80, 0x6b, 0xa9, 0x63, 0x79, 0x13, 0xd8, 0xc9, 0x5d, - 0xd5, 0x84, 0x17, 0xdc, 0xe4, 0x56, 0xae, 0x55, 0x64, 0x69, 0x8c, 0x95, - 0xa4, 0x03, 0xc1, 0x4a, 0xe8, 0xb6, 0xd5, 0x1b, 0xfa, 0x26, 0x3f, 0x2c, - 0xff, 0xfc, 0xea, 0x83, 0xca, 0xf7, 0x4d, 0x9e, 0xf4, 0xbf, 0xca, 0xb6, - 0x19, 0x46, 0x55, 0x45, 0xf4, 0x7d, 0xcd, 0x4b, 0xbc, 0x3d, 0xb7, 0xff, - 0x57, 0xbf, 0xe8, 0x0e, 0xbc, 0x16, 0x45, 0xa1, 0xdb, 0xf0, 0xb4, 0x44, - 0x64, 0x76, 0x0b, 0xe5, 0x86, 0x32, 0xbe, 0xd7, 0xf0, 0x26, 0x6c, 0x48, - 0xb6, 0x7f, 0x1a, 0x2a, 0xe6, 0x1b, 0xbd, 0x5b, 0x9e, 0xca, 0xd0, 0xf4, - 0xbb, 0xe4, 0x7f, 0x29, 0x66, 0xf6, 0x31, 0x6d, 0x70, 0x6f, 0xfd, 0x4d, - 0x7f, 0xc8, 0x7f, 0x9a, 0x5b, 0x1e, 0x37, 0xf7, 0x0c, 0x66, 0xb2, 0x62, - 0xd8, 0x3e, 0xca, 0x79, 0x6c,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0x3C, 0x53, 0xBC, 0x59, + 0x5A, 0xF6, 0x1A, 0x0E, 0x2F, 0x9A, 0xA6, 0x9B, 0x3C, 0x06, + 0x88, 0x77, 0x38, 0x7A, 0x02, 0xC9, 0x89, 0x03, 0x5B, 0xF9, + 0xE7, 0xF2, 0xFD, 0x2B, 0x63, 0x94, 0x92, 0x8D, 0xBB, 0x9D, + 0x71, 0x17, 0xB6, 0xBF, 0xA4, 0x68, 0x51, 0xF4, 0x98, 0xAC, + 0xD2, 0x57, 0x6D, 0xC0, 0xBD, 0xE9, 0xC1, 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); diff --git a/IDE/Renesas/e2studio/RX65N/GR-ROSE/tools/README.md b/IDE/Renesas/e2studio/RX65N/GR-ROSE/tools/README.md new file mode 100644 index 0000000000..dcb17b70ab --- /dev/null +++ b/IDE/Renesas/e2studio/RX65N/GR-ROSE/tools/README.md @@ -0,0 +1,39 @@ +# Create/Update Signed CA +This document describes how to create/update Signed CA data that is used at an example program. + +## Signed CA Creatation +### Generate RSA Key pair +``` +2048 bit RSA key pair +$ openssl genrsa 2048 2> /dev/null > rsa_private.pem +$ openssl rsa -in rsa_private.pem -pubout -out rsa_public.pem 2> /dev/null +``` + +### Sign to CA certificate +``` +Signed by 2048-bit RSA +$ openssl dgst -sha256 -sign rsa_private.pem -sigopt rsa_padding_mode:pss -sigopt rsa_pss_saltlen:-1-out .sign + +For an example program, it assumes that wolfSSL example CA cert is to be signed. +e.g. +$ openssl dgst -sha256 -sign rsa_private.pem -sigopt rsa_padding_mode:pss -sigopt rsa_pss_saltlen:-1-out Signed-CA.sign /path/for/wolfssl/certs/ca-cert.der +``` + +### Convert Signed CA to C source +It is able to use `dertoc.pl` to generate c-source data from signed-ca binary data. + +``` +$ /path/to/wolfssl/scripts/dertoc.pl ./ca-cert.der.sign ca_cert_der_sig example.c +``` + + +## Appendix +### Example Keys +There are multiple example keys for testing in the `example_keys` folder. +``` + +| ++----+ rsa_private.pem an example 2048-bit rsa private key for signing CA cert + + rsa_public.pem an example 2048-bit rsa public key for verifying CA cert + + generate_signCA.sh an example script to genearte signed-certificate data for the example program +``` diff --git a/IDE/Renesas/e2studio/RX65N/GR-ROSE/tools/example_keys/generate_SignedCA.sh b/IDE/Renesas/e2studio/RX65N/GR-ROSE/tools/example_keys/generate_SignedCA.sh new file mode 100755 index 0000000000..dd56430ae2 --- /dev/null +++ b/IDE/Renesas/e2studio/RX65N/GR-ROSE/tools/example_keys/generate_SignedCA.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# example usage +# ./generate_SignedCA.sh rsa_private.pem rsa_public.pem ../../../../../../../../wolfssl/certs/ca-cert.der ../../../../../../../../wolfssl +# ./generate_SignedCA.sh rsa_private.pem rsa_public.pem ../../../../../../../../wolfssl/certs/ca-ecc-cert.der ../../../../../../../../wolfssl +# +SIGOPT=rsa_padding_mode:pss +SIGOPT2=rsa_pss_saltlen:-1 +CURRENT=$(cd $(dirname $0);pwd) + +function usage() { + cat <<- _EOT_ + Usage: + $0 private-key public-key file-name wolfssl-dir + + Options: + private-key : private key for sign/verify + public-key : public key for verify + file-name : file name to be signed + wolfssl-dir : wolfssl folder path + +_EOT_ +exit 1 +} + +if [ $# -ne 4 ]; then + usage +fi + +# $1 private key for sign/verify +# $2 public key for verify +# $3 file for sign/verify +signed_file=$(basename $3) +wolf_dir=$4 + +openssl dgst -sha256 -sign $1 -sigopt $SIGOPT -sigopt $SIGOPT2 -out ${CURRENT}/${signed_file}.sign $3 + +echo Verify by private key +openssl dgst -sha256 -prverify $1 -sigopt $SIGOPT -sigopt $SIGOPT2 -signature ${CURRENT}/${signed_file}.sign $3 +echo Verifiy by public key +openssl dgst -sha256 -verify $2 -sigopt $SIGOPT -sigopt $SIGOPT2 -signature ${CURRENT}/${signed_file}.sign $3 + +# Convert Signed CA to c source +${wolf_dir}/scripts/dertoc.pl ${CURRENT}/${signed_file}.sign XXXXXXX ${signed_file}.c diff --git a/IDE/Renesas/e2studio/RX65N/GR-ROSE/tools/example_keys/rsa_private.pem b/IDE/Renesas/e2studio/RX65N/GR-ROSE/tools/example_keys/rsa_private.pem new file mode 100644 index 0000000000..1fdfcca481 --- /dev/null +++ b/IDE/Renesas/e2studio/RX65N/GR-ROSE/tools/example_keys/rsa_private.pem @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEowIBAAKCAQEAvv9Ojq+nD5Qey29QAjw30fNVQz1A9OaDMivHMsLDKrW2qlzb +y5upich6j+bFVCV/qxeWe3Gqgz/9P5lL1gxlsfMB0Ou9ktkpr/tPTGfEg2GqnRT9 +jy6H2gayKV9TB4cGrqOdcg8JA8io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7knolEUCgYBFCaGP+Lft8PZO7zZ2HO0rrbGLTjz/G4kpJsJP +kGKikoI6FQaL4xDV5CaBWbiysVO1YqblJPCZD4IFlSKV24YNIKvjo4qaSCdnqr3X +UJI5yua2lt5K6dydl72kA68WxV34JanGF4BoRb9CYn8SytX2jbdaW/ITWFR70n// +vXbemQKBgG+yXyN14DZeld3zCX/1OTi1no++XSe99tK0eeXCmMTjq5kLPJAyQfSz +Cht82D1bkovS/LX+mZ06ySD632d46W8rgv+AMZqChhUmOG6a0QcCK1vYsgX90O5e +da5/kHw4lwcCY7yRDq7i0dtgoBGRsLQzIVvo4VxnLNBPH2uqHvum +-----END RSA PRIVATE KEY----- diff --git a/IDE/Renesas/e2studio/RX65N/GR-ROSE/tools/example_keys/rsa_public.pem b/IDE/Renesas/e2studio/RX65N/GR-ROSE/tools/example_keys/rsa_public.pem new file mode 100644 index 0000000000..ab82dcda3c --- /dev/null +++ b/IDE/Renesas/e2studio/RX65N/GR-ROSE/tools/example_keys/rsa_public.pem @@ -0,0 +1,9 @@ +-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvv9Ojq+nD5Qey29QAjw3 +0fNVQz1A9OaDMivHMsLDKrW2qlzby5upich6j+bFVCV/qxeWe3Gqgz/9P5lL1gxl +sfMB0Ou9ktkpr/tPTGfEg2GqnRT9jy6H2gayKV9TB4cGrqOdcg8JA8ioYt6tks03 +jMqAzqYG20N8pPOxZLl0bRX/CR9rzo/ngDZkyHXf35LL+XsjLmavPYrHdULxS4DY +z/sHVJe5hLboOjNShpDAM5WU3flDxQqspaWfAiXty0RyNmHgVY3ev5xj053hOr2F +zbA+vGr2krg6jTlGtt7Pq1/uLfsnc86E+wzHqJj/yW+ovlUGFTBhHVosQ/MB2wRx +iwIDAQAB +-----END PUBLIC KEY-----