Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions wolfcrypt/ciphers.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,13 +651,13 @@ class _Rsa(object): # pylint: disable=too-few-public-methods
_mgf = None
_hash_type = None

def __init__(self):
def __init__(self, rng=Random()):
self.native_object = _ffi.new("RsaKey *")
ret = _lib.wc_InitRsaKey(self.native_object, _ffi.NULL)
if ret < 0: # pragma: no cover
raise WolfCryptError("Invalid key error (%d)" % ret)

self._random = Random()
self._random = rng
if _lib.RSA_BLINDING_ENABLED:
ret = _lib.wc_RsaSetRNG(self.native_object,
self._random.native_object)
Expand Down Expand Up @@ -691,12 +691,14 @@ def _get_mgf(self):


class RsaPublic(_Rsa):
def __init__(self, key=None, hash_type=None):
def __init__(self, key=None, hash_type=None, rng=None):
if key != None:
key = t2b(key)
self._hash_type = hash_type
if rng is None:
rng = Random()

_Rsa.__init__(self)
_Rsa.__init__(self, rng)

idx = _ffi.new("word32*")
idx[0] = 0
Expand Down
Loading