[Cryptech-Commits] [user/sra/aes-keywrap] branch master updated: Use unittest.TestCase.assertEqual() properly, and crank up test verbosity.

git at cryptech.is git at cryptech.is
Thu Jun 28 17:54:05 UTC 2018


This is an automated email from the git hooks/post-receive script.

sra at hactrn.net pushed a commit to branch master
in repository user/sra/aes-keywrap.

The following commit(s) were added to refs/heads/master by this push:
     new 8254932  Use unittest.TestCase.assertEqual() properly, and crank up test verbosity.
8254932 is described below

commit 825493299896cd34e4f4188805c254667e68c077
Author: Rob Austein <sra at hactrn.net>
AuthorDate: Thu Jun 28 13:53:37 2018 -0400

    Use unittest.TestCase.assertEqual() properly, and crank up test verbosity.
---
 aes_keywrap.py | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/aes_keywrap.py b/aes_keywrap.py
old mode 100644
new mode 100755
index bb6968a..a026518
--- a/aes_keywrap.py
+++ b/aes_keywrap.py
@@ -144,8 +144,7 @@ if __name__ == "__main__":
             K = AESKeyWrapWithPadding(self.hex2bin("00:01:02:03:04:05:06:07:08:09:0a:0b:0c:0d:0e:0f"))
             C = K.wrap_key(I)
             O = K.unwrap_key(C)
-            if I != O:
-                raise RuntimeError("Input and output plaintext did not match: {!r} <> {!r}".format(I, O))
+            self.assertEqual(I, O, "Input and output plaintext did not match: {!r} <> {!r}".format(I, O))
 
         def rfc5649_test(self, K, Q, C):
             K = AESKeyWrapWithPadding(key = self.hex2bin(K))
@@ -153,10 +152,8 @@ if __name__ == "__main__":
             C = self.hex2bin(C)
             c = K.wrap_key(Q)
             q = K.unwrap_key(C)
-            if q != Q:
-                raise RuntimeError("Input and output plaintext did not match: {} <> {}".format(self.bin2hex(Q), self.bin2hex(q)))
-            if c != C:
-                raise RuntimeError("Input and output ciphertext did not match: {} <> {}".format(self.bin2hex(C), self.bin2hex(c)))
+            self.assertEqual(q, Q, "Input and output plaintext did not match: {} <> {}".format(self.bin2hex(Q), self.bin2hex(q)))
+            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",
@@ -213,4 +210,4 @@ if __name__ == "__main__":
         def test_loopback_9(self):
             self.loopback_test("Hello!  My name is Inigo Montoya. You killed my AES key wrapper. Prepare to die.")
 
-    unittest.main()
+    unittest.main(verbosity = 9)

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Commits mailing list