@@ -1025,7 +1025,7 @@ def fixture_data(self, backend) -> bytes:
1025
1025
@pytest .fixture (name = "certificate" )
1026
1026
def fixture_certificate (self , backend ) -> x509 .Certificate :
1027
1027
return load_vectors_from_file (
1028
- os .path .join ("pkcs7" , "verify_cert .pem" ),
1028
+ os .path .join ("pkcs7" , "ca .pem" ),
1029
1029
loader = lambda pemfile : x509 .load_pem_x509_certificate (
1030
1030
pemfile .read ()
1031
1031
),
@@ -1035,7 +1035,7 @@ def fixture_certificate(self, backend) -> x509.Certificate:
1035
1035
@pytest .fixture (name = "private_key" )
1036
1036
def fixture_private_key (self , backend ) -> types .PrivateKeyTypes :
1037
1037
return load_vectors_from_file (
1038
- os .path .join ("pkcs7" , "verify_key .pem" ),
1038
+ os .path .join ("pkcs7" , "ca_key .pem" ),
1039
1039
lambda pemfile : serialization .load_pem_private_key (
1040
1040
pemfile .read (), None , unsafe_skip_rsa_key_validation = True
1041
1041
),
@@ -1197,18 +1197,20 @@ def test_pkcs7_verify_der_wrong_certificate(
1197
1197
with pytest .raises (ValueError ):
1198
1198
pkcs7 .pkcs7_verify_der (signature , certificate = rsa_certificate )
1199
1199
1200
- def test_pkcs7_verify_der_unsupported_digest_algorithm (
1201
- self , backend , data , certificate , private_key
1200
+ def test_pkcs7_verify_der_unsupported_rsa_digest_algorithm (
1201
+ self , backend , data
1202
1202
):
1203
- # Signature
1203
+ certificate , private_key = _load_rsa_cert_key ()
1204
+
1205
+ # Signature with an unsupported digest algorithm
1204
1206
builder = (
1205
1207
pkcs7 .PKCS7SignatureBuilder ()
1206
1208
.set_data (data )
1207
1209
.add_signer (certificate , private_key , hashes .SHA384 ())
1208
1210
)
1209
1211
signature = builder .sign (serialization .Encoding .DER , [])
1210
1212
1211
- # Verification with another certificate
1213
+ # Verification
1212
1214
with pytest .raises (exceptions .UnsupportedAlgorithm ):
1213
1215
pkcs7 .pkcs7_verify_der (signature )
1214
1216
@@ -1268,9 +1270,7 @@ def test_pkcs7_verify_smime_with_content(
1268
1270
# Verification
1269
1271
pkcs7 .pkcs7_verify_smime (signed , content = data )
1270
1272
1271
- def test_pkcs7_verify_smime_opaque_signing (
1272
- self , backend , data , certificate , private_key
1273
- ):
1273
+ def test_pkcs7_verify_smime_opaque_signing (self , backend ):
1274
1274
# Signature
1275
1275
signed = load_vectors_from_file (
1276
1276
os .path .join ("pkcs7" , "signed-opaque.msg" ),
@@ -1288,9 +1288,7 @@ def test_pkcs7_verify_smime_opaque_signing(
1288
1288
b"Content-Type: multipart/signed;\n Hello world!" ,
1289
1289
],
1290
1290
)
1291
- def test_pkcs7_verify_smime_wrong_format (
1292
- self , backend , data , certificate , signature
1293
- ):
1291
+ def test_pkcs7_verify_smime_wrong_format (self , backend , signature ):
1294
1292
with pytest .raises (ValueError ):
1295
1293
pkcs7 .pkcs7_verify_smime (signature )
1296
1294
0 commit comments