Merge "keymaster: spec does not require that update produce output" into pi-dev

am: 409b5fd5fb

Change-Id: Ieb194a3116abcfee249c2033ed346aa7151fc26c
This commit is contained in:
nagendra modadugu 2018-06-26 17:05:10 -07:00 committed by android-build-merger
commit c7d39cf9ac

View file

@ -3005,6 +3005,7 @@ TEST_F(EncryptionOperationsTest, AesGcmAadNoData) {
* Verifies that AES GCM mode works when provided additional authenticated data in multiple chunks.
*/
TEST_F(EncryptionOperationsTest, AesGcmMultiPartAad) {
const size_t tag_bits = 128;
ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
.Authorization(TAG_NO_AUTH_REQUIRED)
.AesEncryptionKey(128)
@ -3016,7 +3017,7 @@ TEST_F(EncryptionOperationsTest, AesGcmMultiPartAad) {
auto begin_params = AuthorizationSetBuilder()
.BlockMode(BlockMode::GCM)
.Padding(PaddingMode::NONE)
.Authorization(TAG_MAC_LENGTH, 128);
.Authorization(TAG_MAC_LENGTH, tag_bits);
AuthorizationSet begin_out_params;
auto update_params =
@ -3038,10 +3039,11 @@ TEST_F(EncryptionOperationsTest, AesGcmMultiPartAad) {
EXPECT_EQ(ErrorCode::OK, Update(op_handle_, update_params, message, &update_out_params,
&ciphertext, &input_consumed));
EXPECT_EQ(message.size(), input_consumed);
EXPECT_EQ(message.size(), ciphertext.size());
EXPECT_TRUE(update_out_params.empty());
EXPECT_EQ(ErrorCode::OK, Finish("" /* input */, &ciphertext));
// Expect 128-bit (16-byte) tag appended to ciphertext.
EXPECT_EQ(message.size() + (tag_bits >> 3), ciphertext.size());
// Grab nonce.
begin_params.push_back(begin_out_params);
@ -3097,7 +3099,6 @@ TEST_F(EncryptionOperationsTest, AesGcmAadOutOfOrder) {
EXPECT_EQ(ErrorCode::OK, Update(op_handle_, update_params, message, &update_out_params,
&ciphertext, &input_consumed));
EXPECT_EQ(message.size(), input_consumed);
EXPECT_EQ(message.size(), ciphertext.size());
EXPECT_TRUE(update_out_params.empty());
// More AAD