-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Andrew Kent
committed
Apr 8, 2021
1 parent
c2ef506
commit a6500d3
Showing
12 changed files
with
381 additions
and
7 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
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
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../../examples |
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,39 @@ | ||
import unittest | ||
from pathlib import Path | ||
import unittest | ||
import cryptol | ||
from cryptol.bitvector import BV | ||
|
||
|
||
class TestAES(unittest.TestCase): | ||
def test_AES(self): | ||
c = cryptol.connect() | ||
c.load_file(str(Path('tests','cryptol','test-files', 'examples','AES.cry'))) | ||
|
||
pt = BV(size=128, value=0x3243f6a8885a308d313198a2e0370734) | ||
key = BV(size=128, value=0x2b7e151628aed2a6abf7158809cf4f3c) | ||
ct = c.call("aesEncrypt", (pt, key)).result() | ||
expected_ct = BV(size=128, value=0x3925841d02dc09fbdc118597196a0b32) | ||
self.assertEqual(ct, expected_ct) | ||
|
||
decrypted_ct = c.call("aesDecrypt", (ct, key)).result() | ||
self.assertEqual(pt, decrypted_ct) | ||
|
||
pt = BV(size=128, value=0x00112233445566778899aabbccddeeff) | ||
key = BV(size=128, value=0x000102030405060708090a0b0c0d0e0f) | ||
ct = c.call("aesEncrypt", (pt, key)).result() | ||
expected_ct = BV(size=128, value=0x69c4e0d86a7b0430d8cdb78070b4c55a) | ||
self.assertEqual(ct, expected_ct) | ||
|
||
decrypted_ct = c.call("aesDecrypt", (ct, key)).result() | ||
self.assertEqual(pt, decrypted_ct) | ||
|
||
# c.safe("aesEncrypt") | ||
# c.safe("aesDecrypt") | ||
self.assertTrue(c.check("AESCorrect").result().success) | ||
# c.prove("AESCorrect") # probably takes too long for this script...? | ||
|
||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
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 |
---|---|---|
|
@@ -26,3 +26,6 @@ id x = x | |
|
||
type Word8 = [8] | ||
type Twenty a = [20]a | ||
|
||
isSqrtOf9 : [8] -> Bit | ||
isSqrtOf9 x = x*x == 9 |
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
Oops, something went wrong.