Skip to content

Commit

Permalink
Merge pull request #137 from cppalliance/aesvs
Browse files Browse the repository at this point in the history
Add AESAVS
  • Loading branch information
mborland authored Dec 4, 2024
2 parents 4c4a248 + 1c52b4e commit d0ecf86
Show file tree
Hide file tree
Showing 30 changed files with 18,397 additions and 10 deletions.
25 changes: 16 additions & 9 deletions include/boost/crypt/aes/detail/cipher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,19 @@ BOOST_CRYPT_GPU_ENABLED constexpr auto cipher<Nr>::key_expansion(ForwardIterator
{
boost::crypt::array<boost::crypt::uint8_t, 4> temp {};

// Since we take pointers or iterators the sign of the offset can be incorrect
#if defined(__GNUC__) && __GNUC__ >= 5
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wconversion"
# pragma GCC diagnostic ignored "-Wsign-conversion"
#elif defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wsign-conversion"
#elif defined(_MSC_VER)
# pragma warning( push )
# pragma warning( disable : 4127 ) // Conditional expression is constant (which is true before C++17 in BOOST_CRYPT_IF_CONSTEXPR)
#endif

for (boost::crypt::size_t i {}; i < Nk; ++i)
{
const auto k {i * 4U};
Expand All @@ -355,14 +368,6 @@ BOOST_CRYPT_GPU_ENABLED constexpr auto cipher<Nr>::key_expansion(ForwardIterator
round_key[k + 3U] = key[k + 3U];
}

#if defined(__GNUC__) && __GNUC__ >= 7 && __GNUC__ <= 9
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wconversion"
#elif defined(_MSC_VER)
# pragma warning( push )
# pragma warning( disable : 4127 ) // Conditional expression is constant (which is true before C++17 in BOOST_CRYPT_IF_CONSTEXPR)
#endif

for (boost::crypt::size_t i {Nk}; i < Nb * (Nr + 1); ++i)
{
const auto k {(i - 1) * 4U};
Expand Down Expand Up @@ -392,8 +397,10 @@ BOOST_CRYPT_GPU_ENABLED constexpr auto cipher<Nr>::key_expansion(ForwardIterator
round_key[j + 3U] = round_key[l + 3U] ^ temp[3];
}

#if defined(__GNUC__) && __GNUC__ >= 7 && __GNUC__ <= 9
#if defined(__GNUC__) && __GNUC__ >= 5
# pragma GCC diagnostic pop
#elif defined(__clang__)
# pragma clang diagnostic pop
#elif defined(_MSC_VER)
# pragma warning( pop )
#endif
Expand Down
4 changes: 4 additions & 0 deletions test/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,7 @@ run test_nist_cavs_shake128_variable_output.cpp ;
run test_nist_cavs_shake256_short_long.cpp ;
run test_nist_cavs_shake256_monte.cpp ;
run test_nist_cavs_shake256_variable_output.cpp ;

run test_nist_cavs_aes128_kat.cpp ;
run test_nist_cavs_aes128_mmt.cpp ;
run test_nist_cavs_aes128_mct.cpp ;
81 changes: 81 additions & 0 deletions test/nist_cavs/vectors/aes/ECBGFSbox128.rsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# CAVS 11.1
# Config info for aes_values
# AESVS GFSbox test data for ECB
# State : Encrypt and Decrypt
# Key Length : 128
# Generated on Fri Apr 22 15:11:26 2011

[ENCRYPT]

COUNT = 0
KEY = 00000000000000000000000000000000
PLAINTEXT = f34481ec3cc627bacd5dc3fb08f273e6
CIPHERTEXT = 0336763e966d92595a567cc9ce537f5e

COUNT = 1
KEY = 00000000000000000000000000000000
PLAINTEXT = 9798c4640bad75c7c3227db910174e72
CIPHERTEXT = a9a1631bf4996954ebc093957b234589

COUNT = 2
KEY = 00000000000000000000000000000000
PLAINTEXT = 96ab5c2ff612d9dfaae8c31f30c42168
CIPHERTEXT = ff4f8391a6a40ca5b25d23bedd44a597

COUNT = 3
KEY = 00000000000000000000000000000000
PLAINTEXT = 6a118a874519e64e9963798a503f1d35
CIPHERTEXT = dc43be40be0e53712f7e2bf5ca707209

COUNT = 4
KEY = 00000000000000000000000000000000
PLAINTEXT = cb9fceec81286ca3e989bd979b0cb284
CIPHERTEXT = 92beedab1895a94faa69b632e5cc47ce

COUNT = 5
KEY = 00000000000000000000000000000000
PLAINTEXT = b26aeb1874e47ca8358ff22378f09144
CIPHERTEXT = 459264f4798f6a78bacb89c15ed3d601

COUNT = 6
KEY = 00000000000000000000000000000000
PLAINTEXT = 58c8e00b2631686d54eab84b91f0aca1
CIPHERTEXT = 08a4e2efec8a8e3312ca7460b9040bbf

[DECRYPT]

COUNT = 0
KEY = 00000000000000000000000000000000
CIPHERTEXT = 0336763e966d92595a567cc9ce537f5e
PLAINTEXT = f34481ec3cc627bacd5dc3fb08f273e6

COUNT = 1
KEY = 00000000000000000000000000000000
CIPHERTEXT = a9a1631bf4996954ebc093957b234589
PLAINTEXT = 9798c4640bad75c7c3227db910174e72

COUNT = 2
KEY = 00000000000000000000000000000000
CIPHERTEXT = ff4f8391a6a40ca5b25d23bedd44a597
PLAINTEXT = 96ab5c2ff612d9dfaae8c31f30c42168

COUNT = 3
KEY = 00000000000000000000000000000000
CIPHERTEXT = dc43be40be0e53712f7e2bf5ca707209
PLAINTEXT = 6a118a874519e64e9963798a503f1d35

COUNT = 4
KEY = 00000000000000000000000000000000
CIPHERTEXT = 92beedab1895a94faa69b632e5cc47ce
PLAINTEXT = cb9fceec81286ca3e989bd979b0cb284

COUNT = 5
KEY = 00000000000000000000000000000000
CIPHERTEXT = 459264f4798f6a78bacb89c15ed3d601
PLAINTEXT = b26aeb1874e47ca8358ff22378f09144

COUNT = 6
KEY = 00000000000000000000000000000000
CIPHERTEXT = 08a4e2efec8a8e3312ca7460b9040bbf
PLAINTEXT = 58c8e00b2631686d54eab84b91f0aca1

80 changes: 80 additions & 0 deletions test/nist_cavs/vectors/aes/ECBGFSbox128_20.rsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# CAVS 20.2
# Config info for Axway API RHLinux6_VM
# AESVS GFSbox test data for ECB
# State : Encrypt and Decrypt
# Key Length : 128
# Generated on Wed Oct 05 10:33:48 2016

[ENCRYPT]

COUNT = 0
KEY = 00000000000000000000000000000000
PLAINTEXT = f34481ec3cc627bacd5dc3fb08f273e6
CIPHERTEXT = 0336763e966d92595a567cc9ce537f5e

COUNT = 1
KEY = 00000000000000000000000000000000
PLAINTEXT = 9798c4640bad75c7c3227db910174e72
CIPHERTEXT = a9a1631bf4996954ebc093957b234589

COUNT = 2
KEY = 00000000000000000000000000000000
PLAINTEXT = 96ab5c2ff612d9dfaae8c31f30c42168
CIPHERTEXT = ff4f8391a6a40ca5b25d23bedd44a597

COUNT = 3
KEY = 00000000000000000000000000000000
PLAINTEXT = 6a118a874519e64e9963798a503f1d35
CIPHERTEXT = dc43be40be0e53712f7e2bf5ca707209

COUNT = 4
KEY = 00000000000000000000000000000000
PLAINTEXT = cb9fceec81286ca3e989bd979b0cb284
CIPHERTEXT = 92beedab1895a94faa69b632e5cc47ce

COUNT = 5
KEY = 00000000000000000000000000000000
PLAINTEXT = b26aeb1874e47ca8358ff22378f09144
CIPHERTEXT = 459264f4798f6a78bacb89c15ed3d601

COUNT = 6
KEY = 00000000000000000000000000000000
PLAINTEXT = 58c8e00b2631686d54eab84b91f0aca1
CIPHERTEXT = 08a4e2efec8a8e3312ca7460b9040bbf

[DECRYPT]

COUNT = 0
KEY = 00000000000000000000000000000000
CIPHERTEXT = 0336763e966d92595a567cc9ce537f5e
PLAINTEXT = f34481ec3cc627bacd5dc3fb08f273e6

COUNT = 1
KEY = 00000000000000000000000000000000
CIPHERTEXT = a9a1631bf4996954ebc093957b234589
PLAINTEXT = 9798c4640bad75c7c3227db910174e72

COUNT = 2
KEY = 00000000000000000000000000000000
CIPHERTEXT = ff4f8391a6a40ca5b25d23bedd44a597
PLAINTEXT = 96ab5c2ff612d9dfaae8c31f30c42168

COUNT = 3
KEY = 00000000000000000000000000000000
CIPHERTEXT = dc43be40be0e53712f7e2bf5ca707209
PLAINTEXT = 6a118a874519e64e9963798a503f1d35

COUNT = 4
KEY = 00000000000000000000000000000000
CIPHERTEXT = 92beedab1895a94faa69b632e5cc47ce
PLAINTEXT = cb9fceec81286ca3e989bd979b0cb284

COUNT = 5
KEY = 00000000000000000000000000000000
CIPHERTEXT = 459264f4798f6a78bacb89c15ed3d601
PLAINTEXT = b26aeb1874e47ca8358ff22378f09144

COUNT = 6
KEY = 00000000000000000000000000000000
CIPHERTEXT = 08a4e2efec8a8e3312ca7460b9040bbf
PLAINTEXT = 58c8e00b2631686d54eab84b91f0aca1
71 changes: 71 additions & 0 deletions test/nist_cavs/vectors/aes/ECBGFSbox192.rsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# CAVS 11.1
# Config info for aes_values
# AESVS GFSbox test data for ECB
# State : Encrypt and Decrypt
# Key Length : 192
# Generated on Fri Apr 22 15:11:28 2011

[ENCRYPT]

COUNT = 0
KEY = 000000000000000000000000000000000000000000000000
PLAINTEXT = 1b077a6af4b7f98229de786d7516b639
CIPHERTEXT = 275cfc0413d8ccb70513c3859b1d0f72

COUNT = 1
KEY = 000000000000000000000000000000000000000000000000
PLAINTEXT = 9c2d8842e5f48f57648205d39a239af1
CIPHERTEXT = c9b8135ff1b5adc413dfd053b21bd96d

COUNT = 2
KEY = 000000000000000000000000000000000000000000000000
PLAINTEXT = bff52510095f518ecca60af4205444bb
CIPHERTEXT = 4a3650c3371ce2eb35e389a171427440

COUNT = 3
KEY = 000000000000000000000000000000000000000000000000
PLAINTEXT = 51719783d3185a535bd75adc65071ce1
CIPHERTEXT = 4f354592ff7c8847d2d0870ca9481b7c

COUNT = 4
KEY = 000000000000000000000000000000000000000000000000
PLAINTEXT = 26aa49dcfe7629a8901a69a9914e6dfd
CIPHERTEXT = d5e08bf9a182e857cf40b3a36ee248cc

COUNT = 5
KEY = 000000000000000000000000000000000000000000000000
PLAINTEXT = 941a4773058224e1ef66d10e0a6ee782
CIPHERTEXT = 067cd9d3749207791841562507fa9626

[DECRYPT]

COUNT = 0
KEY = 000000000000000000000000000000000000000000000000
CIPHERTEXT = 275cfc0413d8ccb70513c3859b1d0f72
PLAINTEXT = 1b077a6af4b7f98229de786d7516b639

COUNT = 1
KEY = 000000000000000000000000000000000000000000000000
CIPHERTEXT = c9b8135ff1b5adc413dfd053b21bd96d
PLAINTEXT = 9c2d8842e5f48f57648205d39a239af1

COUNT = 2
KEY = 000000000000000000000000000000000000000000000000
CIPHERTEXT = 4a3650c3371ce2eb35e389a171427440
PLAINTEXT = bff52510095f518ecca60af4205444bb

COUNT = 3
KEY = 000000000000000000000000000000000000000000000000
CIPHERTEXT = 4f354592ff7c8847d2d0870ca9481b7c
PLAINTEXT = 51719783d3185a535bd75adc65071ce1

COUNT = 4
KEY = 000000000000000000000000000000000000000000000000
CIPHERTEXT = d5e08bf9a182e857cf40b3a36ee248cc
PLAINTEXT = 26aa49dcfe7629a8901a69a9914e6dfd

COUNT = 5
KEY = 000000000000000000000000000000000000000000000000
CIPHERTEXT = 067cd9d3749207791841562507fa9626
PLAINTEXT = 941a4773058224e1ef66d10e0a6ee782

61 changes: 61 additions & 0 deletions test/nist_cavs/vectors/aes/ECBGFSbox256.rsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# CAVS 11.1
# Config info for aes_values
# AESVS GFSbox test data for ECB
# State : Encrypt and Decrypt
# Key Length : 256
# Generated on Fri Apr 22 15:11:30 2011

[ENCRYPT]

COUNT = 0
KEY = 0000000000000000000000000000000000000000000000000000000000000000
PLAINTEXT = 014730f80ac625fe84f026c60bfd547d
CIPHERTEXT = 5c9d844ed46f9885085e5d6a4f94c7d7

COUNT = 1
KEY = 0000000000000000000000000000000000000000000000000000000000000000
PLAINTEXT = 0b24af36193ce4665f2825d7b4749c98
CIPHERTEXT = a9ff75bd7cf6613d3731c77c3b6d0c04

COUNT = 2
KEY = 0000000000000000000000000000000000000000000000000000000000000000
PLAINTEXT = 761c1fe41a18acf20d241650611d90f1
CIPHERTEXT = 623a52fcea5d443e48d9181ab32c7421

COUNT = 3
KEY = 0000000000000000000000000000000000000000000000000000000000000000
PLAINTEXT = 8a560769d605868ad80d819bdba03771
CIPHERTEXT = 38f2c7ae10612415d27ca190d27da8b4

COUNT = 4
KEY = 0000000000000000000000000000000000000000000000000000000000000000
PLAINTEXT = 91fbef2d15a97816060bee1feaa49afe
CIPHERTEXT = 1bc704f1bce135ceb810341b216d7abe

[DECRYPT]

COUNT = 0
KEY = 0000000000000000000000000000000000000000000000000000000000000000
CIPHERTEXT = 5c9d844ed46f9885085e5d6a4f94c7d7
PLAINTEXT = 014730f80ac625fe84f026c60bfd547d

COUNT = 1
KEY = 0000000000000000000000000000000000000000000000000000000000000000
CIPHERTEXT = a9ff75bd7cf6613d3731c77c3b6d0c04
PLAINTEXT = 0b24af36193ce4665f2825d7b4749c98

COUNT = 2
KEY = 0000000000000000000000000000000000000000000000000000000000000000
CIPHERTEXT = 623a52fcea5d443e48d9181ab32c7421
PLAINTEXT = 761c1fe41a18acf20d241650611d90f1

COUNT = 3
KEY = 0000000000000000000000000000000000000000000000000000000000000000
CIPHERTEXT = 38f2c7ae10612415d27ca190d27da8b4
PLAINTEXT = 8a560769d605868ad80d819bdba03771

COUNT = 4
KEY = 0000000000000000000000000000000000000000000000000000000000000000
CIPHERTEXT = 1bc704f1bce135ceb810341b216d7abe
PLAINTEXT = 91fbef2d15a97816060bee1feaa49afe

Loading

0 comments on commit d0ecf86

Please sign in to comment.