Skip to content

Commit caf3500

Browse files
SOuajihsjaeckel
authored andcommitted
fix pkcs_1_v1_5_decode() when empty message
In case of EME-PKCS1-v1_5 decoding, the encoded message format is as follow : EM = 0x00 || 0x02 || PS || 0x00 || M. When using an empty message, the 0x00 octet that separates the padding string and message is located at the end. Thus, update the condition to pass the check in case of empty message. This fixes the following AOSP cts test: Module: CtsKeystoreTestCases Test: testEmptyPlaintextEncryptsAndDecrypts Link: https://android.googlesource.com/platform/cts/+/refs/tags/android-cts-12.0_r6/tests/tests/keystore/src/android/keystore/cts/CipherTest.java Signed-off-by: Safae Ouajih <souajih@baylibre.com>
1 parent 05f9407 commit caf3500

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/pk/pkcs1/pkcs_1_v1_5_decode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ int pkcs_1_v1_5_decode(const unsigned char *msg,
5858
}
5959
ps_len = i++ - 2;
6060

61-
if (i >= modulus_len) {
61+
if (i > modulus_len) {
6262
/* There was no octet with hexadecimal value 0x00 to separate ps from m.
6363
*/
6464
result = CRYPT_INVALID_PACKET;

0 commit comments

Comments
 (0)