From 2c81ecf429e266039a66d83742e22ea0eccfa327 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Wed, 27 May 2015 15:56:59 +0200 Subject: First pass at RSA tests. --- tests/Makefile.in | 2 +- tests/test-rsa.c | 215 ++++++++++++++++++ tests/test-rsa.h | 644 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/test-rsa.py | 86 ++++++++ 4 files changed, 946 insertions(+), 1 deletion(-) create mode 100644 tests/test-rsa.c create mode 100644 tests/test-rsa.h create mode 100644 tests/test-rsa.py (limited to 'tests') diff --git a/tests/Makefile.in b/tests/Makefile.in index ba45a57..19c68c8 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -2,7 +2,7 @@ INC = ../cryptech.h LIB = ../libcryptech.a -BIN = test-aes-key-wrap test-hash +BIN = test-aes-key-wrap test-hash test-rsa CC = @CC@ CFLAGS = @CFLAGS@ -I.. diff --git a/tests/test-rsa.c b/tests/test-rsa.c new file mode 100644 index 0000000..95b366a --- /dev/null +++ b/tests/test-rsa.c @@ -0,0 +1,215 @@ +/* + * First stumblings towards a test harness for RSA using Cryptech + * ModExp core. + * + * For the moment this just does modular exponentiation tests using + * RSA keys and pre-formatted data-to-be-signed, without attempting + * CRT or any of the other clever stuff we should be doing. This is + * not usable for any sane purpose other than testing. + */ + +#include +#include +#include +#include +#include + +#include "cryptech.h" +#include "test-rsa.h" + +/* + * Constant value to use with hal_io_write() when we don't want + * a read-back check thus aren't using set_register(). + */ + +static const uint8_t one[] = { 0, 0, 0, 1 }; + +/* + * Debugging aid: check a result, report on failure. + */ + +#define check(_expr_) \ + do { \ + if ((_expr_) != 0) \ + return printf("%s failed\n", #_expr_), 1; \ + } while (0) + +/* + * Set an ordinary register, with read-back check. + */ + +static int _set_register(const off_t addr, + const char * const name, + uint32_t value) +{ + uint8_t w1[4], w2[4]; + int i; + assert(name != NULL); + for (i = 3; i >= 0; i--) { + w1[i] = value & 0xFF; + value >>= 8; + } + printf("Setting register %#lx %s\n", (unsigned long) addr, name); + check(hal_io_write(addr, w1, sizeof(w1))); + check(hal_io_read(addr, w2, sizeof(w2))); + if (memcmp(w1, w2, sizeof(w1)) != 0) + printf("MISMATCH\n"); + printf("\n"); + return 0; +} + +/* + * Get value of a block memory. + */ + +static int _get_blockmem(const off_t reset_addr, + const char * const reset_name, + const off_t data_addr, + const char * const data_name, + uint8_t *value, + const size_t length) +{ + size_t i; + assert(reset_name != NULL && data_name != NULL && value != NULL && length % 4 == 0 && length <= sizeof(value)); + printf("Setting register %#lx %s\n", (unsigned long) reset_addr, reset_name); + check(hal_io_write(reset_addr, one, sizeof(one))); + printf("\n"); + printf("Getting blockmem %#lx %s\n", (unsigned long) data_addr, data_name); + for (i = 0; i < length; i += 4) + check(hal_io_read(data_addr, &value[i], 4)); + return 0; +} + +/* + * Set value of a block memory, with read-back check. + */ + +static int _set_blockmem(const off_t reset_addr, + const char * const reset_name, + const off_t data_addr, + const char * const data_name, + const uint8_t * const value, + const size_t value_length, + uint8_t *buffer, + const size_t buffer_length) +{ + size_t i; + assert(reset_name != NULL && data_name != NULL && value != NULL && buffer_length >= value_length && value_length % 4 == 0); + printf("Setting register %#lx %s\n", (unsigned long) reset_addr, reset_name); + check(hal_io_write(reset_addr, one, sizeof(one))); + printf("\n"); + printf("Setting blockmem %#lx %s\n", (unsigned long) data_addr, data_name); + for (i = 0; i < value_length; i += 4) + check(hal_io_write(data_addr, &value[i], 4)); + printf("\n"); + check(_get_blockmem(reset_addr, reset_name, data_addr, data_name, buffer, value_length)); + if (memcmp(value, buffer, value_length)) + printf("MISMATCH\n"); + printf("\n"); + return 0; +} + +/* + * Syntactic sugar. + */ + +#define set_register(_field_, _value_) \ + _set_register(_field_, #_field_, _value_) + +#define get_blockmem(_field_, _value_) \ + _get_blockmem(_field_##_PTR_RST, #_field_ "_PTR_RST", _field_##_DATA, #_field_ "_DATA", _value_, sizeof(_value_)) + +#define set_blockmem(_field_, _value_, _buffer_) \ + _set_blockmem(_field_##_PTR_RST, #_field_ "_PTR_RST", _field_##_DATA, #_field_ "_DATA", (_value_).val, (_value_).len, _buffer_, sizeof(_buffer_)) + +/* + * Test driver. + */ + +static int test(const rsa_tc_t * const tc) +{ + uint8_t b[4096]; + + printf("Signature test for %lu-bit RSA key\n", (unsigned long) tc->size); + + check(set_blockmem(MODEXP_MODULUS, tc->n, b)); + check(set_blockmem(MODEXP_MESSAGE, tc->m, b)); + check(set_register(MODEXP_MODULUS_LENGTH, tc->n.len / 4)); + + check(set_blockmem(MODEXP_EXPONENT, tc->d, b)); + check(set_register(MODEXP_EXPONENT_LENGTH, tc->d.len / 4)); + + printf("Checking ready status\n"); + check(hal_io_wait_ready(MODEXP_ADDR_STATUS)); + printf("\n"); + + check(set_register(MODEXP_ADDR_CTRL, 1)); + + printf("Waiting for ready\n"); + check(hal_io_wait(MODEXP_ADDR_STATUS, STATUS_READY, NULL)); + printf("\n"); + + check(get_blockmem(MODEXP_RESULT, b)); + + printf("Comparing results with known value..."); + if (memcmp(b, tc->s.val, tc->s.len)) + printf("MISMATCH\n"); + else + printf("OK\n"); + + printf("Verification test for %lu-bit RSA key\n", (unsigned long) tc->size); + + check(set_blockmem(MODEXP_MODULUS, tc->n, b)); + check(set_blockmem(MODEXP_MESSAGE, tc->m, b)); + check(set_register(MODEXP_MODULUS_LENGTH, tc->n.len / 4)); + + check(set_blockmem(MODEXP_EXPONENT, tc->e, b)); + check(set_register(MODEXP_EXPONENT_LENGTH, tc->e.len / 4)); + + printf("Checking ready status\n"); + check(hal_io_wait_ready(MODEXP_ADDR_STATUS)); + printf("\n"); + + check(set_register(MODEXP_ADDR_CTRL, 1)); + + printf("Waiting for ready\n"); + check(hal_io_wait(MODEXP_ADDR_STATUS, STATUS_READY, NULL)); + printf("\n"); + + check(get_blockmem(MODEXP_RESULT, b)); + + printf("Comparing results with known value..."); + if (memcmp(b, tc->m.val, tc->m.len)) + printf("MISMATCH\n"); + else + printf("OK\n"); + + return 0; +} + + +int main(int argc, char *argv[]) +{ + uint8_t name[8], version[4]; + int i; + + /* + * Initialize EIM and report what core we're running. + */ + + check(hal_io_read(MODEXP_ADDR_NAME0, name, sizeof(name))); + check(hal_io_read(MODEXP_ADDR_VERSION, version, sizeof(version))); + printf("\"%8.8s\" \"%4.4s\"\n\n", name, version); + + hal_io_set_debug(1); + + /* + * Run all the test cases. + */ + + for (i = 0; i < sizeof(rsa_tc)/sizeof(*rsa_tc); i++) + if (test(&rsa_tc[i])) + return 1; + + return 0; +} diff --git a/tests/test-rsa.h b/tests/test-rsa.h new file mode 100644 index 0000000..b6e6ba6 --- /dev/null +++ b/tests/test-rsa.h @@ -0,0 +1,644 @@ +/* + * RSA signature test data for Cryptech project, automatically generated by + * test-rsa.py using PyCrypto version 2.6.1. Do not edit. + * + * Plaintext: "You can hack anything you want with TECO and DDT." + * SHA-256: 8e36fc9aa31724c32416263c0366a175fabbb92b741ca6496107074d0343b597 + */ + +/* 1024-bit RSA private key (PKCS #8) +-----BEGIN PRIVATE KEY----- +MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBANB17AqVBI74yqaQ +c42dWOkXZLQ3ULWMrYpuMZkTX4DuhOsr3ljTjuNYJeker96xuqFaFgsAV8R8x3Ze +MYaKPhVe5XzvsAjE3WoKie6YpO6clxoH3mHlsNPPcOHNxqDeW0UfL7nbmVGWny+I +S0sJdJrmxN2+fuYfeSZcat+xazAVAgMBAAECgYA/8myeMmhbk2ZXAijwYDxOBKcX +wYA4sRbrSDJeytqZKpILskFa7kr+4qN+h7NblRmzNXddmJVT6RMm9G4s32t7hKq/ +qe8kxgC1aHKtXtuQQejs1/hTUTP73vySx0I4QiZ9QOX1yRvXRZV45GD8hYN0MXK+ +03O2lXzA1qaOMxVqYQJBANaRRDD2v64QZYrtBNjRMiryChl8+X0hxd33QXW4AR1A +SClmLlmJh5RkmsZopkuHEMduJn2yqSQq8wcGnKTiU+cCQQD4tsblcx0D/KZA9i3h +iMVWvGgJnaxWIRJjQi+6gIVqiBlJr/4FqEi3mXEURkLdGbrBBTdTtp2kKfS96xOO +eZyjAkBbThWmgFmwyGltZM7bNKoUfEqv7e58wRJiEgVZAqP2vpP2ifTPRSbcjrMO +GxooqaEKPGVEt/Ih4eTo6Hdf8q+hAkEAllMK1kYERJOg/OSOiKF8/Na1XxKAxjIJ +BhtL88KYYPJPrn0D4PF8uhOxCBsLcM2LVfzMGvnmQAHn3h5GXLfeVwJAYcoQDtnx +Et+5wWaTYN9bvQYRBqcChxc/MuUBEyOSxFuyIqIRb3V2XvsXiB1WYqIu6Nsrbzfv +RdWc9bHUt/bBEw== +-----END PRIVATE KEY----- +*/ + +static const uint8_t n_1024[] = { /* key component n, 128 bytes */ + 0xd0, 0x75, 0xec, 0x0a, 0x95, 0x04, 0x8e, 0xf8, 0xca, 0xa6, 0x90, 0x73, + 0x8d, 0x9d, 0x58, 0xe9, 0x17, 0x64, 0xb4, 0x37, 0x50, 0xb5, 0x8c, 0xad, + 0x8a, 0x6e, 0x31, 0x99, 0x13, 0x5f, 0x80, 0xee, 0x84, 0xeb, 0x2b, 0xde, + 0x58, 0xd3, 0x8e, 0xe3, 0x58, 0x25, 0xe9, 0x1e, 0xaf, 0xde, 0xb1, 0xba, + 0xa1, 0x5a, 0x16, 0x0b, 0x00, 0x57, 0xc4, 0x7c, 0xc7, 0x76, 0x5e, 0x31, + 0x86, 0x8a, 0x3e, 0x15, 0x5e, 0xe5, 0x7c, 0xef, 0xb0, 0x08, 0xc4, 0xdd, + 0x6a, 0x0a, 0x89, 0xee, 0x98, 0xa4, 0xee, 0x9c, 0x97, 0x1a, 0x07, 0xde, + 0x61, 0xe5, 0xb0, 0xd3, 0xcf, 0x70, 0xe1, 0xcd, 0xc6, 0xa0, 0xde, 0x5b, + 0x45, 0x1f, 0x2f, 0xb9, 0xdb, 0x99, 0x51, 0x96, 0x9f, 0x2f, 0x88, 0x4b, + 0x4b, 0x09, 0x74, 0x9a, 0xe6, 0xc4, 0xdd, 0xbe, 0x7e, 0xe6, 0x1f, 0x79, + 0x26, 0x5c, 0x6a, 0xdf, 0xb1, 0x6b, 0x30, 0x15 +}; + +static const uint8_t e_1024[] = { /* key component e, 4 bytes */ + 0x00, 0x01, 0x00, 0x01 +}; + +static const uint8_t d_1024[] = { /* key component d, 128 bytes */ + 0x3f, 0xf2, 0x6c, 0x9e, 0x32, 0x68, 0x5b, 0x93, 0x66, 0x57, 0x02, 0x28, + 0xf0, 0x60, 0x3c, 0x4e, 0x04, 0xa7, 0x17, 0xc1, 0x80, 0x38, 0xb1, 0x16, + 0xeb, 0x48, 0x32, 0x5e, 0xca, 0xda, 0x99, 0x2a, 0x92, 0x0b, 0xb2, 0x41, + 0x5a, 0xee, 0x4a, 0xfe, 0xe2, 0xa3, 0x7e, 0x87, 0xb3, 0x5b, 0x95, 0x19, + 0xb3, 0x35, 0x77, 0x5d, 0x98, 0x95, 0x53, 0xe9, 0x13, 0x26, 0xf4, 0x6e, + 0x2c, 0xdf, 0x6b, 0x7b, 0x84, 0xaa, 0xbf, 0xa9, 0xef, 0x24, 0xc6, 0x00, + 0xb5, 0x68, 0x72, 0xad, 0x5e, 0xdb, 0x90, 0x41, 0xe8, 0xec, 0xd7, 0xf8, + 0x53, 0x51, 0x33, 0xfb, 0xde, 0xfc, 0x92, 0xc7, 0x42, 0x38, 0x42, 0x26, + 0x7d, 0x40, 0xe5, 0xf5, 0xc9, 0x1b, 0xd7, 0x45, 0x95, 0x78, 0xe4, 0x60, + 0xfc, 0x85, 0x83, 0x74, 0x31, 0x72, 0xbe, 0xd3, 0x73, 0xb6, 0x95, 0x7c, + 0xc0, 0xd6, 0xa6, 0x8e, 0x33, 0x15, 0x6a, 0x61 +}; + +static const uint8_t p_1024[] = { /* key component p, 64 bytes */ + 0xd6, 0x91, 0x44, 0x30, 0xf6, 0xbf, 0xae, 0x10, 0x65, 0x8a, 0xed, 0x04, + 0xd8, 0xd1, 0x32, 0x2a, 0xf2, 0x0a, 0x19, 0x7c, 0xf9, 0x7d, 0x21, 0xc5, + 0xdd, 0xf7, 0x41, 0x75, 0xb8, 0x01, 0x1d, 0x40, 0x48, 0x29, 0x66, 0x2e, + 0x59, 0x89, 0x87, 0x94, 0x64, 0x9a, 0xc6, 0x68, 0xa6, 0x4b, 0x87, 0x10, + 0xc7, 0x6e, 0x26, 0x7d, 0xb2, 0xa9, 0x24, 0x2a, 0xf3, 0x07, 0x06, 0x9c, + 0xa4, 0xe2, 0x53, 0xe7 +}; + +static const uint8_t q_1024[] = { /* key component q, 64 bytes */ + 0xf8, 0xb6, 0xc6, 0xe5, 0x73, 0x1d, 0x03, 0xfc, 0xa6, 0x40, 0xf6, 0x2d, + 0xe1, 0x88, 0xc5, 0x56, 0xbc, 0x68, 0x09, 0x9d, 0xac, 0x56, 0x21, 0x12, + 0x63, 0x42, 0x2f, 0xba, 0x80, 0x85, 0x6a, 0x88, 0x19, 0x49, 0xaf, 0xfe, + 0x05, 0xa8, 0x48, 0xb7, 0x99, 0x71, 0x14, 0x46, 0x42, 0xdd, 0x19, 0xba, + 0xc1, 0x05, 0x37, 0x53, 0xb6, 0x9d, 0xa4, 0x29, 0xf4, 0xbd, 0xeb, 0x13, + 0x8e, 0x79, 0x9c, 0xa3 +}; + +static const uint8_t u_1024[] = { /* key component u, 64 bytes */ + 0x87, 0x5c, 0xc3, 0x4c, 0x33, 0xc7, 0x67, 0xfa, 0xc6, 0xf6, 0xcd, 0xf4, + 0x33, 0x85, 0x07, 0x78, 0x7f, 0x56, 0x80, 0x30, 0xee, 0x4c, 0x34, 0x03, + 0xa0, 0x5d, 0xa7, 0x34, 0x0d, 0xc9, 0x18, 0x8e, 0xd0, 0xd5, 0xe2, 0xb9, + 0x0b, 0x53, 0x4c, 0xb5, 0x00, 0x5b, 0x10, 0x9f, 0xba, 0xbf, 0x2f, 0x65, + 0x0a, 0x40, 0x58, 0x18, 0xb3, 0x83, 0xa0, 0x0c, 0x71, 0x01, 0xa4, 0x86, + 0xbe, 0xcc, 0x1b, 0x7b +}; + +static const uint8_t m_1024[] = { /* message to be signed, 128 bytes */ + 0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x00, 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, + 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20, + 0x8e, 0x36, 0xfc, 0x9a, 0xa3, 0x17, 0x24, 0xc3, 0x24, 0x16, 0x26, 0x3c, + 0x03, 0x66, 0xa1, 0x75, 0xfa, 0xbb, 0xb9, 0x2b, 0x74, 0x1c, 0xa6, 0x49, + 0x61, 0x07, 0x07, 0x4d, 0x03, 0x43, 0xb5, 0x97 +}; + +static const uint8_t s_1024[] = { /* signed message, 128 bytes */ + 0x06, 0x33, 0x9a, 0x64, 0x36, 0x7d, 0xb0, 0x2a, 0xf4, 0x11, 0x58, 0xcc, + 0x95, 0xe7, 0x60, 0x49, 0x45, 0x19, 0xc1, 0x65, 0x11, 0x11, 0x84, 0xbe, + 0xe4, 0x1d, 0x8e, 0xe2, 0x2a, 0xe5, 0xf5, 0xd1, 0x1d, 0xa7, 0xf9, 0x62, + 0xac, 0x93, 0xac, 0x88, 0x91, 0x5e, 0xee, 0x13, 0xa3, 0x35, 0x0c, 0x22, + 0xf0, 0xdf, 0xa6, 0x2e, 0xfd, 0xfc, 0x2b, 0x62, 0x29, 0xf2, 0x6e, 0x27, + 0xbe, 0xbd, 0xc8, 0x4e, 0x47, 0x46, 0xdf, 0x79, 0x7b, 0x38, 0x7a, 0xd2, + 0x13, 0x42, 0x3c, 0x9f, 0x98, 0xe8, 0xa1, 0x46, 0xff, 0x48, 0x6b, 0x6c, + 0x1a, 0x85, 0x41, 0x4e, 0x73, 0x11, 0x71, 0x21, 0xb7, 0x00, 0xe5, 0x47, + 0xab, 0x4e, 0x07, 0xb2, 0x21, 0xb9, 0x88, 0xb8, 0x24, 0xdd, 0x77, 0xc2, + 0x04, 0x6b, 0x0a, 0x20, 0xcd, 0xdb, 0x98, 0x6a, 0xac, 0x75, 0xc2, 0xf2, + 0xb0, 0x44, 0xed, 0x59, 0xea, 0x56, 0x58, 0x79 +}; + +/* 2048-bit RSA private key (PKCS #8) +-----BEGIN PRIVATE KEY----- +MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQC5tGlpsGBD/vGf +MiPLUUoggaENQ4tothWYpc+ve35q5AhUqzz04yZ0gnHey2rkg5qNfwiaukL8r6QD +Mgq/7Wh6hWoT8LBUWIljN/9zzb407brHZBKRRKl/j3WXC2kJ31+SbE7BXWCDqMmZ +4X2sphvQLI9muvN3HtgZxWVpzFfMX+I4eveeoVZcc5vYrUNqTS4aysq2TOzt4x56 +82d1spEGWEkbWgN1rlUlyCQE3Itdo1FPkPS7dVS799ajiQZRx1dHbojhDxT+0uTd +Q9V14qehygOGQGBft87dU7t/BR0jatt8WlH+6EqXTfZ2ENywNjDZC1lr1USN8Ksm +CIYBIcgjAgMBAAECggEADfVPjxAgzDuXcb3VDu03QyY7MsIG8oHtMaIU8D26DNLD +BYoxdL62Hz/Gy1ZC3JY/wa7wuKCTdGbHTy4tvKtdlQf+Jy2KM2zMNtb4rn2idFwC +FAajlqOwkdP4pLfI12MgzeKyMLqSDJNdQ+G9DoMVyBnxVWlr72I0IAvESaWAW+4g +IsRjE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RIVATE KEY----- +*/ + +static const uint8_t n_2048[] = { /* key component n, 256 bytes */ + 0xb9, 0xb4, 0x69, 0x69, 0xb0, 0x60, 0x43, 0xfe, 0xf1, 0x9f, 0x32, 0x23, + 0xcb, 0x51, 0x4a, 0x20, 0x81, 0xa1, 0x0d, 0x43, 0x8b, 0x68, 0xb6, 0x15, + 0x98, 0xa5, 0xcf, 0xaf, 0x7b, 0x7e, 0x6a, 0xe4, 0x08, 0x54, 0xab, 0x3c, + 0xf4, 0xe3, 0x26, 0x74, 0x82, 0x71, 0xde, 0xcb, 0x6a, 0xe4, 0x83, 0x9a, + 0x8d, 0x7f, 0x08, 0x9a, 0xba, 0x42, 0xfc, 0xaf, 0xa4, 0x03, 0x32, 0x0a, + 0xbf, 0xed, 0x68, 0x7a, 0x85, 0x6a, 0x13, 0xf0, 0xb0, 0x54, 0x58, 0x89, + 0x63, 0x37, 0xff, 0x73, 0xcd, 0xbe, 0x34, 0xed, 0xba, 0xc7, 0x64, 0x12, + 0x91, 0x44, 0xa9, 0x7f, 0x8f, 0x75, 0x97, 0x0b, 0x69, 0x09, 0xdf, 0x5f, + 0x92, 0x6c, 0x4e, 0xc1, 0x5d, 0x60, 0x83, 0xa8, 0xc9, 0x99, 0xe1, 0x7d, + 0xac, 0xa6, 0x1b, 0xd0, 0x2c, 0x8f, 0x66, 0xba, 0xf3, 0x77, 0x1e, 0xd8, + 0x19, 0xc5, 0x65, 0x69, 0xcc, 0x57, 0xcc, 0x5f, 0xe2, 0x38, 0x7a, 0xf7, + 0x9e, 0xa1, 0x56, 0x5c, 0x73, 0x9b, 0xd8, 0xad, 0x43, 0x6a, 0x4d, 0x2e, + 0x1a, 0xca, 0xca, 0xb6, 0x4c, 0xec, 0xed, 0xe3, 0x1e, 0x7a, 0xf3, 0x67, + 0x75, 0xb2, 0x91, 0x06, 0x58, 0x49, 0x1b, 0x5a, 0x03, 0x75, 0xae, 0x55, + 0x25, 0xc8, 0x24, 0x04, 0xdc, 0x8b, 0x5d, 0xa3, 0x51, 0x4f, 0x90, 0xf4, + 0xbb, 0x75, 0x54, 0xbb, 0xf7, 0xd6, 0xa3, 0x89, 0x06, 0x51, 0xc7, 0x57, + 0x47, 0x6e, 0x88, 0xe1, 0x0f, 0x14, 0xfe, 0xd2, 0xe4, 0xdd, 0x43, 0xd5, + 0x75, 0xe2, 0xa7, 0xa1, 0xca, 0x03, 0x86, 0x40, 0x60, 0x5f, 0xb7, 0xce, + 0xdd, 0x53, 0xbb, 0x7f, 0x05, 0x1d, 0x23, 0x6a, 0xdb, 0x7c, 0x5a, 0x51, + 0xfe, 0xe8, 0x4a, 0x97, 0x4d, 0xf6, 0x76, 0x10, 0xdc, 0xb0, 0x36, 0x30, + 0xd9, 0x0b, 0x59, 0x6b, 0xd5, 0x44, 0x8d, 0xf0, 0xab, 0x26, 0x08, 0x86, + 0x01, 0x21, 0xc8, 0x23 +}; + +static const uint8_t e_2048[] = { /* key component e, 4 bytes */ + 0x00, 0x01, 0x00, 0x01 +}; + +static const uint8_t d_2048[] = { /* key component d, 256 bytes */ + 0x0d, 0xf5, 0x4f, 0x8f, 0x10, 0x20, 0xcc, 0x3b, 0x97, 0x71, 0xbd, 0xd5, + 0x0e, 0xed, 0x37, 0x43, 0x26, 0x3b, 0x32, 0xc2, 0x06, 0xf2, 0x81, 0xed, + 0x31, 0xa2, 0x14, 0xf0, 0x3d, 0xba, 0x0c, 0xd2, 0xc3, 0x05, 0x8a, 0x31, + 0x74, 0xbe, 0xb6, 0x1f, 0x3f, 0xc6, 0xcb, 0x56, 0x42, 0xdc, 0x96, 0x3f, + 0xc1, 0xae, 0xf0, 0xb8, 0xa0, 0x93, 0x74, 0x66, 0xc7, 0x4f, 0x2e, 0x2d, + 0xbc, 0xab, 0x5d, 0x95, 0x07, 0xfe, 0x27, 0x2d, 0x8a, 0x33, 0x6c, 0xcc, + 0x36, 0xd6, 0xf8, 0xae, 0x7d, 0xa2, 0x74, 0x5c, 0x02, 0x14, 0x06, 0xa3, + 0x96, 0xa3, 0xb0, 0x91, 0xd3, 0xf8, 0xa4, 0xb7, 0xc8, 0xd7, 0x63, 0x20, + 0xcd, 0xe2, 0xb2, 0x30, 0xba, 0x92, 0x0c, 0x93, 0x5d, 0x43, 0xe1, 0xbd, + 0x0e, 0x83, 0x15, 0xc8, 0x19, 0xf1, 0x55, 0x69, 0x6b, 0xef, 0x62, 0x34, + 0x20, 0x0b, 0xc4, 0x49, 0xa5, 0x80, 0x5b, 0xee, 0x20, 0x22, 0xc4, 0x63, + 0x11, 0x81, 0x1f, 0x37, 0x11, 0x47, 0x93, 0x96, 0xcc, 0xd7, 0x5c, 0xc4, + 0xc3, 0xde, 0x3c, 0xed, 0xd5, 0x1e, 0x80, 0x35, 0x8d, 0x60, 0xea, 0x1d, + 0xe8, 0xf4, 0x3c, 0x6c, 0x78, 0x44, 0x94, 0x37, 0x0a, 0x2d, 0xc0, 0x06, + 0x23, 0xa4, 0x0d, 0x27, 0xba, 0x1b, 0xf4, 0x6a, 0xc2, 0xa8, 0xcc, 0x56, + 0x42, 0x96, 0x53, 0xa7, 0x5e, 0x3f, 0x0c, 0x0e, 0xb3, 0x69, 0xaa, 0xe6, + 0xeb, 0x1f, 0x19, 0x7e, 0x0a, 0x45, 0x14, 0x24, 0x9f, 0x5a, 0xd5, 0x4e, + 0xe2, 0x73, 0xd0, 0xc6, 0x6d, 0xe1, 0xeb, 0xfe, 0x1f, 0x52, 0x30, 0x3e, + 0xe2, 0x47, 0x76, 0x51, 0xa4, 0xad, 0x05, 0xdf, 0x75, 0x4b, 0x25, 0x05, + 0x83, 0xb3, 0xca, 0x4f, 0x69, 0xb3, 0x66, 0x50, 0x25, 0x3a, 0xc3, 0xd4, + 0xad, 0x62, 0x28, 0x66, 0xf4, 0xf4, 0x33, 0xa2, 0x57, 0x0c, 0x9d, 0x75, + 0x94, 0x14, 0x59, 0xa1 +}; + +static const uint8_t p_2048[] = { /* key component p, 128 bytes */ + 0xc5, 0x0a, 0xf2, 0x4f, 0xd1, 0xf2, 0x86, 0xca, 0x1e, 0x25, 0xbd, 0x65, + 0x2a, 0xf9, 0x75, 0xda, 0x3d, 0x98, 0x8a, 0xed, 0x0e, 0xfe, 0xc5, 0xa1, + 0x85, 0x8d, 0xb4, 0x95, 0x41, 0x4c, 0x6b, 0x5d, 0x64, 0x49, 0x39, 0x0f, + 0x0c, 0x21, 0x2b, 0x60, 0xce, 0x21, 0x04, 0xab, 0x32, 0x24, 0x8e, 0xb6, + 0xc6, 0x47, 0xc2, 0xed, 0xa0, 0x36, 0x99, 0xf6, 0xa1, 0x5c, 0x3a, 0x86, + 0x92, 0x41, 0x21, 0xe3, 0xe1, 0xc3, 0x4d, 0x8c, 0xa5, 0x6c, 0x9d, 0x04, + 0x7d, 0x04, 0x88, 0xa4, 0xe7, 0xce, 0xf6, 0x3f, 0xfe, 0xaa, 0xaf, 0xe4, + 0x8d, 0x87, 0x42, 0xbe, 0x31, 0x0d, 0x7c, 0xc0, 0xef, 0xfb, 0x27, 0x31, + 0x77, 0x0e, 0xe8, 0x1a, 0x88, 0x8d, 0xde, 0x6e, 0xa3, 0x1f, 0x73, 0x96, + 0x84, 0x8e, 0xc7, 0x43, 0x99, 0xb1, 0xa2, 0x9e, 0xb8, 0x61, 0x54, 0xa2, + 0x4d, 0x91, 0xfd, 0x87, 0x52, 0x6e, 0x2a, 0x7b +}; + +static const uint8_t q_2048[] = { /* key component q, 128 bytes */ + 0xf1, 0x44, 0xff, 0x27, 0x56, 0x64, 0x25, 0x4f, 0x94, 0x6a, 0x1b, 0xc8, + 0x20, 0x05, 0x13, 0xd0, 0x24, 0x22, 0x4e, 0x20, 0x3c, 0x5a, 0x99, 0x8b, + 0xd4, 0xaa, 0xc0, 0x49, 0x0d, 0xef, 0x2b, 0x8c, 0x3a, 0xef, 0x55, 0x2a, + 0x19, 0xe6, 0x88, 0xc7, 0xdf, 0xcd, 0x54, 0x94, 0x03, 0x63, 0xa9, 0xad, + 0x4a, 0xec, 0x6a, 0xd0, 0xcd, 0x77, 0xfc, 0xae, 0xff, 0x0b, 0x63, 0x68, + 0xf6, 0xcc, 0xdc, 0xb7, 0x29, 0xe7, 0x46, 0xb4, 0x26, 0xf9, 0xa3, 0xed, + 0x32, 0x8d, 0xf7, 0x12, 0xa2, 0x19, 0xc2, 0xef, 0x52, 0xf7, 0xde, 0x91, + 0x48, 0x97, 0x6a, 0x18, 0x8b, 0x84, 0x0e, 0xaa, 0x62, 0xf2, 0xaa, 0x31, + 0x1e, 0xdc, 0x8a, 0x31, 0x30, 0x3b, 0x22, 0xec, 0x7c, 0x8b, 0x8c, 0xbd, + 0x4d, 0xe5, 0xb7, 0xb6, 0x68, 0xac, 0xaa, 0xff, 0x8e, 0x6e, 0x93, 0x14, + 0xa4, 0xef, 0x2b, 0x9f, 0x15, 0x4a, 0xdc, 0x79 +}; + +static const uint8_t u_2048[] = { /* key component u, 128 bytes */ + 0x5e, 0x42, 0x7f, 0x1d, 0x33, 0x81, 0x1e, 0xa4, 0x18, 0xdf, 0x86, 0xba, + 0xb0, 0x1b, 0x77, 0x56, 0xf4, 0x65, 0x91, 0x31, 0xd8, 0xac, 0xbc, 0x63, + 0x55, 0x55, 0x11, 0x5c, 0xc5, 0x31, 0x61, 0x08, 0xe0, 0xb3, 0x5c, 0xce, + 0x9e, 0x82, 0xbb, 0xc4, 0x7d, 0xd3, 0xc3, 0xc0, 0x95, 0x0b, 0xc0, 0xbf, + 0x7c, 0xaf, 0xcd, 0xa2, 0x1f, 0xbb, 0x8f, 0x7f, 0xce, 0xde, 0x42, 0x59, + 0xd5, 0x71, 0x49, 0xa2, 0x91, 0xe2, 0x24, 0xc2, 0xf7, 0x7f, 0xd2, 0xae, + 0x10, 0xbd, 0x34, 0xb6, 0xc4, 0xec, 0xa2, 0x17, 0xc8, 0x4f, 0x76, 0xf6, + 0x1d, 0x90, 0x72, 0x58, 0x55, 0x18, 0xbe, 0x44, 0xd4, 0xf1, 0x85, 0xf5, + 0x90, 0x65, 0x45, 0x4f, 0xf1, 0x3b, 0x65, 0xe7, 0x79, 0x3b, 0xe5, 0x4e, + 0x56, 0x28, 0x4b, 0x62, 0x4d, 0x8e, 0x1d, 0x25, 0x26, 0x37, 0x1a, 0xb5, + 0x5c, 0xd5, 0x14, 0x67, 0x73, 0x74, 0x70, 0x24 +}; + +static const uint8_t m_2048[] = { /* message to be signed, 256 bytes */ + 0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, + 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20, 0x8e, 0x36, 0xfc, 0x9a, + 0xa3, 0x17, 0x24, 0xc3, 0x24, 0x16, 0x26, 0x3c, 0x03, 0x66, 0xa1, 0x75, + 0xfa, 0xbb, 0xb9, 0x2b, 0x74, 0x1c, 0xa6, 0x49, 0x61, 0x07, 0x07, 0x4d, + 0x03, 0x43, 0xb5, 0x97 +}; + +static const uint8_t s_2048[] = { /* signed message, 256 bytes */ + 0xa4, 0xcf, 0x2b, 0x55, 0x74, 0x6e, 0x9a, 0x97, 0x4e, 0x50, 0x7a, 0x8c, + 0xbb, 0x32, 0x3d, 0x42, 0x4a, 0x14, 0x0d, 0x50, 0x29, 0xc8, 0x76, 0x2c, + 0xd9, 0x25, 0x16, 0x62, 0xee, 0xc7, 0xd7, 0xf9, 0x7f, 0xc5, 0x0c, 0x4b, + 0xa4, 0x6e, 0xd3, 0xe5, 0x0d, 0x01, 0x7c, 0xd7, 0x9e, 0xe2, 0x9f, 0xa0, + 0xf0, 0x51, 0x57, 0x4f, 0x9b, 0xf2, 0x89, 0x03, 0x04, 0xe7, 0xda, 0x19, + 0x05, 0xe7, 0xcb, 0xea, 0xaf, 0x84, 0xae, 0x21, 0x44, 0x6f, 0x85, 0xc4, + 0x71, 0x9b, 0x35, 0xed, 0xd8, 0x55, 0xd7, 0x25, 0xaa, 0xdb, 0xd8, 0x0f, + 0x24, 0xac, 0x3e, 0x3d, 0xcd, 0xa5, 0x72, 0xd9, 0x96, 0x75, 0x4b, 0x93, + 0xc4, 0x37, 0xef, 0x25, 0xe4, 0xa0, 0xda, 0x66, 0x51, 0x5e, 0xc2, 0xa9, + 0xcb, 0x4b, 0xde, 0xca, 0x70, 0x68, 0xd0, 0x9a, 0x76, 0x79, 0x86, 0x5f, + 0xab, 0xc0, 0x5d, 0x35, 0x10, 0x59, 0xa5, 0x4b, 0x17, 0x56, 0x68, 0xe2, + 0x24, 0x53, 0x3c, 0x73, 0x0f, 0x9d, 0x74, 0xeb, 0xb8, 0x9e, 0xb3, 0x18, + 0x8c, 0x20, 0x32, 0xf6, 0x28, 0x98, 0xe8, 0x6e, 0x95, 0xf5, 0x62, 0x2f, + 0x72, 0x13, 0x38, 0xe6, 0xd7, 0xaa, 0x46, 0x69, 0x07, 0xe8, 0x1e, 0x14, + 0xe3, 0x45, 0x03, 0x34, 0xa7, 0xde, 0xaf, 0xca, 0x42, 0x08, 0x22, 0xea, + 0x27, 0xe8, 0xaa, 0x49, 0xaf, 0x2f, 0xbe, 0xa6, 0x1f, 0xdc, 0x28, 0x7f, + 0x75, 0x3c, 0xfc, 0xe0, 0x80, 0x63, 0xf0, 0xd2, 0xd2, 0x93, 0x6b, 0x91, + 0xe1, 0x3b, 0x97, 0x50, 0xf4, 0x0f, 0xce, 0x73, 0xa2, 0x01, 0x7d, 0x97, + 0x84, 0x97, 0x61, 0xf5, 0x50, 0x66, 0x23, 0x1b, 0x94, 0x91, 0x67, 0x21, + 0xdc, 0x1a, 0xe0, 0x2a, 0x83, 0x91, 0x29, 0x64, 0x73, 0xb7, 0x2a, 0x0c, + 0x44, 0x48, 0x11, 0x36, 0x5f, 0xb3, 0x73, 0x1d, 0x43, 0xb6, 0xc3, 0x5e, + 0x9c, 0x63, 0x3c, 0x93 +}; + +/* 4096-bit RSA private key (PKCS #8) +-----BEGIN PRIVATE KEY----- +MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQC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ixsoKdrtyX2GzTblyqTEyO0zzbQuc0fsotfR8eHlMorZJUD +OEMxOMledaO50ViUl+IJeNn78Lkm9Ir4HrbzYYYy+djLPiHWiZBFHZnwYy5ZAm8I +F4y8OqBbJMdAAcMlO+6v6B5qznE9bimQSSjGeSDrIXihDopzlW8/GHiKdh4Q8D5c +J4VwrRkJNsDEenHiS8RKwI91unvSGEZuYa1KQ9iATYijRRb6O1pERUx5iXq6TWZ2 +JJZLsc6qY9l9YIc7UZAOe8wyLb7NTLCfw85JOPLFAoIBAC0ELGADW53mKy+zbKyl +0roUjzuDCNwpX3ZuKqQT7a1wKP0PYOvZp2quz/LSCps6sQBI2xKOuK5fWSzAyfzz +F5x77JgksCPRbMK06rHKZfXYD06WxqdSWP0LRcMKb53DhxYvnfWUifAA/2PWAAET +BVQEAW/61d6wJS/vIpktgdWhQxswEquprb1aTTvPJLob/82vLEvPk7QMpME2cHY7 +PaEzFMJHxUy24d+wQUQQoFn6r6uPCPxIa4Dj3eJSXqfo6d/gUwuLur6mHyDN467J +TIrIXUUs12yvhKHAjpkBFQm79Chy3npdeTXC1y0UcMTHKwKc2DFuJmb8sGoVqBn/ +6WECggEAb5ivKyaQQG+eYu4+9hFEIWAe71Yi28/NLaOHfyjaeTciBDLm/XlHX6hE +7K3PgGV8FTulY1rcIRvGL2cI6+s9Ig2yXGgeREDgJBXNt+/tU5BEZMcmQhdp6RRj +f8zX7LVIhMUrY05J4UIJ4tVjQk6+raLp+4xF0BqGvj7tNkiqNGp++WQ5W296YJJ1 +O7NGnUuOrOlujwGpZb/eolN2CxuG/u9+Qw7H8q6XSY9Qy/sIsG6exNep3uirV6T8 +aXl0oxF0s/y8GOFthFRCxb0zl53We84fV6wC6TP4JjnwH0g8de/d/LYL3UWdnVp3 +kGtZAf6sJuZ46gk9R0vQHX5WXHQUIw== +-----END PRIVATE KEY----- +*/ + +static const uint8_t n_4096[] = { /* key component n, 512 bytes */ + 0x97, 0xa1, 0xe3, 0xe1, 0xe2, 0x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x70, 0x4e, 0xcd, 0xf4, 0x87, 0x74, + 0xe0, 0xd3, 0x6a, 0xcb, 0xee, 0xe8, 0x04, 0x64, 0x2f, 0x34, 0xde, 0x71, + 0x61, 0xac, 0xc6, 0x7c, 0x65, 0x31, 0x6f, 0xd8, 0xdc, 0x4a, 0x49, 0x43, + 0xa7, 0xec, 0x19, 0xf3, 0x73, 0x2a, 0x77, 0x78, 0xe3, 0xc9, 0x0a, 0xc4, + 0xea, 0x6e, 0x36, 0x10, 0x8e, 0x50, 0x4d, 0xad, 0xea, 0x70, 0x6f, 0xc3, + 0xff, 0x68, 0x70, 0x0b, 0x0a, 0x9b, 0x38, 0x7b, 0x43, 0x0d, 0xc1, 0x99, + 0xac, 0x64, 0xc4, 0xb8, 0x53, 0xb5, 0xc5, 0x28, 0x87, 0x74, 0x88, 0x0e, + 0xcc, 0x06, 0x98, 0xd2, 0xf5, 0xb8, 0x86, 0xb7, 0x73, 0xc0, 0x23, 0x4f, + 0x32, 0x3b, 0x74, 0xef, 0xde, 0x14, 0xc7, 0xeb, 0x18, 0x94, 0x9b, 0xc3, + 0xcb, 0xef, 0x00, 0xf4, 0x9b, 0x2f, 0x07, 0x12, 0xfc, 0x5d, 0x69, 0x9f, + 0x45, 0x98, 0x3c, 0x6a, 0xee, 0x60, 0xfb, 0xee, 0x8c, 0xac, 0x98, 0xba, + 0x40, 0x25, 0xa4, 0x80, 0x39, 0xf7, 0x83, 0x23, 0xbc, 0x19, 0x1e, 0x17, + 0xb5, 0x0d, 0x90, 0xc3, 0xa4, 0xac, 0xe5, 0x76, 0xd3, 0x7f, 0x75, 0x6c, + 0x54, 0x27, 0x77, 0xf9, 0x75, 0x96, 0xa2, 0x84, 0x45, 0x24, 0xb2, 0x40, + 0x31, 0x42, 0x63, 0x16, 0x8c, 0x99, 0xdf, 0x90, 0xae, 0x6f, 0xa6, 0x04, + 0x62, 0x1f, 0xdf, 0x37, 0xc9, 0xd2, 0x9d, 0x68, 0xa3, 0x7f, 0x63, 0x3c, + 0xce, 0x39, 0x53, 0xc4, 0x66, 0x50, 0xba, 0x47, 0x50, 0x71, 0x47, 0xcf, + 0xbe, 0xf4, 0x4a, 0x02, 0xf7, 0xd2, 0xb2, 0x24, 0x98, 0xe8, 0x94, 0x99, + 0xb4, 0x3b, 0x3f, 0xc9, 0x4f, 0x52, 0x46, 0x4a, 0x12, 0x99, 0x61, 0x5d, + 0xfd, 0xaf, 0xba, 0x56, 0x7a, 0x3e, 0x85, 0xca, 0x06, 0xac, 0x8a, 0xf2, + 0x85, 0x36, 0xe3, 0x10, 0x32, 0x8f, 0xe7, 0x2b, 0x07, 0xc7, 0xe9, 0xdf, + 0x46, 0xfc, 0x03, 0xf1, 0xce, 0x97, 0x79, 0x87, 0x3f, 0xd1, 0xf3, 0x8a, + 0x38, 0x38, 0x2f, 0xc1, 0xb7, 0x99, 0x91, 0xc3, 0xa9, 0xc8, 0x78, 0x6f, + 0xbe, 0xf5, 0x9d, 0x91, 0x53, 0x1b, 0x52, 0xc5, 0xa4, 0x85, 0x9b, 0x18, + 0x12, 0xd1, 0x35, 0xf0, 0xe6, 0x5e, 0x04, 0x95, 0x48, 0x22, 0xb1, 0x3e, + 0xaf, 0xa2, 0x6d, 0xa9, 0xa2, 0xeb, 0xb8, 0xd9, 0xa5, 0x24, 0x02, 0x30, + 0x4d, 0x59, 0x69, 0xa7, 0xed, 0xfc, 0xe3, 0x60, 0xb8, 0xc6, 0xf9, 0x2b, + 0x52, 0x1d, 0x96, 0x15, 0x1d, 0xc4, 0xc9, 0xc3 +}; + +static const uint8_t e_4096[] = { /* key component e, 4 bytes */ + 0x00, 0x01, 0x00, 0x01 +}; + +static const uint8_t d_4096[] = { /* key component d, 512 bytes */ + 0x27, 0x8f, 0x3a, 0xee, 0xd1, 0xbf, 0x06, 0x56, 0x23, 0x06, 0x35, 0xa3, + 0x68, 0xa3, 0x6e, 0xa1, 0x70, 0x05, 0x0a, 0x37, 0x93, 0xd4, 0x32, 0x16, + 0xaf,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e, 0x50, 0xea, 0x08, 0xef, 0xd5, 0xf9, 0xb2, + 0x9e, 0xb9, 0xed, 0x97, 0x1e, 0xfd, 0x1b, 0x56, 0xcd, 0x67, 0xa0, 0x57, + 0x54, 0x5f, 0x1d, 0x43, 0x2b, 0xde, 0x6b, 0xc7, 0x29, 0xe9, 0x9d, 0x0a, + 0x84, 0xd4, 0x25, 0xb4, 0xf3, 0xb3, 0xdb, 0x1c, 0x98, 0xdc, 0x91, 0x49, + 0x16, 0xec, 0xc8, 0xfa, 0xa1, 0xb2, 0x03, 0xb6, 0xe5, 0x7a, 0xb4, 0x56, + 0xb5, 0xf5, 0x70, 0x4b, 0x75, 0x68, 0xb9, 0x6e, 0xea, 0x66, 0xc9, 0xe2, + 0x25, 0xc2, 0x4d, 0xe3, 0x14, 0xcc, 0xc1, 0xf9, 0xa0, 0xe0, 0x8e, 0x71, + 0xa0, 0xbf, 0x53, 0xbb, 0x2f, 0x60, 0x37, 0x76, 0xca, 0xfb, 0x55, 0x57, + 0x65, 0xbd, 0xda, 0xef, 0xf4, 0x65, 0xb2, 0xe9, 0x3c, 0x17, 0xa3, 0x55, + 0x4f, 0x5e, 0x8f, 0xd5, 0xef, 0xce, 0x1e, 0x64, 0x92, 0x8f, 0x4b, 0xde, + 0x7c, 0x8b, 0x89, 0x62, 0xb1, 0x60, 0xe2, 0x81 +}; + +static const uint8_t p_4096[] = { /* key component p, 256 bytes */ + 0xbd, 0x67, 0x35, 0x89, 0x0c, 0xdd, 0x2d, 0xae, 0xfa, 0xf4, 0xc3, 0xac, + 0xa0, 0xe7, 0x01, 0xe0, 0x3b, 0xb5, 0x3c, 0x7f, 0xe0, 0xe1, 0x80, 0x18, + 0x96, 0xce, 0x0d, 0x5f, 0xaf, 0x83, 0x14, 0x9c, 0xda, 0x50, 0xdd, 0x86, + 0xf4, 0x5f, 0x22, 0xd1, 0x5d, 0xdc, 0xc2, 0x36, 0x49, 0x8a, 0x88, 0xc9, + 0x0d, 0xf4, 0xc7,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b7, 0x4d, 0x9a, 0xde, 0x35, 0x47, 0x5e, 0xbd, + 0xae, 0xae, 0x96, 0xc2, 0xdb, 0x3d, 0x39, 0xde, 0x7e, 0xfc, 0xd8, 0xcc, + 0x3f, 0xea, 0x8b, 0x63 +}; + +static const uint8_t q_4096[] = { /* key component q, 256 bytes */ + 0xcc, 0xf2, 0xcf, 0xaf, 0x2f, 0x5a, 0x22, 0x36, 0x67, 0x12, 0xce, 0xf9, + 0xef, 0xdc, 0x6b, 0xc4, 0xdf, 0x9a, 0x6b, 0x59, 0x43, 0xa7, 0x55, 0x56, + 0xa8, 0x5f, 0x32, 0xe2, 0x5d, 0x41, 0x33, 0xd6, 0x5b, 0x89, 0xb5, 0x2a, + 0x30, 0x06, 0xe3, 0x1b, 0x68, 0xbd, 0xad, 0x57, 0x0a, 0xd1, 0x44, 0xe1, + 0x9f, 0xe4, 0x99, 0xed, 0x6e, 0x0d, 0x24, 0xdd, 0xdd, 0x52, 0xb6, 0x67, + 0xc8, 0x51, 0xe3, 0x25, 0x9a, 0xd4, 0x17, 0xb6, 0x06, 0x17, 0x53, 0x26, + 0x78, 0x12, 0x4e, 0x8b, 0xe8, 0x73, 0x1a, 0x1f, 0xfe, 0xfa, 0xe5, 0xc1, + 0x54, 0xc2, 0x22, 0x98, 0xc4, 0xcf, 0xc1, 0xf9, 0x1c, 0x8b, 0xfa, 0xe4, + 0xb2, 0x50, 0x7e, 0x25, 0x24, 0x49, 0xd9, 0x3f, 0x63, 0x96, 0x51, 0x20, + 0xa7, 0x14, 0xa7, 0x81, 0xf8, 0x97, 0x97, 0x14, 0x5c, 0x25, 0xe1, 0x4d, + 0x7c, 0x70, 0xa7, 0x2c, 0xba, 0x80, 0x22, 0xc4, 0xf3, 0xdc, 0x8f, 0x4c, + 0xf2, 0x4b, 0x76, 0xe7, 0x70, 0xeb, 0xb5, 0xe2, 0x18, 0xd0, 0x28, 0x03, + 0x28, 0xf0, 0x30, 0x91, 0x54, 0x05, 0x41, 0xe5, 0x4d, 0x84, 0x87, 0x8b, + 0x22, 0xc3, 0x28, 0x9b, 0xcc, 0xd1, 0x29, 0xda, 0xe5, 0x2c, 0x32, 0x44, + 0x95, 0xc7, 0x5b, 0x77, 0xf3, 0x6a, 0x97, 0x0a, 0x2f, 0x18, 0xa4, 0xb0, + 0x67, 0x99, 0x46, 0xad, 0xcf, 0x24, 0xba, 0x2a, 0xbc, 0x04, 0x54, 0xe5, + 0x91, 0xbe, 0x37, 0x3c, 0x11, 0xf7, 0x8a, 0xa4, 0x2d, 0x6f, 0xca, 0x4d, + 0x16, 0x71, 0x6a, 0x02, 0xf7, 0xdf, 0xa9, 0x1c, 0x0e, 0x53, 0x51, 0x19, + 0xb8, 0x6c, 0x46, 0x61, 0x8e, 0x9c, 0x3a, 0x8f, 0xfa, 0x1a, 0x56, 0xa8, + 0xef, 0x16, 0x2b, 0x45, 0xc4, 0x70, 0xbf, 0xb4, 0x45, 0xf2, 0xbb, 0x67, + 0x4d, 0x96, 0xbb, 0xbb, 0x77, 0x7c, 0xc6, 0x4f, 0x7b, 0xce, 0xcf, 0x93, + 0xde, 0x11, 0x86, 0x21 +}; + +static const uint8_t u_4096[] = { /* key component u, 256 bytes */ + 0x54, 0x31, 0x57, 0xff, 0x2c, 0xac, 0x38, 0xe7, 0xef, 0xa6, 0x8e, 0x0f, + 0xba, 0xcd, 0x7f, 0xcb, 0x8a, 0x30, 0x4a, 0x98, 0xd9, 0xf2, 0xb8, 0x61, + 0x5e, 0x93, 0x8f, 0x99, 0xf4, 0xe8, 0x3e, 0xd8, 0x23, 0x6f, 0xab, 0xc0, + 0x64, 0x7d, 0x1a, 0xf1, 0x10, 0x8c, 0xd3, 0x3f, 0x3d, 0x2e, 0x0d, 0xa1, + 0x6c, 0xb7, 0x27, 0x9f, 0x87, 0x0c, 0x73, 0x3a, 0xe4, 0xb3, 0x03, 0x14, + 0xfd, 0x1a, 0x5e, 0xe9, 0x98, 0xde, 0xb0, 0x93, 0xd7, 0x36, 0x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 0x3d, 0xac, + 0xa3, 0x92, 0x36, 0x0b +}; + +static const uint8_t m_4096[] = { /* message to be signed, 512 bytes */ + 0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x00, 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, + 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20, + 0x8e, 0x36, 0xfc, 0x9a, 0xa3, 0x17, 0x24, 0xc3, 0x24, 0x16, 0x26, 0x3c, + 0x03, 0x66, 0xa1, 0x75, 0xfa, 0xbb, 0xb9, 0x2b, 0x74, 0x1c, 0xa6, 0x49, + 0x61, 0x07, 0x07, 0x4d, 0x03, 0x43, 0xb5, 0x97 +}; + +static const uint8_t s_4096[] = { /* signed message, 512 bytes */ + 0x57, 0x1c, 0xea, 0xc6, 0xef, 0x58, 0x63, 0x7f, 0x9f, 0x61, 0xd7, 0x28, + 0x33, 0xb2, 0x06, 0x55, 0xf6, 0x19, 0x30, 0x04, 0x40, 0xbd, 0x8a, 0x1b, + 0x61, 0x21, 0x5f, 0xc2, 0x97, 0x38, 0xd4, 0x3e, 0x20, 0x92, 0x12, 0x58, + 0x40, 0xd9, 0x60, 0x6f, 0x52, 0x82, 0x00, 0x00, 0x44, 0x68, 0x29, 0xf5, + 0xcb, 0x00, 0xf2, 0xde, 0xc8, 0x49, 0xba, 0x47, 0xf3, 0x5c, 0xb7, 0x8d, + 0xfd, 0x5f, 0x67, 0x12, 0xb9, 0x76, 0xed, 0x24, 0x1f, 0x25, 0x04, 0x17, + 0x08, 0x45, 0xaa, 0x55, 0x0a, 0x9b, 0x5e, 0x88, 0x03, 0x95, 0x1a, 0x77, + 0x7b, 0xe0, 0xe2, 0xd8, 0xc2, 0xef, 0x53, 0x22, 0x66, 0x92, 0x73, 0x19, + 0xcf, 0x1a, 0x26, 0x98, 0x57, 0x2e, 0xbc, 0x04, 0x36, 0xab, 0x26, 0xe9, + 0x57, 0x1b, 0x5d, 0x3f, 0x49, 0x13, 0xf8, 0x53, 0x3d, 0x4f, 0xbe, 0x41, + 0x59, 0x68, 0xa2, 0x34, 0x4e, 0xc7, 0x9d, 0x14, 0x0d, 0xaf, 0xdf, 0x91, + 0xba, 0xf7, 0xe4, 0xce, 0x04, 0x12, 0x9b, 0x47, 0x17, 0x3d, 0xb4, 0xd3, + 0x76, 0x74, 0xdb, 0x34, 0x80, 0x91, 0x26, 0x56, 0x7f, 0x55, 0x30, 0x64, + 0x15, 0xa4, 0xc2, 0x20, 0x1a, 0x34, 0xde, 0x0a, 0x6b, 0x99, 0x6a, 0x92, + 0xf0, 0x40, 0x26, 0xe4, 0x77, 0x73, 0x60, 0x98, 0xa9, 0xb8, 0xbf, 0xc6, + 0xda, 0x68, 0xa4, 0xcb, 0xee, 0xae, 0x58, 0xf9, 0xa4, 0xb1, 0xfd, 0xb9, + 0xaa, 0xfd, 0xea, 0xd2, 0x29, 0xec, 0x30, 0xb0, 0x30, 0xc7, 0x8e, 0xdb, + 0x4b, 0x65, 0x59, 0x65, 0x11, 0xe5, 0xc2, 0xe8, 0xca, 0x43, 0x33, 0x32, + 0x14, 0x5c, 0x97, 0xf4, 0xc2, 0xe9, 0xde, 0xc9, 0xa9, 0x9e, 0x55, 0x51, + 0x0e, 0xf7, 0x93, 0xda, 0x95, 0xbb, 0xe5, 0xd0, 0xf6, 0xd9, 0x1b, 0x54, + 0x34, 0x26, 0x25, 0x3a, 0xeb, 0xbf, 0x80, 0x0a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x66, 0xf5, 0x1e, + 0xca, 0xdb, 0xf1, 0x96, 0x39, 0xb2, 0xf3, 0xa4, 0x3d, 0x26, 0xa2, 0x27, + 0xa5, 0xab, 0xb2, 0x24, 0x34, 0xb0, 0xb5, 0xbf, 0xb7, 0xd1, 0x18, 0x4e, + 0x74, 0x7b, 0x85, 0xe8, 0xfb, 0x1e, 0x54, 0x36, 0xf9, 0x85, 0xd5, 0x74, + 0x47, 0xe9, 0xf7, 0x6a, 0x29, 0x65, 0xb4, 0x53, 0x9b, 0x5c, 0xd3, 0xae, + 0xbc, 0x9f, 0x06, 0x27, 0xce, 0xa5, 0xf5, 0x7b, 0xd3, 0x93, 0xda, 0x09, + 0x2d, 0xad, 0xa0, 0xca, 0xb7, 0xe8, 0xba, 0xf9, 0xa9, 0x6a, 0xe3, 0x2e, + 0xd6, 0xc6, 0x3d, 0xae, 0x07, 0x24, 0x5a, 0xd7 +}; + +typedef struct { const uint8_t *val; size_t len; } rsa_tc_bn_t; +typedef struct { size_t size; rsa_tc_bn_t n, e, d, p, q, u, m, s; } rsa_tc_t; + +static const rsa_tc_t rsa_tc[] = { + { 1024, + { n_1024, sizeof(n_1024) }, + { e_1024, sizeof(e_1024) }, + { d_1024, sizeof(d_1024) }, + { p_1024, sizeof(p_1024) }, + { q_1024, sizeof(q_1024) }, + { u_1024, sizeof(u_1024) }, + { m_1024, sizeof(m_1024) }, + { s_1024, sizeof(s_1024) } + }, + { 2048, + { n_2048, sizeof(n_2048) }, + { e_2048, sizeof(e_2048) }, + { d_2048, sizeof(d_2048) }, + { p_2048, sizeof(p_2048) }, + { q_2048, sizeof(q_2048) }, + { u_2048, sizeof(u_2048) }, + { m_2048, sizeof(m_2048) }, + { s_2048, sizeof(s_2048) } + }, + { 4096, + { n_4096, sizeof(n_4096) }, + { e_4096, sizeof(e_4096) }, + { d_4096, sizeof(d_4096) }, + { p_4096, sizeof(p_4096) }, + { q_4096, sizeof(q_4096) }, + { u_4096, sizeof(u_4096) }, + { m_4096, sizeof(m_4096) }, + { s_4096, sizeof(s_4096) } + } +}; diff --git a/tests/test-rsa.py b/tests/test-rsa.py new file mode 100644 index 0000000..759d5a3 --- /dev/null +++ b/tests/test-rsa.py @@ -0,0 +1,86 @@ +# Use PyCrypto to generate test data for Cryptech ModExp core. +# +# Funnily enough, PyCrypto and Cryptlib use exactly the same names for +# RSA key components, see Cryptlib documentation pages 186-187 & 339. + +key_lengths = (1024, 2048, 4096) # Lengths in bits of keys to generate +pkcs_encoding = 8 # PKCS encoding for PEM comment (1 or 8) + +plaintext = "You can hack anything you want with TECO and DDT." + +from Crypto import __version__ as PyCryptoVersion +from Crypto.PublicKey import RSA +from Crypto.Hash import SHA256 +from Crypto.Util.number import long_to_bytes +from Crypto.Signature.PKCS1_v1_5 import EMSA_PKCS1_V1_5_ENCODE, PKCS115_SigScheme +from textwrap import TextWrapper +import sys, os.path + +assert all(key_length % 8 == 0 for key_length in key_lengths) + +scriptname = os.path.basename(sys.argv[0]) + +wrapper = TextWrapper(width = 78, initial_indent = " " * 2, subsequent_indent = " " * 2) + +def printlines(*lines, **kwargs): + for line in lines: + sys.stdout.write(line % kwargs + "\n") + +def trailing_comma(item, sequence): + return "" if item == sequence[-1] else "," + +def print_hex(name, value, comment): + printlines("static const uint8_t %(name)s[] = { /* %(comment)s, %(length)d bytes */", + wrapper.fill(", ".join("0x%02x" % ord(v) for v in value)), + "};", "", + name = name, comment = comment, length = len(value)) + +h = SHA256.new(plaintext) + +printlines("/*", + " * RSA signature test data for Cryptech project, automatically generated by", + " * %(scriptname)s using PyCrypto version %(version)s. Do not edit.", + " *", + " * Plaintext: \"%(plaintext)s\"", + " * SHA-256: %(digest)s", + " */", "", + scriptname = scriptname, + version = PyCryptoVersion, + plaintext = plaintext, + digest = h.hexdigest()) + +for k_len in key_lengths: + + k = RSA.generate(k_len) # Cryptlib insists u < p, probably with good reason, + while k.u >= k.p: # and I'm sure not going to argue the math with Peter, + k = RSA.generate(k_len) # so keep trying until we pass this test + + m = EMSA_PKCS1_V1_5_ENCODE(h, k_len/8) + s = PKCS115_SigScheme(k).sign(h) + assert len(m) == len(s) + + printlines("/* %(k_len)d-bit RSA private key (PKCS #%(pkcs)d)", + k.exportKey(format = "PEM", pkcs = pkcs_encoding), + "*/", "", + k_len = k_len, pkcs = pkcs_encoding) + + for component in k.keydata: + print_hex("%s_%d" % (component, k_len), + long_to_bytes(getattr(k, component), blocksize = 4), + "key component %s" % component) + print_hex("m_%d" % k_len, m, "message to be signed") + print_hex("s_%d" % k_len, s, "signed message") + +fields = "nedpqums" +printlines("typedef struct { const uint8_t *val; size_t len; } rsa_tc_bn_t;", + "typedef struct { size_t size; rsa_tc_bn_t %(fields)s; } rsa_tc_t;", + "", + "static const rsa_tc_t rsa_tc[] = {", + fields = ", ".join(fields)) +for k_len in key_lengths: + printlines(" { %(k_len)d,", k_len = k_len) + for field in fields: + printlines(" { %(field)s_%(k_len)d, sizeof(%(field)s_%(k_len)d) }%(comma)s", + field = field, k_len = k_len, comma = trailing_comma(field, fields)) + printlines(" }%(comma)s", comma = trailing_comma(k_len, key_lengths)) +printlines("};") -- cgit v1.2.3