File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -650,13 +650,13 @@ class _Rsa(object): # pylint: disable=too-few-public-methods
650650 _mgf = None
651651 _hash_type = None
652652
653- def __init__ (self ):
653+ def __init__ (self , rng = Random () ):
654654 self .native_object = _ffi .new ("RsaKey *" )
655655 ret = _lib .wc_InitRsaKey (self .native_object , _ffi .NULL )
656656 if ret < 0 : # pragma: no cover
657657 raise WolfCryptError ("Invalid key error (%d)" % ret )
658658
659- self ._random = Random ()
659+ self ._random = rng
660660 if _lib .RSA_BLINDING_ENABLED :
661661 ret = _lib .wc_RsaSetRNG (self .native_object ,
662662 self ._random .native_object )
@@ -690,12 +690,14 @@ def _get_mgf(self):
690690
691691
692692 class RsaPublic (_Rsa ):
693- def __init__ (self , key = None , hash_type = None ):
693+ def __init__ (self , key = None , hash_type = None , rng = None ):
694694 if key is not None :
695695 key = t2b (key )
696696 self ._hash_type = hash_type
697+ if rng is None :
698+ rng = Random ()
697699
698- _Rsa .__init__ (self )
700+ _Rsa .__init__ (self , rng )
699701
700702 idx = _ffi .new ("word32*" )
701703 idx [0 ] = 0
You can’t perform that action at this time.
0 commit comments