aboutsummaryrefslogtreecommitdiff
path: root/src/model/aes_keywrap.py
diff options
context:
space:
mode:
authorJoachim StroĢˆmbergson <joachim@secworks.se>2018-07-03 09:54:36 +0200
committerJoachim StroĢˆmbergson <joachim@secworks.se>2018-07-03 09:54:36 +0200
commit5eb133ca96cade7fd8c462d734723d89dc7ae7ec (patch)
tree142d268cd009092b8826643993f704f3f502a561 /src/model/aes_keywrap.py
parentef107e0aae06a658e1353dbf0856103cddfcf1c4 (diff)
Focusing on a single NIST KWP test case that is non-trivial.
Diffstat (limited to 'src/model/aes_keywrap.py')
-rwxr-xr-xsrc/model/aes_keywrap.py205
1 files changed, 103 insertions, 102 deletions
diff --git a/src/model/aes_keywrap.py b/src/model/aes_keywrap.py
index 6d99d0c..ef83baa 100755
--- a/src/model/aes_keywrap.py
+++ b/src/model/aes_keywrap.py
@@ -216,60 +216,60 @@ if __name__ == "__main__":
self.assertEqual(c, C, "Input and output ciphertext did not match: {} <> {}".format(self.bin2hex(C), self.bin2hex(c)))
- def test_rfc5649_1(self):
- self.rfc5649_test(K = "5840df6e29b02af1 ab493b705bf16ea1 ae8338f4dcc176a8",
- Q = "c37b7e6492584340 bed1220780894115 5068f738",
- C = "138bdeaa9b8fa7fc 61f97742e72248ee 5ae6ae5360d1ae6a 5f54f373fa543b6a")
-
- def test_rfc5649_2(self):
- self.rfc5649_test(K = "5840df6e29b02af1 ab493b705bf16ea1 ae8338f4dcc176a8",
- Q = "466f7250617369",
- C = "afbeb0f07dfbf541 9200f2ccb50bb24f")
-
-
- def test_mangled_1(self):
- self.assertRaises(AESKeyWrapWithPadding.UnwrapError, self.rfc5649_test,
- K = "5840df6e29b02af0 ab493b705bf16ea1 ae8338f4dcc176a8",
- Q = "466f7250617368",
- C = "afbeb0f07dfbf541 9200f2ccb50bb24f")
-
- def test_mangled_2(self):
- self.assertRaises(AESKeyWrapWithPadding.UnwrapError, self.rfc5649_test,
- K = "5840df6e29b02af0 ab493b705bf16ea1 ae8338f4dcc176a8",
- Q = "466f7250617368",
- C = "afbeb0f07dfbf541 9200f2ccb50bb24f 0123456789abcdef")
-
- def test_mangled_3(self):
- self.assertRaises(AESKeyWrapWithPadding.UnwrapError, self.rfc5649_test,
- K = "5840df6e29b02af1 ab493b705bf16ea1 ae8338f4dcc176a8",
- Q = "c37b7e6492584340 bed1220780894115 5068f738",
- C = "138bdeaa9b8fa7fc 61f97742e72248ee 5ae6ae5360d1ae6a")
-
-
- # This one should fail. But it doesn't. Que pasa?!?
- def test_mangled_4(self):
- self.assertRaises(AESKeyWrapWithPadding.UnwrapError, self.rfc5649_test,
- K = "5840df6e29b02af1 ab493b705bf16ea1 ae8338f4dcc176a8",
- Q = "c37b7e6492584340 bed1220780894115 5068f738",
- C = "238bdeaa9b8fa7fc 61f97742e72248ee 5ae6ae5360d1ae6a")
+# def test_rfc5649_1(self):
+# self.rfc5649_test(K = "5840df6e29b02af1 ab493b705bf16ea1 ae8338f4dcc176a8",
+# Q = "c37b7e6492584340 bed1220780894115 5068f738",
+# C = "138bdeaa9b8fa7fc 61f97742e72248ee 5ae6ae5360d1ae6a 5f54f373fa543b6a")
+#
+# def test_rfc5649_2(self):
+# self.rfc5649_test(K = "5840df6e29b02af1 ab493b705bf16ea1 ae8338f4dcc176a8",
+# Q = "466f7250617369",
+# C = "afbeb0f07dfbf541 9200f2ccb50bb24f")
+#
+#
+# def test_mangled_1(self):
+# self.assertRaises(AESKeyWrapWithPadding.UnwrapError, self.rfc5649_test,
+# K = "5840df6e29b02af0 ab493b705bf16ea1 ae8338f4dcc176a8",
+# Q = "466f7250617368",
+# C = "afbeb0f07dfbf541 9200f2ccb50bb24f")
+#
+# def test_mangled_2(self):
+# self.assertRaises(AESKeyWrapWithPadding.UnwrapError, self.rfc5649_test,
+# K = "5840df6e29b02af0 ab493b705bf16ea1 ae8338f4dcc176a8",
+# Q = "466f7250617368",
+# C = "afbeb0f07dfbf541 9200f2ccb50bb24f 0123456789abcdef")
+#
+# def test_mangled_3(self):
+# self.assertRaises(AESKeyWrapWithPadding.UnwrapError, self.rfc5649_test,
+# K = "5840df6e29b02af1 ab493b705bf16ea1 ae8338f4dcc176a8",
+# Q = "c37b7e6492584340 bed1220780894115 5068f738",
+# C = "138bdeaa9b8fa7fc 61f97742e72248ee 5ae6ae5360d1ae6a")
+#
+#
+# # This one should fail. But it doesn't. Que pasa?!?
+# def test_mangled_4(self):
+# self.assertRaises(AESKeyWrapWithPadding.UnwrapError, self.rfc5649_test,
+# K = "5840df6e29b02af1 ab493b705bf16ea1 ae8338f4dcc176a8",
+# Q = "c37b7e6492584340 bed1220780894115 5068f738",
+# C = "238bdeaa9b8fa7fc 61f97742e72248ee 5ae6ae5360d1ae6a")
# 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_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",
@@ -277,60 +277,61 @@ if __name__ == "__main__":
C = "57e3b6699c6e8177 59a69492bb7e2cd0 0160d2ebef9bf4d 4eb16fbf798f134 0f6df6558a4fb84cd0")
- 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_loopback_1(self):
- self.loopback_test("!")
-
- def test_loopback_2(self):
- self.loopback_test("Yo!")
-
- def test_loopback_3(self):
- self.loopback_test("Hi, Mom")
-
- def test_loopback_4(self):
- self.loopback_test("1" * (64 / 8))
-
- def test_loopback_5(self):
- self.loopback_test("2" * (128 / 8))
-
- def test_loopback_6(self):
- self.loopback_test("3" * (256 / 8))
-
- def test_loopback_7(self):
- self.loopback_test("3.14159265358979323846264338327950288419716939937510")
-
- def test_loopback_8(self):
- self.loopback_test("3.14159265358979323846264338327950288419716939937510")
+# 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_loopback_9(self):
- self.loopback_test("Hello! My name is Inigo Montoya. You killed my AES key wrapper. Prepare to die.")
- def test_joachim_loopback(self):
- I = "31:32:33"
- K = AESKeyWrapWithPadding(urandom(256/8))
- C = K.wrap_key(I)
- O = K.unwrap_key(C)
- self.assertEqual(I, O, "Input and output plaintext did not match: {!r} <> {!r}".format(I, O))
+# def test_loopback_1(self):
+# self.loopback_test("!")
+#
+# def test_loopback_2(self):
+# self.loopback_test("Yo!")
+#
+# def test_loopback_3(self):
+# self.loopback_test("Hi, Mom")
+#
+# def test_loopback_4(self):
+# self.loopback_test("1" * (64 / 8))
+#
+# def test_loopback_5(self):
+# self.loopback_test("2" * (128 / 8))
+#
+# def test_loopback_6(self):
+# self.loopback_test("3" * (256 / 8))
+#
+# def test_loopback_7(self):
+# self.loopback_test("3.14159265358979323846264338327950288419716939937510")
+#
+# def test_loopback_8(self):
+# self.loopback_test("3.14159265358979323846264338327950288419716939937510")
+#
+# def test_loopback_9(self):
+# self.loopback_test("Hello! My name is Inigo Montoya. You killed my AES key wrapper. Prepare to die.")
+#
+# def test_joachim_loopback(self):
+# I = "31:32:33"
+# K = AESKeyWrapWithPadding(urandom(256/8))
+# C = K.wrap_key(I)
+# O = K.unwrap_key(C)
+# self.assertEqual(I, O, "Input and output plaintext did not match: {!r} <> {!r}".format(I, O))
+#
unittest.main(verbosity = 9)