Skip to content

Commit 9eaa6c2

Browse files
committed
wo#7449 . verify padding contents for IKEv2 RSA sig check
Special thanks to Sze Yiu Chau of Purdue University ([email protected]) who reported the issue.
1 parent d28ef9e commit 9eaa6c2

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

lib/liboswkeys/signatures.c

+15-2
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,21 @@ err_t verify_signed_hash(const struct RSA_public_key *k
157157
return "3""SIG padding does not check out";
158158
}
159159

160-
s += padlen + 3;
161-
(*psig) = s;
160+
/* signature starts after ASN wrapped padding [00,01,FF..FF,00] */
161+
(*psig) = s + padlen + 3;
162+
163+
/* verify padding contents */
164+
{
165+
const u_char *p;
166+
size_t cnt_ffs = 0;
167+
168+
for (p = s+2; p < s+padlen+2; p++)
169+
if (*p == 0xFF)
170+
cnt_ffs ++;
171+
172+
if (cnt_ffs != padlen)
173+
return "4" "invalid Padding String";
174+
}
162175

163176
/* return SUCCESS */
164177
return NULL;

0 commit comments

Comments
 (0)