diff --git a/libwvdrmengine/oemcrypto/ref/src/oemcrypto_session.cpp b/libwvdrmengine/oemcrypto/ref/src/oemcrypto_session.cpp index 714b2521..eb70320d 100644 --- a/libwvdrmengine/oemcrypto/ref/src/oemcrypto_session.cpp +++ b/libwvdrmengine/oemcrypto/ref/src/oemcrypto_session.cpp @@ -636,6 +636,7 @@ OEMCryptoResult SessionContext::LoadKeys( break; } } + encryption_key_.clear(); return OEMCrypto_SUCCESS; } diff --git a/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp b/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp index 21da261c..3674d835 100644 --- a/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp +++ b/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp @@ -871,6 +871,24 @@ TEST_F(OEMCryptoSessionTests, LoadKeyNoNonce) { ASSERT_NO_FATAL_FAILURE(s.LoadTestKeys()); } +// Verify that a second license may be not be loaded in a session. +TEST_F(OEMCryptoSessionTests, LoadKeyNoNonceTwice) { + Session s; + ASSERT_NO_FATAL_FAILURE(s.open()); + ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s)); + ASSERT_NO_FATAL_FAILURE(s.FillSimpleMessage(kDuration, 0, 42)); + ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign()); + ASSERT_NO_FATAL_FAILURE(s.LoadTestKeys()); + ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign()); + ASSERT_NE( + OEMCrypto_SUCCESS, + OEMCrypto_LoadKeys(s.session_id(), s.message_ptr(), s.message_size(), + s.signature().data(), s.signature().size(), + s.enc_mac_keys_iv_substr(), s.enc_mac_keys_substr(), + s.num_keys(), s.key_array(), s.pst_substr(), + GetSubstring(), OEMCrypto_ContentLicense)); +} + // Verify that a license may be loaded with a nonce. TEST_F(OEMCryptoSessionTests, LoadKeyWithNonce) { Session s; @@ -882,6 +900,24 @@ TEST_F(OEMCryptoSessionTests, LoadKeyWithNonce) { ASSERT_NO_FATAL_FAILURE(s.LoadTestKeys()); } +// Verify that a second license may be not be loaded in a session. +TEST_F(OEMCryptoSessionTests, LoadKeyWithNonceTwice) { + Session s; + ASSERT_NO_FATAL_FAILURE(s.open()); + ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s)); + ASSERT_NO_FATAL_FAILURE( + s.FillSimpleMessage(0, wvoec::kControlNonceEnabled, s.get_nonce())); + ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign()); + ASSERT_NO_FATAL_FAILURE(s.LoadTestKeys()); + ASSERT_NE( + OEMCrypto_SUCCESS, + OEMCrypto_LoadKeys(s.session_id(), s.message_ptr(), s.message_size(), + s.signature().data(), s.signature().size(), + s.enc_mac_keys_iv_substr(), s.enc_mac_keys_substr(), + s.num_keys(), s.key_array(), s.pst_substr(), + GetSubstring(), OEMCrypto_ContentLicense)); +} + // This asks for several nonce. This simulates several license requests being // lost. OEMCrypto is required to keep up to four nonce in the nonce table. TEST_F(OEMCryptoSessionTests, LoadKeySeveralNonce) {