1515def create_signed_data_from_json (path : str ) -> str :
1616 data = read_data_from_file (path )
1717 decoded_data = json .loads (data )
18- private_key = ec .generate_private_key (ES256 ).private_bytes (encoding = serialization .Encoding .PEM , format = serialization .PrivateFormat .TraditionalOpenSSL , encryption_algorithm = serialization .NoEncryption ()).decode ()
18+ private_key = ec .generate_private_key (ec . SECP256R1 ).private_bytes (encoding = serialization .Encoding .PEM , format = serialization .PrivateFormat .TraditionalOpenSSL , encryption_algorithm = serialization .NoEncryption ()).decode ()
1919 return jwt .encode (payload = decoded_data , key = private_key , algorithm = 'ES256' )
2020
2121def decode_json_from_signed_date (data : str ) -> Dict [str , Any ]:
22- public_key = ec .generate_private_key (ES256 ).public_key ().public_bytes (encoding = serialization .Encoding .PEM , format = serialization .PublicFormat .SubjectPublicKeyInfo ).decode ()
22+ public_key = ec .generate_private_key (ec . SECP256R1 ).public_key ().public_bytes (encoding = serialization .Encoding .PEM , format = serialization .PublicFormat .SubjectPublicKeyInfo ).decode ()
2323 return decode_complete (jwt = data , key = public_key , algorithms = ['ES256' ], options = {"verify_signature" : False })
2424
2525def read_data_from_file (path : str ) -> str :
@@ -32,10 +32,6 @@ def read_data_from_binary_file(path: str) -> str:
3232 with open (full_path , mode = 'rb' ) as test_file :
3333 return test_file .read ()
3434
35- class ES256 (ec .EllipticCurve ):
36- name = "prime256v1"
37- key_size = 256
38-
3935def get_signed_data_verifier (env : Environment , bundle_id : str , app_apple_id : int = 1234 ) -> SignedDataVerifier :
4036 verifier = SignedDataVerifier ([read_data_from_binary_file ('tests/resources/certs/testCA.der' )], False , env , bundle_id , app_apple_id )
4137 verifier ._chain_verifier .enable_strict_checks = False # We don't have authority identifiers on test certs
0 commit comments