diff --git a/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp b/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp index 99a7906d..f88518ec 100644 --- a/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp +++ b/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp @@ -579,20 +579,24 @@ TEST_F(OEMCryptoProv30Test, OEMCertForbiddenPaddingScheme) { vector data(500); GetRandBytes(&data[0], data.size()); size_t signature_length = 0; - vector signature(1); + // We need a size one vector to pass as a pointer. + vector signature(1, 0); + vector zero(1, 0); sts = OEMCrypto_GenerateRSASignature(s.session_id(), &data[0], data.size(), &signature[0], &signature_length, kSign_PKCS1_Block1); if (OEMCrypto_ERROR_SHORT_BUFFER == sts) { + // The OEMCrypto could complain about buffer length first, so let's + // resize and check if it's writing to the signature again. signature.resize(signature_length, 0); + zero.resize(signature_length, 0); sts = OEMCrypto_GenerateRSASignature(s.session_id(), &data[0], data.size(), &signature[0], &signature_length, kSign_PKCS1_Block1); } EXPECT_NE(OEMCrypto_SUCCESS, sts) << "OEM Cert Signed with forbidden kSign_PKCS1_Block1."; - vector zero(signature_length, 0); ASSERT_EQ(zero, signature); // signature should not be computed. }