|
9 | 9 |
|
10 | 10 | #ifdef LTC_CURVE25519
|
11 | 11 |
|
| 12 | +static void xor_shuffle(char *buf, int size, int change) |
| 13 | +{ |
| 14 | + for(int i = 0; i < size; i++) |
| 15 | + buf[i] ^= change; |
| 16 | +} |
| 17 | + |
12 | 18 | static int s_rfc_8410_10_test(void)
|
13 | 19 | {
|
14 | 20 | const struct {
|
@@ -202,6 +208,13 @@ static int s_rfc_8032_7_1_test(void)
|
202 | 208 | DO(ed25519_verify(msg, mlen, sig, siglen, &ret, &key));
|
203 | 209 | DO(do_compare_testvector(&ret, sizeof(ret), &should, sizeof(should), "Ed25519 RFC8032 7.1 - verify w/ privkey", n));
|
204 | 210 |
|
| 211 | + xor_shuffle(sig, siglen, 0x8); |
| 212 | + DO( ed25519_verify(msg, mlen, sig, siglen, &ret, &key)); |
| 213 | + ENSUREX(ret != 1, "ed25519_verify is expected to fail on the modified signature"); |
| 214 | + xor_shuffle(msg, mlen, 0xf); |
| 215 | + DO( ed25519_verify(msg, mlen, sig, siglen, &ret, &key)); |
| 216 | + ENSUREX(ret != 1, "ed25519_verify is expected to fail on the modified message"); |
| 217 | + |
205 | 218 | plen = sizeof(pub);
|
206 | 219 | DO(base16_decode(rfc_8032_7_1[n].public_key, XSTRLEN(rfc_8032_7_1[n].public_key), pub, &plen));
|
207 | 220 | mlen = sizeof(msg);
|
|
0 commit comments