Skip to content

Commit 7002b01

Browse files
EccPrivate: Do lazy creation of random generator in make_key().
1 parent b4ddce1 commit 7002b01

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

wolfcrypt/ciphers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,16 +1232,17 @@ class EccPrivate(EccPublic):
12321232

12331233
def __init__(self, key=None, rng=None):
12341234
super().__init__(key)
1235-
if rng is None:
1236-
rng = Random()
12371235
self._rng = rng
12381236

12391237
@classmethod
12401238
def make_key(cls, size, rng=None):
12411239
"""
12421240
Generates a new key pair of desired length **size**.
12431241
"""
1242+
if rng is None:
1243+
rng = Random()
12441244
ecc = cls(rng=rng)
1245+
12451246
ret = _lib.wc_ecc_make_key(ecc._rng.native_object, size,
12461247
ecc.native_object)
12471248
if ret < 0:

0 commit comments

Comments
 (0)