@@ -67,10 +67,10 @@ def from_raw(cls, private_raw):
6767
6868 @classmethod
6969 def from_raw_public (cls , public_raw ):
70- key = ec .EllipticCurvePublicNumbers .from_encoded_point (
70+ key = ec .EllipticCurvePublicKey .from_encoded_point (
7171 curve = ec .SECP256R1 (),
7272 data = b64urldecode (public_raw )
73- ). public_key ( default_backend ())
73+ )
7474 ss = cls ()
7575 ss ._public_key = key
7676 return ss
@@ -258,13 +258,13 @@ def _base_sign(self, claims):
258258 cclaims = copy .deepcopy (claims )
259259 if not cclaims .get ('exp' ):
260260 cclaims ['exp' ] = str (int (time .time ()) + 86400 )
261- if not re .match (" mailto:.+@.+\..+" ,
261+ if not re .match (r' mailto:.+@.+\..+' ,
262262 cclaims .get ('sub' , '' ),
263263 re .IGNORECASE ):
264264 raise VapidException (
265265 "Missing 'sub' from claims. "
266266 "'sub' is your admin email as a mailto: link." )
267- if not re .match ("^https?:\/\ /[^\/\ .:]+\.[^\ /:]+(:\d+)?$" ,
267+ if not re .match (r "^https?:/ /[^/ .:]+\.[^/:]+(:\d+)?$" ,
268268 cclaims .get ("aud" , "" ),
269269 re .IGNORECASE ):
270270 raise VapidException (
@@ -289,7 +289,10 @@ def sign(self, claims, crypto_key=None):
289289 sig = sign (self ._base_sign (claims ), self .private_key )
290290 pkey = 'p256ecdsa='
291291 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+ ))
293296 if crypto_key :
294297 crypto_key = crypto_key + ';' + pkey
295298 else :
@@ -309,7 +312,10 @@ class Vapid02(Vapid01):
309312
310313 def sign (self , claims , crypto_key = None ):
311314 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+ )
313319 return {
314320 "Authorization" : "{schema} t={t},k={k}" .format (
315321 schema = self ._schema ,
0 commit comments