X-Git-Url: https://git.cryptolib.org/?a=blobdiff_plain;f=test_src%2Fmain-rsaes_oaep-test.c;h=5f86ec2b59f3ced81ee52ec238321b9f53100ded;hb=56e75f661dfea7104d76421be6059f098d3236d4;hp=26cb449697d6c7c6bed47601c8ef90e954539b73;hpb=7715ef86b09869014eb5afd319e4acc2ce157b00;p=avr-crypto-lib.git diff --git a/test_src/main-rsaes_oaep-test.c b/test_src/main-rsaes_oaep-test.c index 26cb449..5f86ec2 100644 --- a/test_src/main-rsaes_oaep-test.c +++ b/test_src/main-rsaes_oaep-test.c @@ -422,7 +422,7 @@ uint8_t read_bigint(bigint_t* a, char* prompt){ return 1; } a->wordv = (bigint_word_t*)buffer; - a->length_B = (read_length + sizeof(bigint_word_t) - 1) / sizeof(bigint_word_t); + a->length_W = (read_length + sizeof(bigint_word_t) - 1) / sizeof(bigint_word_t); a->info = 0; bigint_changeendianess(a); bigint_adjust(a); @@ -491,7 +491,7 @@ uint8_t read_key_conv(void){ } uint8_t load_bigint_from_os(bigint_t* a, PGM_VOID_P os, uint16_t length_B){ - a->length_B = BIGINT_CEIL(length_B) / sizeof(bigint_word_t); + a->length_W = BIGINT_CEIL(length_B) / sizeof(bigint_word_t); a->wordv = malloc(BIGINT_CEIL(length_B)); if(!a->wordv){ cli_putstr_P(PSTR("\r\nOOM!\r\n")); @@ -531,12 +531,15 @@ void quick_test(void){ uint8_t *ciphertext, *plaintext, rc; uint8_t seed[sizeof(SEED)]; uint16_t clen, plen; - ciphertext = malloc(clen = pub_key.modulus.length_B * sizeof(bigint_word_t)); - plaintext = malloc(pub_key.modulus.length_B * sizeof(bigint_word_t)); + if(!keys_allocated){ + load_fix_rsa(); + } + ciphertext = malloc(clen = pub_key.modulus.length_W * sizeof(bigint_word_t)); + plaintext = malloc(pub_key.modulus.length_W * sizeof(bigint_word_t)); memcpy_P(plaintext, MSG, sizeof(MSG)); memcpy_P(seed, SEED, sizeof(SEED)); cli_putstr_P(PSTR("\r\nplaintext:")); - cli_hexdump_block(plaintext, sizeof(MSG), 4, 8); + cli_hexdump_block(plaintext, sizeof(MSG), 4, 16); cli_putstr_P(PSTR("\r\nencrypting: ...")); rc = rsa_encrypt_oaep(ciphertext, &clen, plaintext, sizeof(MSG), &pub_key, NULL, NULL, seed); if(rc){