Skip to content

Commit e3c2fa7

Browse files
committed
minor syntax cleanup
1 parent 47c0578 commit e3c2fa7

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
# ff3 - Format Preserving Encryption in Python
77

8-
An implementation of the NIST approved Format Preserving Encryption (FPE) FF3 and FF3-1 algorithm in Python.
8+
An implementation of the NIST approved Format Preserving Encryption (FPE) FF3 and FF3-1 algorithms in Python.
99

1010
This package follows the FF3 algorithm for Format Preserving Encryption as described in the March 2016 NIST publication 800-38G _Methods for Format-Preserving Encryption_,
1111
and revised on February 28th, 2019 with a draft update for FF3-1.

ff3/ff3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def encrypt_with_tweak(self, plaintext, tweak):
222222

223223
# Tr is T[32..55] + T[28..31] + 0000
224224
Tr = bytearray(tweakBytes[HALF_TWEAK_LEN:])
225-
Tr.append((tweakBytes[3]&0x0F)<<4)
225+
Tr.append((tweakBytes[3] & 0x0F) << 4)
226226
print(f"Tweak:{tweakBytes.hex()} Tl:{Tl.hex()}, Tr:{Tr.hex()}")
227227
else:
228228
raise ValueError(f"tweak length {len(tweakBytes)} invalid: tweak must be 56 or 64 bits")

ff3/ff3_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@
310310
},
311311
]
312312

313+
313314
class TestFF3(unittest.TestCase):
314315

315316
def test_encode_int(self):
@@ -328,7 +329,6 @@ def test_decode_int(self):
328329
self.assertEqual(0x02, (decode_int_r("20", hexdigits)))
329330
self.assertEqual(0xAA, (decode_int_r("aa", hexdigits)))
330331

331-
332332
def test_aes_ecb(self):
333333
# NIST test vector for ECB-AES128
334334
key = bytes.fromhex('2b7e151628aed2a6abf7158809cf4f3c')
@@ -421,7 +421,7 @@ def test_custom_alphabet(self):
421421

422422
# Check that encryption and decryption are inverses over whole domain
423423
def test_whole_domain(self):
424-
TEST_CASES = [
424+
test_cases = [
425425
# (radix, plaintext_len, alphabet (None means default))
426426
(2, 10, None),
427427
(3, 6, None),
@@ -431,15 +431,15 @@ def test_whole_domain(self):
431431
(3, 7, "ABC"),
432432
]
433433

434-
max_radix = max(radix for radix, plaintext_len, alphabet in TEST_CASES)
434+
max_radix = max(radix for radix, plaintext_len, alphabet in test_cases)
435435

436436
# Temporarily reduce DOMAIN_MIN to make testing fast
437437
domain_min_orig = FF3Cipher.DOMAIN_MIN
438438
FF3Cipher.DOMAIN_MIN = max_radix + 1
439439

440440
key = "EF4359D8D580AA4F7F036D6F04FC6A94"
441441
tweak = "D8E7920AFA330A73"
442-
for radix, plaintext_len, alphabet in TEST_CASES:
442+
for radix, plaintext_len, alphabet in test_cases:
443443
if alphabet is None:
444444
c = FF3Cipher(key, tweak, radix=radix)
445445
else:

0 commit comments

Comments
 (0)