File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -651,13 +651,13 @@ class _Rsa(object): # pylint: disable=too-few-public-methods
651651 _mgf = None
652652 _hash_type = None
653653
654- def __init__ (self ):
654+ def __init__ (self , rng = Random () ):
655655 self .native_object = _ffi .new ("RsaKey *" )
656656 ret = _lib .wc_InitRsaKey (self .native_object , _ffi .NULL )
657657 if ret < 0 : # pragma: no cover
658658 raise WolfCryptError ("Invalid key error (%d)" % ret )
659659
660- self ._random = Random ()
660+ self ._random = rng
661661 if _lib .RSA_BLINDING_ENABLED :
662662 ret = _lib .wc_RsaSetRNG (self .native_object ,
663663 self ._random .native_object )
@@ -691,12 +691,14 @@ def _get_mgf(self):
691691
692692
693693 class RsaPublic (_Rsa ):
694- def __init__ (self , key = None , hash_type = None ):
694+ def __init__ (self , key = None , hash_type = None , rng = None ):
695695 if key != None :
696696 key = t2b (key )
697697 self ._hash_type = hash_type
698+ if rng is None :
699+ rng = Random ()
698700
699- _Rsa .__init__ (self )
701+ _Rsa .__init__ (self , rng )
700702
701703 idx = _ffi .new ("word32*" )
702704 idx [0 ] = 0
You can’t perform that action at this time.
0 commit comments