Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
fix: add memory pressure for jwt's cryptography usage
Browse files Browse the repository at this point in the history
related to cffi issue #320: pypy's GC isn't aware of many of
cryptography's allocations, manually add pressure for now so it keeps
up

Closes #917
  • Loading branch information
pjenvey committed Jun 28, 2017
1 parent b839bb5 commit 6719a32
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions autopush/jwt.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import base64
import binascii
import json
try:
from __pypy__ import add_memory_pressure
except ImportError:
def add_memory_pressure(estimate):
pass

from cryptography.exceptions import InvalidSignature
from cryptography.hazmat.backends import default_backend
Expand Down Expand Up @@ -89,6 +94,10 @@ def decode(token, key):
ec.SECP256R1(),
key
).public_key(default_backend())

# cffi issue #320: public_key & verify allocate approx.
add_memory_pressure(144)

# NOTE: verify() will take any string as the signature. It appears
# to be doing lazy verification and matching strings rather than
# comparing content values. If the signatures start failing for
Expand Down

0 comments on commit 6719a32

Please sign in to comment.