diff --git a/sdk/attestation/azure-security-attestation/tests/test_attestation_token.py b/sdk/attestation/azure-security-attestation/tests/test_attestation_token.py index b77d14c9df33..1142be7d33c7 100644 --- a/sdk/attestation/azure-security-attestation/tests/test_attestation_token.py +++ b/sdk/attestation/azure-security-attestation/tests/test_attestation_token.py @@ -11,6 +11,7 @@ from typing import Dict import unittest from cryptography import x509 +from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import hashes, serialization from cryptography.hazmat.primitives.asymmetric.dsa import DSAPublicKey from devtools_testutils import AzureTestCase, ResourceGroupPreparer, PowerShellPreparer @@ -116,21 +117,21 @@ def callback(token, signer): # Helper functions to create keys and certificates wrapping those keys. @staticmethod def _create_ecds_key(): #type() -> EllipticCurvePrivateKey - return ec.generate_private_key(ec.SECP256R1()).private_bytes( + return ec.generate_private_key(ec.SECP256R1(), backend=default_backend()).private_bytes( serialization.Encoding.DER, serialization.PrivateFormat.PKCS8, serialization.NoEncryption()) @staticmethod def _create_rsa_key(): #type() -> EllipticCurvePrivateKey - return rsa.generate_private_key(65537, 2048).private_bytes( + return rsa.generate_private_key(65537, 2048, backend=default_backend()).private_bytes( serialization.Encoding.DER, serialization.PrivateFormat.PKCS8, serialization.NoEncryption()) @staticmethod def _create_x509_certificate(key_der, subject_name): #type(Union[EllipticCurvePrivateKey,RSAPrivateKey], str) -> Certificate - signing_key = serialization.load_der_private_key(key_der, password=None) + signing_key = serialization.load_der_private_key(key_der, password=None, backend=default_backend()) builder = CertificateBuilder() builder = builder.subject_name(x509.Name([ x509.NameAttribute(NameOID.COMMON_NAME, subject_name), diff --git a/sdk/attestation/azure-security-attestation/tests/test_policy_getset.py b/sdk/attestation/azure-security-attestation/tests/test_policy_getset.py index 556d71bdf7dd..dc6dbf00aa2f 100644 --- a/sdk/attestation/azure-security-attestation/tests/test_policy_getset.py +++ b/sdk/attestation/azure-security-attestation/tests/test_policy_getset.py @@ -24,6 +24,7 @@ import functools import cryptography import cryptography.x509 +from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import serialization import base64 import pytest @@ -83,7 +84,7 @@ def test_aad_set_policy_sgx_unsecured(self, attestation_aad_url): assert policy_get_response.value == attestation_policy expected_policy = AttestationToken(body=StoredAttestationPolicy(attestation_policy=str(attestation_policy).encode('utf-8'))) - hasher = hashes.Hash(hashes.SHA256()) + hasher = hashes.Hash(hashes.SHA256(), backend=default_backend()) hasher.update(expected_policy.serialize().encode('utf-8')) expected_hash = hasher.finalize() @@ -106,7 +107,7 @@ def test_aad_set_policy_sgx_secured(self, attestation_aad_url, attestation_polic assert policy_get_response.value == attestation_policy expected_policy = AttestationToken(body=StoredAttestationPolicy(attestation_policy=str(attestation_policy).encode('ascii')), signer=AttestationSigningKey(key, signing_certificate)) - hasher = hashes.Hash(hashes.SHA256()) + hasher = hashes.Hash(hashes.SHA256(), backend=default_backend()) hasher.update(expected_policy.serialize().encode('utf-8')) expected_hash = hasher.finalize() @@ -129,7 +130,7 @@ def test_isolated_set_policy_sgx_secured(self, attestation_isolated_url, attesta assert policy_get_response.value == attestation_policy expected_policy = AttestationToken(body=StoredAttestationPolicy(attestation_policy=str(attestation_policy).encode('ascii')), signer=AttestationSigningKey(key, decoded_cert)) - hasher = hashes.Hash(hashes.SHA256()) + hasher = hashes.Hash(hashes.SHA256(), backend=default_backend()) hasher.update(expected_policy.serialize().encode('utf-8')) expected_hash = hasher.finalize()