From 7f9bff5ef5ae6048a6e3df9ded94d4b501a0c56d Mon Sep 17 00:00:00 2001 From: Fred Gylys-Colwell Date: Tue, 6 May 2014 17:54:18 -0700 Subject: [PATCH] Correct message size in call to OEMCrypto_RewrapDeviceRSAKey This is a copy of https://widevine-internal-review.googlesource.com/#/c/10040/ The message size was wrong on several OEMCrypto_RewrapDeviceRSAKey unit tests. The function was supposed to fail in these tests. However, a vendor found that they were failing with a different error code because the buffer size was incorrect. Now the function should fail with the correct error code, and the test should pass for the vendor. Change-Id: Iea27b489f9bc386241d9add4f99ccb50560dfef6 --- .../oemcrypto/test/oemcrypto_test.cpp | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp b/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp index 7899868c..d9b95925 100644 --- a/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp +++ b/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp @@ -2631,7 +2631,7 @@ TEST_F(DISABLED_TestKeybox, CertificateProvisionBadRange1) { size_t wrapped_key_length = 0; ASSERT_EQ(OEMCrypto_ERROR_SHORT_BUFFER, OEMCrypto_RewrapDeviceRSAKey( - s.session_id(), message_ptr, sizeof(MessageData), &signature[0], + s.session_id(), message_ptr, sizeof(encrypted), &signature[0], signature.size(), &encrypted.nonce, encrypted.rsa_key, encrypted.rsa_key_length, encrypted.rsa_key_iv, NULL, &wrapped_key_length)); @@ -2641,7 +2641,7 @@ TEST_F(DISABLED_TestKeybox, CertificateProvisionBadRange1) { ASSERT_NE( OEMCrypto_SUCCESS, OEMCrypto_RewrapDeviceRSAKey( - s.session_id(), message_ptr, sizeof(MessageData), &signature[0], + s.session_id(), message_ptr, sizeof(encrypted), &signature[0], signature.size(), &nonce, encrypted.rsa_key, encrypted.rsa_key_length, encrypted.rsa_key_iv, &(wrapped_key.front()), &wrapped_key_length)); } @@ -2659,7 +2659,7 @@ TEST_F(DISABLED_TestKeybox, CertificateProvisionBadRange2) { size_t wrapped_key_length = 0; ASSERT_EQ(OEMCrypto_ERROR_SHORT_BUFFER, OEMCrypto_RewrapDeviceRSAKey( - s.session_id(), message_ptr, sizeof(MessageData), &signature[0], + s.session_id(), message_ptr, sizeof(encrypted), &signature[0], signature.size(), &encrypted.nonce, encrypted.rsa_key, encrypted.rsa_key_length, encrypted.rsa_key_iv, NULL, &wrapped_key_length)); @@ -2670,7 +2670,7 @@ TEST_F(DISABLED_TestKeybox, CertificateProvisionBadRange2) { ASSERT_NE(OEMCrypto_SUCCESS, OEMCrypto_RewrapDeviceRSAKey( - s.session_id(), message_ptr, sizeof(MessageData), &signature[0], + s.session_id(), message_ptr, sizeof(encrypted), &signature[0], signature.size(), &encrypted.nonce, &bad_buffer[0], encrypted.rsa_key_length, encrypted.rsa_key_iv, &(wrapped_key.front()), &wrapped_key_length)); @@ -2690,7 +2690,7 @@ TEST_F(DISABLED_TestKeybox, CertificateProvisionBadRange3) { size_t wrapped_key_length = 0; ASSERT_EQ(OEMCrypto_ERROR_SHORT_BUFFER, OEMCrypto_RewrapDeviceRSAKey( - s.session_id(), message_ptr, sizeof(MessageData), &signature[0], + s.session_id(), message_ptr, sizeof(encrypted), &signature[0], signature.size(), &encrypted.nonce, encrypted.rsa_key, encrypted.rsa_key_length, encrypted.rsa_key_iv, NULL, &wrapped_key_length)); @@ -2701,7 +2701,7 @@ TEST_F(DISABLED_TestKeybox, CertificateProvisionBadRange3) { ASSERT_NE(OEMCrypto_SUCCESS, OEMCrypto_RewrapDeviceRSAKey( - s.session_id(), message_ptr, sizeof(MessageData), &signature[0], + s.session_id(), message_ptr, sizeof(encrypted), &signature[0], signature.size(), &encrypted.nonce, encrypted.rsa_key, encrypted.rsa_key_length, &bad_buffer[0], &(wrapped_key.front()), &wrapped_key_length)); @@ -2721,7 +2721,7 @@ TEST_F(DISABLED_TestKeybox, CertificateProvisionBadSignature) { size_t wrapped_key_length = 0; ASSERT_EQ(OEMCrypto_ERROR_SHORT_BUFFER, OEMCrypto_RewrapDeviceRSAKey( - s.session_id(), message_ptr, sizeof(MessageData), &signature[0], + s.session_id(), message_ptr, sizeof(encrypted), &signature[0], signature.size(), &encrypted.nonce, encrypted.rsa_key, encrypted.rsa_key_length, encrypted.rsa_key_iv, NULL, &wrapped_key_length)); @@ -2730,7 +2730,7 @@ TEST_F(DISABLED_TestKeybox, CertificateProvisionBadSignature) { signature[4] ^= 42; // bad signature. ASSERT_NE(OEMCrypto_SUCCESS, OEMCrypto_RewrapDeviceRSAKey( - s.session_id(), message_ptr, sizeof(MessageData), &signature[0], + s.session_id(), message_ptr, sizeof(encrypted), &signature[0], signature.size(), &encrypted.nonce, encrypted.rsa_key, encrypted.rsa_key_length, encrypted.rsa_key_iv, &(wrapped_key.front()), &wrapped_key_length)); @@ -2750,7 +2750,7 @@ TEST_F(DISABLED_TestKeybox, CertificateProvisionBadNonce) { size_t wrapped_key_length = 0; ASSERT_EQ(OEMCrypto_ERROR_SHORT_BUFFER, OEMCrypto_RewrapDeviceRSAKey( - s.session_id(), message_ptr, sizeof(MessageData), &signature[0], + s.session_id(), message_ptr, sizeof(encrypted), &signature[0], signature.size(), &encrypted.nonce, encrypted.rsa_key, encrypted.rsa_key_length, encrypted.rsa_key_iv, NULL, &wrapped_key_length)); @@ -2759,7 +2759,7 @@ TEST_F(DISABLED_TestKeybox, CertificateProvisionBadNonce) { encrypted.nonce ^= 42; // Almost surely a bad nonce. ASSERT_NE(OEMCrypto_SUCCESS, OEMCrypto_RewrapDeviceRSAKey( - s.session_id(), message_ptr, sizeof(MessageData), &signature[0], + s.session_id(), message_ptr, sizeof(encrypted), &signature[0], signature.size(), &encrypted.nonce, encrypted.rsa_key, encrypted.rsa_key_length, encrypted.rsa_key_iv, &(wrapped_key.front()), &wrapped_key_length)); @@ -2779,7 +2779,7 @@ TEST_F(DISABLED_TestKeybox, CertificateProvisionBadRSAKey) { size_t wrapped_key_length = 0; ASSERT_EQ(OEMCrypto_ERROR_SHORT_BUFFER, OEMCrypto_RewrapDeviceRSAKey( - s.session_id(), message_ptr, sizeof(MessageData), &signature[0], + s.session_id(), message_ptr, sizeof(encrypted), &signature[0], signature.size(), &encrypted.nonce, encrypted.rsa_key, encrypted.rsa_key_length, encrypted.rsa_key_iv, NULL, &wrapped_key_length)); @@ -2788,7 +2788,7 @@ TEST_F(DISABLED_TestKeybox, CertificateProvisionBadRSAKey) { encrypted.rsa_key[1] ^= 42; // Almost surely a bad key. ASSERT_NE(OEMCrypto_SUCCESS, OEMCrypto_RewrapDeviceRSAKey( - s.session_id(), message_ptr, sizeof(MessageData), &signature[0], + s.session_id(), message_ptr, sizeof(encrypted), &signature[0], signature.size(), &encrypted.nonce, encrypted.rsa_key, encrypted.rsa_key_length, encrypted.rsa_key_iv, &(wrapped_key.front()), &wrapped_key_length));