-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
aes-gcm: update to use cipher interface #78
- modifies the GCM mode implementation to use the interface - replaces AES_GCM with separate instantiations of the GCM functor for our AES's of interest, and an independent test file -
- Loading branch information
Showing
5 changed files
with
121 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
Primitive/Symmetric/Cipher/Authenticated/Instantiations/AES128_GCM.cry
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* Instantiate GCM mode for AES 128. | ||
* | ||
* @copyright Galois, Inc. | ||
* @author Marcella Hastings <[email protected]> | ||
*/ | ||
module Primitive::Symmetric::Cipher::Authenticated::Instantiations::AES128_GCM = | ||
Primitive::Symmetric::Cipher::Authenticated::GCM { | ||
Primitive::Symmetric::Cipher::Block::AES128 | ||
} | ||
|
11 changes: 11 additions & 0 deletions
11
Primitive/Symmetric/Cipher/Authenticated/Instantiations/AES256_GCM.cry
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* Instantiate GCM mode for AES 256. | ||
* | ||
* @copyright Galois, Inc. | ||
* @author Marcella Hastings <[email protected]> | ||
*/ | ||
module Primitive::Symmetric::Cipher::Authenticated::Instantiations::AES256_GCM = | ||
Primitive::Symmetric::Cipher::Authenticated::GCM { | ||
Primitive::Symmetric::Cipher::Block::AES256 | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,35 @@ | ||
:l AES_GCM.cry | ||
:l Tests/TestAES_GCM.cry | ||
|
||
:prove AES_GCM_test_vector_0 | ||
:prove AES_GCM_test_vector_1 | ||
:prove AES_GCM_test_vector_2 | ||
:prove AES_GCM_test_vector_3 | ||
:prove AES_GCM_test_vector_4 | ||
:prove AES_GCM_invalid_test_vector | ||
:prove aes128_vector_0 | ||
:prove aes128_vector_1 | ||
:prove aes128_vector_2 | ||
:prove aes128_vector_3 | ||
|
||
:prove aes256_vector_0 | ||
:prove aes256_invalid_vector_1 | ||
|
||
// The following checks do not really provide any significant formal | ||
// verification because they check so little of the sample space. | ||
// They each take a long time to `:prove` and would likely require | ||
// manual modification to prove in a reasonable amount of time. | ||
|
||
// These properties can be checked manually; one of the APIs calls the other. | ||
// They take more than an hour to `:prove`. | ||
:check aesGcmDecryptionApisAreEquivalent | ||
:check aesGcmEncryptionApisAreEquivalent | ||
|
||
// This property is independent of the type parameters but we have to specify | ||
// them anyway. | ||
// It takes more than 25 minutes to `:prove`. | ||
:check dotAndMultAreEquivalent `{K=128, IV=96, AAD=0, T=128} {E=AES128::encrypt} | ||
:l Instantiations/AES128_GCM.cry | ||
|
||
// Make sure that decryption is the inverse of encryption | ||
// This property takes more than 20 minutes to `:prove`. | ||
// It's also spot-checked in the test vectors | ||
:check aesGcmIsSymmetric | ||
// Here, we just pick a fixed set of parameters, but it should be true | ||
// for all valid tag, aad, and plaintext lengths. | ||
// - P = 256 because we want to test the block chaining, so we need at least 2 | ||
// - IV = 96 because it's the shortest allowable value | ||
// - AAD = 5 because we want to make sure it's incorporated | ||
:check gcmIsSymmetric `{AAD=5, P=256, IV=96} | ||
|
||
// This takes more than 25 minutes to `:prove`. | ||
:check dotAndMultAreEquivalent | ||
|
||
// Repeat the above checks for AES256 | ||
:l Instantiations/AES256_GCM.cry | ||
:check gcmIsSymmetric `{AAD=5, P=256, IV=96} | ||
:check dotAndMultAreEquivalent |