Skip to content

Commit ff7343c

Browse files
committed
Added new unit tests for decode_int_r for large values
1 parent f89402b commit ff7343c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

ff3/ff3_test.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ def test_decode_int(self):
331331
self.assertEqual(101, (decode_int_r("101", string.digits)))
332332
self.assertEqual(0x02, (decode_int_r("20", hexdigits)))
333333
self.assertEqual(0xAA, (decode_int_r("aa", hexdigits)))
334+
self.assertEqual(44831223490454933899171349985, decode_int_r("p0oModYgk00ZI4S6", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"))
334335

335336
def test_aes_ecb(self):
336337
# NIST test vector for ECB-AES128
@@ -444,6 +445,19 @@ def test_german(self):
444445
x = c.decrypt(s)
445446
self.assertEqual(x, plaintext)
446447

448+
def test_decodeint_signbyte(self):
449+
alphabet = string.ascii_uppercase + string.ascii_lowercase + string.digits
450+
key = "2DE79D232DF5585D68CE47882AE256D6"
451+
tweak = "CBD09280979564"
452+
plaintext = "Ceciestuntestdechiffrement123cet"
453+
ciphertext = "0uaTPI9g49f9MMw54OvY8x5rmNcrhydM"
454+
c = FF3Cipher.withCustomAlphabet(key, tweak, alphabet)
455+
s = c.encrypt(plaintext)
456+
self.assertEqual(s, ciphertext)
457+
x = c.decrypt(s)
458+
self.assertEqual(x, plaintext)
459+
460+
447461
# Check that encryption and decryption are inverses over whole domain
448462
def test_whole_domain(self):
449463
test_cases = [

0 commit comments

Comments
 (0)