Skip to content

Commit 30689f8

Browse files
author
Aitor Gómez Goiri
committed
Documenting some details
1 parent c078ab7 commit 30689f8

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/kdf/nist.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ def _to_one_byte(self, inByte):
4040
output.append(inByte)
4141
return output;
4242

43-
def _debug_string_as_bytes(self, array_alpha):
44-
import binascii
45-
print binascii.hexlify(array_alpha)
43+
# def _debug_string_as_bytes(self, array_alpha):
44+
# import binascii
45+
# print binascii.hexlify(array_alpha)
4646

4747
def derive_key(self, outputSizeBits, fixedInput):
4848
assert outputSizeBits >= 56, "Key has size of %d, which is less than minimum of 56-bits." % outputSizeBits
@@ -67,6 +67,7 @@ def derive_key(self, outputSizeBits, fixedInput):
6767
hmac.update(fixedInput)
6868
tmpKey = hmac.digest() # type: string
6969
#print self._debug_string_as_bytes(tmpKey)
70+
# or simply hmac.hexdigest()
7071

7172
if len(tmpKey) >= outputSizeBytes:
7273
lenn = outputSizeBytes

test/nistTest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99

1010
class NISTTest(unittest.TestCase):
1111

12-
def _test_NIST_UseCase(self, nist_obj, testCase):
12+
def _test_NIST_UseCase(self, nist_obj, testCase, error_msg):
1313
nist_obj.set_hmac( testCase["digestmod"], testCase["ki"] )
1414
#ret = self.nist.derive_key( len(testCase["ko"])*8, testCase["fixedInput"] )
1515
ret = nist_obj.derive_key( testCase["l"], testCase["fixedInput"] )
16-
self.assertSequenceEqual(ret, testCase["ko"])
16+
self.assertSequenceEqual(ret, testCase["ko"], error_msg)
1717

1818
def _test_using_hmac_library(self, generic_case):
1919
# less things to do because this test suite was originally conceived for hmac implementation
@@ -26,7 +26,7 @@ def _test_using_hmac_library(self, generic_case):
2626
raise Exception("Digest mode not considered.")
2727

2828
from kdf.lhmac import NIST
29-
self._test_NIST_UseCase( NIST(), case )
29+
self._test_NIST_UseCase( NIST(), case, "hmac library based implementation" )
3030

3131
def _test_using_crypto_library(self, generic_case):
3232
case = generic_case.copy()
@@ -45,7 +45,7 @@ def _test_using_crypto_library(self, generic_case):
4545
case["ko"] = str(case["ko"])
4646

4747
from kdf.lcrypto import NIST
48-
self._test_NIST_UseCase( NIST(), case )
48+
self._test_NIST_UseCase( NIST(), case, "crypto library based implementation" )
4949

5050
def test_NIST1(self):
5151
"""

0 commit comments

Comments
 (0)