Fix segfault in EncryptionOperationsTest.RsaPkcs1Success

This test tries to modify an encrypted message to ensure that the
result can't be decrypted, but if encrypting the messsage fails
first then there's nothing to modify.

Bug: None
Test: Ran against a Strongbox implementation that refuses to
      encrypt the message using Digest::NONE
Signed-off-by: Bill Richardson <wfrichar@google.com>
Change-Id: Ib4d389a47702edd56a4e7d2b334dc89d0c3972a1
This commit is contained in:
Bill Richardson 2021-02-24 20:00:31 -06:00
parent 0b12cea833
commit 478715818f

View file

@ -2562,7 +2562,8 @@ TEST_P(EncryptionOperationsTest, RsaPkcs1Success) {
string message = "Hello World!";
auto params = AuthorizationSetBuilder().Padding(PaddingMode::RSA_PKCS1_1_5_ENCRYPT);
string ciphertext1 = EncryptMessage(message, params);
EXPECT_EQ(2048U / 8, ciphertext1.size());
// Die here on failure because we try to modify ciphertext1 below
ASSERT_EQ(2048U / 8, ciphertext1.size()) << "Failed to encrypt the message";
string ciphertext2 = EncryptMessage(message, params);
EXPECT_EQ(2048U / 8, ciphertext2.size());