udpate bleichenbacher signature attack
also test for too short padding strings
This commit is contained in:
parent
e227000578
commit
2b3c603c6c
@ -104,7 +104,7 @@ int rsa_test(void)
|
|||||||
{
|
{
|
||||||
unsigned char in[1024], out[1024], tmp[1024];
|
unsigned char in[1024], out[1024], tmp[1024];
|
||||||
rsa_key key, privKey, pubKey;
|
rsa_key key, privKey, pubKey;
|
||||||
int hash_idx, prng_idx, stat, stat2;
|
int hash_idx, prng_idx, stat, stat2, i;
|
||||||
unsigned long rsa_msgsize, len, len2, len3, cnt, cnt2;
|
unsigned long rsa_msgsize, len, len2, len3, cnt, cnt2;
|
||||||
static unsigned char lparam[] = { 0x01, 0x02, 0x03, 0x04 };
|
static unsigned char lparam[] = { 0x01, 0x02, 0x03, 0x04 };
|
||||||
|
|
||||||
@ -361,6 +361,7 @@ for (cnt = 0; cnt < len; ) {
|
|||||||
unsigned char* p = in;
|
unsigned char* p = in;
|
||||||
unsigned char* p2 = out;
|
unsigned char* p2 = out;
|
||||||
unsigned char* p3 = tmp;
|
unsigned char* p3 = tmp;
|
||||||
|
for (i = 0; i < 9; ++i) {
|
||||||
len = sizeof(in);
|
len = sizeof(in);
|
||||||
len2 = sizeof(out);
|
len2 = sizeof(out);
|
||||||
cnt = rsa_get_size(&key);
|
cnt = rsa_get_size(&key);
|
||||||
@ -391,9 +392,9 @@ for (cnt = 0; cnt < len; ) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* (4.2) */
|
/* (4.2) */
|
||||||
memmove(&p3[cnt+1], &p3[cnt2], len3-cnt2);
|
memmove(&p3[cnt+i], &p3[cnt2], len3-cnt2);
|
||||||
/* (4.3) */
|
/* (4.3) */
|
||||||
for (cnt = cnt + len3-cnt2+1; cnt < len; ++cnt) {
|
for (cnt = cnt + len3-cnt2+i; cnt < len; ++cnt) {
|
||||||
do {
|
do {
|
||||||
p3[cnt] = (unsigned char)rand();
|
p3[cnt] = (unsigned char)rand();
|
||||||
} while (p3[cnt] == 0);
|
} while (p3[cnt] == 0);
|
||||||
@ -414,8 +415,13 @@ for (cnt = 0; cnt < len; ) {
|
|||||||
|
|
||||||
len3 = sizeof(tmp);
|
len3 = sizeof(tmp);
|
||||||
/* (6) */
|
/* (6) */
|
||||||
|
if (i < 8)
|
||||||
|
DOX(rsa_verify_hash_ex(p2, len2, p, 20, LTC_PKCS_1_V1_5, hash_idx, -1, &stat, &pubKey)
|
||||||
|
== CRYPT_INVALID_PACKET ? CRYPT_OK:CRYPT_INVALID_PACKET, "should fail");
|
||||||
|
else
|
||||||
DOX(rsa_verify_hash_ex(p2, len2, p, 20, LTC_PKCS_1_V1_5, hash_idx, -1, &stat, &pubKey), "should succeed");
|
DOX(rsa_verify_hash_ex(p2, len2, p, 20, LTC_PKCS_1_V1_5, hash_idx, -1, &stat, &pubKey), "should succeed");
|
||||||
DOX(stat == 0?CRYPT_OK:CRYPT_FAIL_TESTVECTOR, "should fail");
|
DOX(stat == 0?CRYPT_OK:CRYPT_FAIL_TESTVECTOR, "should fail");
|
||||||
|
}
|
||||||
|
|
||||||
/* free the key and return */
|
/* free the key and return */
|
||||||
rsa_free(&key);
|
rsa_free(&key);
|
||||||
|
Loading…
Reference in New Issue
Block a user