Check set_encrypt_key return value in AESTest.ABI.

On aarch64 and x86_64 ABIs, the unused bits of 32-bit parameters have
unspecified value. That means if, say, the aarch64
aes_hw_set_encrypt_key accessed the 'bits' parameter as X1 rather than
W1, it could get a different value from what C passed in. To test this,
our ABI testing framework fills the upper half of the register with
garbage.  However, set_encrypt_key just cleanly returns error on
unrecognized bit length. So, to check that this all worked correctly, we
need to assert that the return value was correct.

Looking at the assembly, they all handle it correctly, but now we'll
also test it.

(Note these functions break the usual convention and use zero as the
success value.)

Change-Id: Icaf65ea54564ebfe3696b42287488fe3f72ef138
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/54205
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Bob Beck <bbe@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
Reviewed-by: Bob Beck <bbe@google.com>
chromium-5359
David Benjamin 3 years ago committed by Boringssl LUCI CQ
parent 10fef972e4
commit 34e474f794
  1. 12
      crypto/fipsmodule/aes/aes_test.cc

@ -289,7 +289,7 @@ TEST(AESTest, ABI) {
}
if (bsaes_capable()) {
vpaes_set_encrypt_key(kKey, bits, &key);
ASSERT_EQ(vpaes_set_encrypt_key(kKey, bits, &key), 0);
CHECK_ABI(vpaes_encrypt_key_to_bsaes, &key, &key);
for (size_t blocks : block_counts) {
SCOPED_TRACE(blocks);
@ -298,7 +298,7 @@ TEST(AESTest, ABI) {
}
}
vpaes_set_decrypt_key(kKey, bits, &key);
ASSERT_EQ(vpaes_set_decrypt_key(kKey, bits, &key), 0);
CHECK_ABI(vpaes_decrypt_key_to_bsaes, &key, &key);
for (size_t blocks : block_counts) {
SCOPED_TRACE(blocks);
@ -308,7 +308,7 @@ TEST(AESTest, ABI) {
}
if (vpaes_capable()) {
CHECK_ABI(vpaes_set_encrypt_key, kKey, bits, &key);
ASSERT_EQ(CHECK_ABI(vpaes_set_encrypt_key, kKey, bits, &key), 0);
CHECK_ABI(vpaes_encrypt, block, block, &key);
for (size_t blocks : block_counts) {
SCOPED_TRACE(blocks);
@ -321,7 +321,7 @@ TEST(AESTest, ABI) {
#endif
}
CHECK_ABI(vpaes_set_decrypt_key, kKey, bits, &key);
ASSERT_EQ(CHECK_ABI(vpaes_set_decrypt_key, kKey, bits, &key), 0);
CHECK_ABI(vpaes_decrypt, block, block, &key);
#if defined(VPAES_CBC)
for (size_t blocks : block_counts) {
@ -333,7 +333,7 @@ TEST(AESTest, ABI) {
}
if (hwaes_capable()) {
CHECK_ABI(aes_hw_set_encrypt_key, kKey, bits, &key);
ASSERT_EQ(CHECK_ABI(aes_hw_set_encrypt_key, kKey, bits, &key), 0);
CHECK_ABI(aes_hw_encrypt, block, block, &key);
for (size_t blocks : block_counts) {
SCOPED_TRACE(blocks);
@ -346,7 +346,7 @@ TEST(AESTest, ABI) {
#endif
}
CHECK_ABI(aes_hw_set_decrypt_key, kKey, bits, &key);
ASSERT_EQ(CHECK_ABI(aes_hw_set_decrypt_key, kKey, bits, &key), 0);
CHECK_ABI(aes_hw_decrypt, block, block, &key);
for (size_t blocks : block_counts) {
SCOPED_TRACE(blocks);

Loading…
Cancel
Save