@@ -1244,7 +1244,7 @@ TEST(XTSTest, TestVectors) {
12441244#endif
12451245}
12461246
1247- TEST (XTSTest, EncryptDecyptRand ) {
1247+ TEST (XTSTest, EncryptDecryptRand ) {
12481248#if defined(OPENSSL_LINUX)
12491249 int pagesize = sysconf (_SC_PAGE_SIZE);
12501250 ASSERT_GE (pagesize, 0 );
@@ -1260,17 +1260,17 @@ const EVP_CIPHER *cipher = EVP_aes_256_xts();
12601260 for (size_t msg_len = 16 ; msg_len < AESXTS_RAND_MSG_MAX_LEN ; msg_len += 1 ) {
12611261
12621262 std::vector<uint8_t > key (EVP_CIPHER_key_length (cipher)), iv (EVP_CIPHER_iv_length (cipher)),
1263- plaintext (msg_len), ciphertext (msg_len), plaintext_test (msg_len);
1263+ plaintext (msg_len), plaintext_test (msg_len);
12641264 RAND_bytes (key.data (), EVP_CIPHER_key_length (cipher));
12651265 RAND_bytes (iv.data (), EVP_CIPHER_iv_length (cipher));
12661266 RAND_bytes (plaintext.data (), msg_len);
1267- OPENSSL_memset (ciphertext.data (), 0 , msg_len);
12681267 OPENSSL_memset (plaintext_test.data (), 0 , msg_len);
12691268
12701269 SCOPED_TRACE (plaintext.size ());
12711270
1272- int len;
1273- uint8_t *in_p, *out_p;
1271+ int len = 0 ;
1272+ size_t decrypted_len = 0 , encrypted_len = 0 ;
1273+ uint8_t *in_p = nullptr , *out_p = nullptr ;
12741274 #if defined(OPENSSL_LINUX)
12751275 ASSERT_GE (pagesize, (int )plaintext.size ());
12761276
@@ -1305,7 +1305,9 @@ const EVP_CIPHER *cipher = EVP_aes_256_xts();
13051305 iv.data ()));
13061306 ASSERT_TRUE (
13071307 EVP_EncryptUpdate (ctx.get (), out_p, &len, in_p, plaintext.size ()));
1308- OPENSSL_memcpy (ciphertext.data (), out_p, plaintext.size ());
1308+
1309+ encrypted_len = len;
1310+ ASSERT_EQ (encrypted_len, plaintext.size ());
13091311
13101312 // Test decryption.
13111313
@@ -1314,10 +1316,14 @@ const EVP_CIPHER *cipher = EVP_aes_256_xts();
13141316 }
13151317
13161318 ctx.Reset ();
1319+ len = 0 ;
13171320 ASSERT_TRUE (EVP_DecryptInit_ex (ctx.get (), cipher, nullptr , key.data (),
13181321 iv.data ()));
13191322 ASSERT_TRUE (
1320- EVP_DecryptUpdate (ctx.get (), in_p, &len, out_p, ciphertext.size ()));
1323+ EVP_DecryptUpdate (ctx.get (), in_p, &len, out_p, plaintext.size ()));
1324+
1325+ decrypted_len = len;
1326+ ASSERT_EQ (decrypted_len, plaintext.size ());
13211327 EXPECT_EQ (Bytes (plaintext), Bytes (in_p, static_cast <size_t >(len)));
13221328 }
13231329 }
0 commit comments