You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pyca rightfully performs consistency checks when importing keys and
these operations are rather expensive. So cache keys once generated so
that repeated uses of the same JWK do not incur undue cost of reloading
the keys from scratch for each subsequent operation.
with a simple test by hand:
$ python
>>> from jwcrypto import jwk
>>> def test():
... key = jwk.JWK.generate(kty='RSA', size=2048)
... for i in range(1000):
... k = key._get_private_key()
...
>>> import timeit
Before the patch:
>>> print(timeit.timeit("test()", setup="from __main__ import test", number=10))
35.80328264506534
After the patch:
>>> print(timeit.timeit("test()", setup="from __main__ import test", number=10))
0.9109518649056554
Resolveslatchset#243
Signed-off-by: Simo Sorce <simo@redhat.com>
Pyca rightfully performs consistency checks when importing keys and
these operations are rather expensive. So cache keys once generated so
that repeated uses of the same JWK do not incur undue cost of reloading
the keys from scratch for each subsequent operation.
with a simple test by hand:
$ python
>>> from jwcrypto import jwk
>>> def test():
... key = jwk.JWK.generate(kty='RSA', size=2048)
... for i in range(1000):
... k = key._get_private_key()
...
>>> import timeit
Before the patch:
>>> print(timeit.timeit("test()", setup="from __main__ import test", number=10))
35.80328264506534
After the patch:
>>> print(timeit.timeit("test()", setup="from __main__ import test", number=10))
0.9109518649056554
Resolves#243
Signed-off-by: Simo Sorce <simo@redhat.com>
We should optimize by keeping round key objects in private variables.
Reference: pyca/cryptography#6301
The text was updated successfully, but these errors were encountered: