Verify RSA type 1 padding.

This commit is contained in:
John Safranek
2014-09-09 15:35:54 -07:00
parent 6175a2a20c
commit ddeb1bb9f7

View File

@ -174,9 +174,14 @@ static int RsaUnPad(const byte *pkcsBlock, unsigned int pkcsBlockLen,
/* Require block type padValue */
invalid = (pkcsBlock[0] != padValue) || invalid;
/* skip past the padding until we find the separator */
while (i<pkcsBlockLen && pkcsBlock[i++]) { /* null body */
}
/* verify the padding until we find the separator */
if (padValue == RSA_BLOCK_TYPE_1) {
while (i<pkcsBlockLen && pkcsBlock[i++] == 0xFF) {/* Null body */}
}
else {
while (i<pkcsBlockLen && pkcsBlock[i++]) {/* Null body */}
}
if(!(i==pkcsBlockLen || pkcsBlock[i-1]==0)) {
CYASSL_MSG("RsaUnPad error, bad formatting");
return RSA_PAD_E;