Skip to content

Commit 4ae435a

Browse files
committed
don't do byte based copy in PRF calculation
1 parent e8da6cf commit 4ae435a

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

tlslite/mathtls.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -677,18 +677,17 @@ def paramStrength(param):
677677

678678

679679
def P_hash(macFunc, secret, seed, length):
680-
bytes = bytearray(length)
680+
ret = bytearray(length)
681681
A = seed
682682
index = 0
683-
while 1:
683+
while index < length:
684684
A = macFunc(secret, A)
685685
output = macFunc(secret, A + seed)
686-
for c in output:
687-
if index >= length:
688-
return bytes
689-
bytes[index] = c
690-
index += 1
691-
return bytes
686+
how_many = min(length - index, len(output))
687+
ret[index:index+how_many] = output[:how_many]
688+
index += how_many
689+
return ret
690+
692691

693692
def PRF(secret, label, seed, length):
694693
#Split the secret into left and right halves

0 commit comments

Comments
 (0)