File tree Expand file tree Collapse file tree 3 files changed +4
-29
lines changed
Expand file tree Collapse file tree 3 files changed +4
-29
lines changed Original file line number Diff line number Diff line change 4141 load_pem_public_key ,
4242 load_ssh_public_key ,
4343 )
44- from cryptography .utils import int_from_bytes
4544
4645 has_crypto = True
4746except ImportError :
@@ -466,8 +465,8 @@ def from_jwk(jwk):
466465 raise InvalidKeyError (f"Invalid curve: { curve } " )
467466
468467 public_numbers = ec .EllipticCurvePublicNumbers (
469- x = int_from_bytes (x , "big" ),
470- y = int_from_bytes (y , "big" ),
468+ x = int . from_bytes (x , byteorder = "big" ),
469+ y = int . from_bytes (y , byteorder = "big" ),
471470 curve = curve_obj ,
472471 )
473472
@@ -481,7 +480,7 @@ def from_jwk(jwk):
481480 )
482481
483482 return ec .EllipticCurvePrivateNumbers (
484- int_from_bytes (d , "big" ), public_numbers
483+ int . from_bytes (d , byteorder = "big" ), public_numbers
485484 ).private_key ()
486485
487486 class RSAPSSAlgorithm (RSAAlgorithm ):
Original file line number Diff line number Diff line change 22import os
33
44from jwt .utils import base64url_decode
5- from tests .utils import int_from_bytes
65
76BASE_PATH = os .path .dirname (os .path .abspath (__file__ ))
87
98
109def decode_value (val ):
1110 decoded = base64url_decode (val )
12- return int_from_bytes (decoded , "big" )
11+ return int . from_bytes (decoded , byteorder = "big" )
1312
1413
1514def load_hmac_key ():
Original file line number Diff line number Diff line change 11import os
2- import struct
32from calendar import timegm
43from datetime import datetime
54
@@ -12,25 +11,3 @@ def key_path(key_name):
1211 return os .path .join (
1312 os .path .dirname (os .path .realpath (__file__ )), "keys" , key_name
1413 )
15-
16-
17- # Borrowed from `cryptography`
18- if hasattr (int , "from_bytes" ):
19- int_from_bytes = int .from_bytes
20- else :
21-
22- def int_from_bytes (data , byteorder , signed = False ):
23- assert byteorder == "big"
24- assert not signed
25-
26- if len (data ) % 4 != 0 :
27- data = (b"\x00 " * (4 - (len (data ) % 4 ))) + data
28-
29- result = 0
30-
31- while len (data ) > 0 :
32- (digit ,) = struct .unpack (">I" , data [:4 ])
33- result = (result << 32 ) + digit
34- data = data [4 :]
35-
36- return result
You can’t perform that action at this time.
0 commit comments