@@ -67,10 +67,10 @@ def from_raw(cls, private_raw):
67
67
68
68
@classmethod
69
69
def from_raw_public (cls , public_raw ):
70
- key = ec .EllipticCurvePublicNumbers .from_encoded_point (
70
+ key = ec .EllipticCurvePublicKey .from_encoded_point (
71
71
curve = ec .SECP256R1 (),
72
72
data = b64urldecode (public_raw )
73
- ). public_key ( default_backend ())
73
+ )
74
74
ss = cls ()
75
75
ss ._public_key = key
76
76
return ss
@@ -258,13 +258,13 @@ def _base_sign(self, claims):
258
258
cclaims = copy .deepcopy (claims )
259
259
if not cclaims .get ('exp' ):
260
260
cclaims ['exp' ] = str (int (time .time ()) + 86400 )
261
- if not re .match (" mailto:.+@.+\..+" ,
261
+ if not re .match (r' mailto:.+@.+\..+' ,
262
262
cclaims .get ('sub' , '' ),
263
263
re .IGNORECASE ):
264
264
raise VapidException (
265
265
"Missing 'sub' from claims. "
266
266
"'sub' is your admin email as a mailto: link." )
267
- if not re .match ("^https?:\/\ /[^\/\ .:]+\.[^\ /:]+(:\d+)?$" ,
267
+ if not re .match (r "^https?:/ /[^/ .:]+\.[^/:]+(:\d+)?$" ,
268
268
cclaims .get ("aud" , "" ),
269
269
re .IGNORECASE ):
270
270
raise VapidException (
@@ -289,7 +289,10 @@ def sign(self, claims, crypto_key=None):
289
289
sig = sign (self ._base_sign (claims ), self .private_key )
290
290
pkey = 'p256ecdsa='
291
291
pkey += b64urlencode (
292
- self .public_key .public_numbers ().encode_point ())
292
+ self .public_key .public_bytes (
293
+ serialization .Encoding .X962 ,
294
+ serialization .PublicFormat .UncompressedPoint
295
+ ))
293
296
if crypto_key :
294
297
crypto_key = crypto_key + ';' + pkey
295
298
else :
@@ -309,7 +312,10 @@ class Vapid02(Vapid01):
309
312
310
313
def sign (self , claims , crypto_key = None ):
311
314
sig = sign (self ._base_sign (claims ), self .private_key )
312
- pkey = self .public_key .public_numbers ().encode_point ()
315
+ pkey = self .public_key .public_bytes (
316
+ serialization .Encoding .X962 ,
317
+ serialization .PublicFormat .UncompressedPoint
318
+ )
313
319
return {
314
320
"Authorization" : "{schema} t={t},k={k}" .format (
315
321
schema = self ._schema ,
0 commit comments