@@ -1020,7 +1020,7 @@ def fixture_data(self, backend) -> bytes:
1020
1020
@pytest .fixture (name = "certificate" )
1021
1021
def fixture_certificate (self , backend ) -> x509 .Certificate :
1022
1022
return load_vectors_from_file (
1023
- os .path .join ("pkcs7" , "verify_cert .pem" ),
1023
+ os .path .join ("pkcs7" , "ca .pem" ),
1024
1024
loader = lambda pemfile : x509 .load_pem_x509_certificate (
1025
1025
pemfile .read ()
1026
1026
),
@@ -1030,7 +1030,7 @@ def fixture_certificate(self, backend) -> x509.Certificate:
1030
1030
@pytest .fixture (name = "private_key" )
1031
1031
def fixture_private_key (self , backend ) -> types .PrivateKeyTypes :
1032
1032
return load_vectors_from_file (
1033
- os .path .join ("pkcs7" , "verify_key .pem" ),
1033
+ os .path .join ("pkcs7" , "ca_key .pem" ),
1034
1034
lambda pemfile : serialization .load_pem_private_key (
1035
1035
pemfile .read (), None , unsafe_skip_rsa_key_validation = True
1036
1036
),
@@ -1192,18 +1192,20 @@ def test_pkcs7_verify_der_wrong_certificate(
1192
1192
with pytest .raises (ValueError ):
1193
1193
pkcs7 .pkcs7_verify_der (signature , certificate = rsa_certificate )
1194
1194
1195
- def test_pkcs7_verify_der_unsupported_digest_algorithm (
1196
- self , backend , data , certificate , private_key
1195
+ def test_pkcs7_verify_der_unsupported_rsa_digest_algorithm (
1196
+ self , backend , data
1197
1197
):
1198
- # Signature
1198
+ certificate , private_key = _load_rsa_cert_key ()
1199
+
1200
+ # Signature with an unsupported digest algorithm
1199
1201
builder = (
1200
1202
pkcs7 .PKCS7SignatureBuilder ()
1201
1203
.set_data (data )
1202
1204
.add_signer (certificate , private_key , hashes .SHA384 ())
1203
1205
)
1204
1206
signature = builder .sign (serialization .Encoding .DER , [])
1205
1207
1206
- # Verification with another certificate
1208
+ # Verification
1207
1209
with pytest .raises (exceptions .UnsupportedAlgorithm ):
1208
1210
pkcs7 .pkcs7_verify_der (signature )
1209
1211
@@ -1263,9 +1265,7 @@ def test_pkcs7_verify_smime_with_content(
1263
1265
# Verification
1264
1266
pkcs7 .pkcs7_verify_smime (signed , content = data )
1265
1267
1266
- def test_pkcs7_verify_smime_opaque_signing (
1267
- self , backend , data , certificate , private_key
1268
- ):
1268
+ def test_pkcs7_verify_smime_opaque_signing (self , backend ):
1269
1269
# Signature
1270
1270
signed = load_vectors_from_file (
1271
1271
os .path .join ("pkcs7" , "signed-opaque.msg" ),
@@ -1283,9 +1283,7 @@ def test_pkcs7_verify_smime_opaque_signing(
1283
1283
b"Content-Type: multipart/signed;\n Hello world!" ,
1284
1284
],
1285
1285
)
1286
- def test_pkcs7_verify_smime_wrong_format (
1287
- self , backend , data , certificate , signature
1288
- ):
1286
+ def test_pkcs7_verify_smime_wrong_format (self , backend , signature ):
1289
1287
with pytest .raises (ValueError ):
1290
1288
pkcs7 .pkcs7_verify_smime (signature )
1291
1289
0 commit comments