[Cryptech-Commits] [user/js/keywrap] branch master updated: Adding a huge, self testing test case.
git at cryptech.is
git at cryptech.is
Tue Sep 11 10:38:06 UTC 2018
This is an automated email from the git hooks/post-receive script.
joachim at secworks.se pushed a commit to branch master
in repository user/js/keywrap.
The following commit(s) were added to refs/heads/master by this push:
new 6cfcc1e Adding a huge, self testing test case.
6cfcc1e is described below
commit 6cfcc1ec5bc0e2c944ec66bd62d58740d2b8823d
Author: Joachim Strömbergson <joachim at secworks.se>
AuthorDate: Tue Sep 11 12:37:28 2018 +0200
Adding a huge, self testing test case.
---
src/model/aes_keywrap.py | 83 ++++++++++++++++++++++++--------------------
src/tb/tb_keywrap.v | 90 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 135 insertions(+), 38 deletions(-)
diff --git a/src/model/aes_keywrap.py b/src/model/aes_keywrap.py
index 0e74ed8..d8b57fe 100755
--- a/src/model/aes_keywrap.py
+++ b/src/model/aes_keywrap.py
@@ -281,25 +281,25 @@ if __name__ == "__main__":
# Test vectors from NISTs set of test vectors for SP800-38F KWP algorithm.
# 128 bit key.
-# def test_kwp_ae_128_1(self):
-# self.rfc5649_test(K = "7efb9b3964de316e 7245c86186d98b5f",
-# Q = "3e",
-# C = "116a4054c13b7fea de9c22aa57b3caed")
-#
-# def test_kwp_ae_128_2(self):
-# self.rfc5649_test(K = "45c770fc26717507 2d70a38269c54685",
-# Q = "cc5fb15a17795c34",
-# C = "78ffa3f03b65c55b 812f355730af71ac")
-#
-# def test_kwp_ae_128_3(self):
-# self.rfc5649_test(K = "853e2bac0f1e6298 67acea0d2b3c087e",
-# Q = "49575527bc59530f be",
-# C = "b43781062eb0317e b2dec6329f2d64de 1c33d85570d57db6")
-
-# def test_kwp_ae_128_4(self):
-# self.rfc5649_test(K = "c03db3cc1416dcd1 c069a195a8d77e3d",
-# Q = "46f87f58cdda4200 f53d99ce2e49bdb7 6212511fe0cd4d0 b5f37a27d45a288",
-# C = "57e3b6699c6e8177 59a69492bb7e2cd0 0160d2ebef9bf4d 4eb16fbf798f134 0f6df6558a4fb84cd0")
+ def test_kwp_ae_128_1(self):
+ self.rfc5649_test(K = "7efb9b3964de316e 7245c86186d98b5f",
+ Q = "3e",
+ C = "116a4054c13b7fea de9c22aa57b3caed")
+
+ def test_kwp_ae_128_2(self):
+ self.rfc5649_test(K = "45c770fc26717507 2d70a38269c54685",
+ Q = "cc5fb15a17795c34",
+ C = "78ffa3f03b65c55b 812f355730af71ac")
+
+ def test_kwp_ae_128_3(self):
+ self.rfc5649_test(K = "853e2bac0f1e6298 67acea0d2b3c087e",
+ Q = "49575527bc59530f be",
+ C = "b43781062eb0317e b2dec6329f2d64de 1c33d85570d57db6")
+
+ def test_kwp_ae_128_4(self):
+ self.rfc5649_test(K = "c03db3cc1416dcd1 c069a195a8d77e3d",
+ Q = "46f87f58cdda4200 f53d99ce2e49bdb7 6212511fe0cd4d0 b5f37a27d45a288",
+ C = "57e3b6699c6e8177 59a69492bb7e2cd0 0160d2ebef9bf4d 4eb16fbf798f134 0f6df6558a4fb84cd0")
def test_kwp_ae_128_5(self):
self.rfc5649_test(K = "6b8ba9cc9b31068b a175abfcc60c1338",
@@ -309,25 +309,32 @@ if __name__ == "__main__":
C = "aea19443d7f8ad7d 4501c1ecadc6b5e3 f1c23c29eca60890 5f9cabdd46e34a55 e1f7ac8308e75c90 3675982bda99173a 2ba57d2ccf2e01a0 2589f89dfd4b3c7f d229ec91c9d0c46e a5dee3c048cd4611 bfeadc9bf26daa1e 02cb72e222cf3dab 120dd1e8c2dd9bd5 8bbefa5d14526abd 1e8d2170a6ba8283 c243ec2fd5ef0703 0b1ef5f69f9620e4 b17a363934100588 7b9ffc7935335947 03e5dcae67bd0ce7 a3c98ca65815a4d0 67f27e6e66d6636c ebb789732566a52a c3970e14c37310dc 2fcee0e739a16291 029fd2b4d534e304 45474b26711a8b3 [...]
-# def test_kwp_ae_256_1(self):
-# self.rfc5649_test(K = "2800f18237cf8d2b a1dfe361784fd751 9b0fdb0ec73e2ab1 c0b966b9173fc5b5",
-# Q = "ad",
-# C = "c1eccf2d077a385e 67aaeb35552c893c")
-#
-# def test_kwp_ae_256_2(self):
-# self.rfc5649_test(K = "1c997c2bb5a15a45 93e337b3249675d55 7467417917f6bc51 65c9af6a3e29504",
-# Q = "3e3eafc50cd4e939",
-# C = "163eb9e7dbc8ed00 86dffbc6ab00e329")
-#
-# def test_kwp_ae_256_3(self):
-# self.rfc5649_test(K = "8df1533f99be6fe6 0f951057fed1daccd 14bd4e34118f24af 677bbf46bf11fe7",
-# Q = "fb36b1f3907fb5ed ce",
-# C = "6974d7bae0221b4e d91336c26af77e327 61f6024d8bbf292")
-#
-# def test_kwp_ae_256_4(self):
-# self.rfc5649_test(K = "dea4667d911b5c9e c996cdb35da0e29bc 996cbfb0e0a56bac 12fccc334d732eb",
-# Q = "25d58d437a56a733 2a18541333201f992 9fccde11b06844c1 9ba1ca224cfd6",
-# C = "86d4e258391f15d7 d4f0ab3e15d6f45e6 5dd2f8caf4c67209 63bb8970fc2f3a4 a58dc74674347ec9")
+ def test_kwp_ae_256_1(self):
+ self.rfc5649_test(K = "2800f18237cf8d2b a1dfe361784fd751 9b0fdb0ec73e2ab1 c0b966b9173fc5b5",
+ Q = "ad",
+ C = "c1eccf2d077a385e 67aaeb35552c893c")
+
+ def test_kwp_ae_256_2(self):
+ self.rfc5649_test(K = "1c997c2bb5a15a45 93e337b3249675d55 7467417917f6bc51 65c9af6a3e29504",
+ Q = "3e3eafc50cd4e939",
+ C = "163eb9e7dbc8ed00 86dffbc6ab00e329")
+
+ def test_kwp_ae_256_3(self):
+ self.rfc5649_test(K = "8df1533f99be6fe6 0f951057fed1daccd 14bd4e34118f24af 677bbf46bf11fe7",
+ Q = "fb36b1f3907fb5ed ce",
+ C = "6974d7bae0221b4e d91336c26af77e327 61f6024d8bbf292")
+
+ def test_kwp_ae_256_4(self):
+ self.rfc5649_test(K = "dea4667d911b5c9e c996cdb35da0e29bc 996cbfb0e0a56bac 12fccc334d732eb",
+ Q = "25d58d437a56a733 2a18541333201f992 9fccde11b06844c1 9ba1ca224cfd6",
+ C = "86d4e258391f15d7 d4f0ab3e15d6f45e6 5dd2f8caf4c67209 63bb8970fc2f3a4 a58dc74674347ec9")
+
+
+# # Huge test case. It fails since the expected wrapped object is wrong.
+# def test_huge_256_1(self):
+# self.rfc5649_test(K = "55aa55aa55aa55aa" * 4,
+# Q = "0101010101010101" * 2040,
+# C = "86d4e258391f15d7" * 2042)
# def test_loopback_1(self):
diff --git a/src/tb/tb_keywrap.v b/src/tb/tb_keywrap.v
index 59409e9..4d1c25c 100644
--- a/src/tb/tb_keywrap.v
+++ b/src/tb/tb_keywrap.v
@@ -1055,6 +1055,94 @@ module tb_keywrap();
endtask // test_kwp_ad_128_2
+
+ //----------------------------------------------------------------
+ // test_big_wrap_256
+ // Implements wrap test with a huge (16 kB+) data object
+ // and 256 bit key.
+ //----------------------------------------------------------------
+ task test_big_wrap_256;
+ begin : test_big_wrap_256
+ integer i;
+ integer err;
+
+ err = 0;
+
+ tc_ctr = tc_ctr + 1;
+
+ $display("** TC test_big_wrap_256 START.");
+
+ // Write key and keylength, we also want to encrypt/wrap.
+ write_word(ADDR_KEY0, 32'h55aa55aa);
+ write_word(ADDR_KEY1, 32'h55aa55aa);
+ write_word(ADDR_KEY2, 32'h55aa55aa);
+ write_word(ADDR_KEY3, 32'h55aa55aa);
+ write_word(ADDR_KEY4, 32'h55aa55aa);
+ write_word(ADDR_KEY5, 32'h55aa55aa);
+ write_word(ADDR_KEY6, 32'h55aa55aa);
+ write_word(ADDR_KEY7, 32'h55aa55aa);
+ write_word(ADDR_CONFIG, 32'h00000003);
+
+ // Initialize the AES engine (to expand the key).
+ // Wait for init to complete.
+ // Note, not actually needed to wait. We can write R data during init.
+ $display("* Trying to initialize.");
+ write_word(ADDR_CTRL, 32'h00000001);
+ #(2 * CLK_PERIOD);
+ wait_ready();
+ $display("* Init should be done.");
+
+
+ // Set the length or R in blocks.
+ // Write the R bank to be written to.
+ // Write the R blocks to be processed.
+ write_word(ADDR_RLEN, 32'h000007f8);
+
+
+ // Write the data to be wrapped.
+ for (i = 0 ; i < 4080 ; i = i + 1)
+ write_word(MEM_BASE + i, 32'h01010101);
+
+ // Write magic words to A.
+ write_word(ADDR_A0, 32'ha65959a6);
+ write_word(ADDR_A1, 32'h00003fc0);
+
+ // Start wrapping and wait for wrap to complete.
+ $display("* Trying to start processing.");
+ write_word(ADDR_CTRL, 32'h00000002);
+ #(2 * CLK_PERIOD);
+ wait_ready();
+ $display("* Processing should be done.");
+
+
+ // Read and check the A registers.
+ read_word(ADDR_A0);
+ if (read_data != 32'h53179eb9)
+ begin
+ $display("Error A0 after wrap: 0x%08x, expected 0x53179eb9", read_data);
+ err = 1;
+ end
+
+ read_word(ADDR_A1);
+ if (read_data != 32'ha90ce632)
+ begin
+ $display("Error A1 after wrap: 0x%08x, expected 0xa90ce632", read_data);
+ err = 1;
+ end
+
+ if (err)
+ begin
+ $display("test_big_wrap_256 completed with errors.");
+ error_ctr = error_ctr + 1;
+ end
+ else
+ $display("test_big_wrap_256 completed successfully.");
+
+ $display("** TC test_big_wrap_256 END.\n");
+ end
+ endtask // test_big_wrap_256
+
+
//----------------------------------------------------------------
// main
//----------------------------------------------------------------
@@ -1081,6 +1169,8 @@ module tb_keywrap();
test_kwp_ae_128_2();
test_kwp_ad_128_2();
+ test_big_wrap_256();
+
display_test_results();
$display("");
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Commits
mailing list