X-Git-Url: https://git.cryptolib.org/?p=arm-crypto-lib.git;a=blobdiff_plain;f=rsa%2Frsa_pkcs15.c;h=858b91886476fb22bf405aeb85e61aea34ff0d12;hp=359801eb30a070ba896853f078a98cb06b15be7b;hb=73f474e8fea34667e788ff4ec24de552e9d1d9e8;hpb=6095187b080b960d111a54f18a3b2da788d2d59d diff --git a/rsa/rsa_pkcs15.c b/rsa/rsa_pkcs15.c index 359801e..858b918 100644 --- a/rsa/rsa_pkcs15.c +++ b/rsa/rsa_pkcs15.c @@ -23,8 +23,12 @@ #include "bigint.h" #include "rsa_basic.h" +#define DEBUG 0 + +#if DEBUG #include "bigint_io.h" #include "cli.h" +#endif #include "random_dummy.h" @@ -34,8 +38,10 @@ uint8_t rsa_encrypt_pkcs15(void* dest, uint16_t* out_length, const void* src, bigint_t x; pad_length = (bigint_get_first_set_bit(key->modulus) + 7) / 8 - length_B - 3; if(pad_length<8){ +#if DEBUG cli_putstr("\r\nERROR: pad_length<8; pad_length: "); cli_hexdump_rev(&pad_length, 2); +#endif return 2; /* message to long */ } if(!pad){ @@ -69,9 +75,13 @@ uint8_t rsa_decrypt_pkcs15(void* dest, uint16_t* out_length, const void* src, uint16_t m_length, pad_length=0, idx=0; x.wordv = dest; rsa_os2ip(&x, src, length_B); +#if DEBUG cli_putstr("\r\ncalling rsa_dec() ..."); +#endif rsa_dec(&x, key); +#if DEBUG cli_putstr("\r\nfinished rsa_dec() ..."); +#endif rsa_i2osp(NULL, &x, &m_length); while(((uint8_t*)x.wordv)[idx]==0 && idx