@@ -275,10 +275,39 @@ def validate_corim_compliance():
275275 encryption_algorithm = serialization .NoEncryption ()
276276 )
277277
278- if report .sign_corim_report_pem (private_pem , "ES512" , "test-validation-key" ):
278+ # Sign the CoRIM report
279+ signing_result = report .sign_corim_report_pem (private_pem , "ES512" , "test-validation-key" )
280+ if signing_result :
279281 signed_corim = report .get_signed_corim_report ()
280282 print (f"✓ CoRIM signing successful ({ len (signed_corim )} bytes)" )
281283 print ("✓ COSE-Sign1 format with cwt library" )
284+
285+ # Validate the signature is actually valid
286+ try :
287+ import cwt
288+ from cwt import COSEKey
289+
290+ # Extract public key from private key for verification
291+ public_key = private_key .public_key ()
292+ public_pem = public_key .public_bytes (
293+ encoding = serialization .Encoding .PEM ,
294+ format = serialization .PublicFormat .SubjectPublicKeyInfo
295+ )
296+
297+ # Create COSE key for verification with proper key ID
298+ cose_key = COSEKey .from_pem (public_pem , kid = "test-validation-key" )
299+
300+ # Verify the signature
301+ verified_payload = cwt .decode (signed_corim , cose_key )
302+ if verified_payload :
303+ print ("✓ Signature verification successful" )
304+ else :
305+ print ("✗ Signature verification failed - invalid signature" )
306+ return False
307+
308+ except Exception as verify_error :
309+ print (f"✗ Signature verification failed: { verify_error } " )
310+ return False
282311 else :
283312 print ("✗ CoRIM signing failed" )
284313 return False
0 commit comments