2022-06-07 15:21:19 +02:00
|
|
|
import hashlib
|
|
|
|
|
2022-06-08 19:47:09 +02:00
|
|
|
"""
|
|
|
|
The SHA primitives are abstracted here to allow platform-
|
|
|
|
aware hardware acceleration in the future. Currently only
|
|
|
|
uses Python's internal SHA-256 implementation. All SHA-256
|
|
|
|
calls in RNS end up here.
|
|
|
|
"""
|
2022-06-07 15:21:19 +02:00
|
|
|
|
|
|
|
def sha256(data):
|
|
|
|
digest = hashlib.sha256()
|
|
|
|
digest.update(data)
|
|
|
|
|
2022-06-08 19:47:09 +02:00
|
|
|
return digest.digest()
|
|
|
|
|
|
|
|
def sha512(data):
|
|
|
|
digest = hashlib.sha512()
|
|
|
|
digest.update(data)
|
|
|
|
|
|
|
|
return digest.digest()
|