Fix LSWAP problem. (#275)

This commit is contained in:
Eugene Kabanov 2020-07-11 00:30:34 +03:00 committed by GitHub
parent 7f77ba2308
commit e64efc5dbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -14,7 +14,7 @@
import bearssl
import eth/keys, nimcrypto/[rijndael, bcmode, hash, hmac, sha2, utils]
import stew/results
import stew/[results, endians2]
export results
@ -82,7 +82,7 @@ proc kdf*(data: openarray[byte]): array[KeyLength, byte] {.noInit.} =
var storage = newSeq[byte](int(ctx.sizeDigest) * (reps + 1))
while counter <= uint32(reps):
counter = counter + 1
counterLe = LSWAP(counter)
counterLe = toBE(counter)
ctx.init()
ctx.update(cast[ptr byte](addr counterLe), uint(sizeof(uint32)))
ctx.update(unsafeAddr data[0], uint(len(data)))