Skip to content

Commit a4094f2

Browse files
committed
kmgmt: Update match to compare the public parts of the key
The private key and public can only be compared using the public parts of the RSA key. Only if the match succeeds we can consider that a public key is related to the corresponding private key. Signed-off-by: Gowtham Suresh Kumar <[email protected]>
1 parent 64e7c58 commit a4094f2

File tree

1 file changed

+4
-4
lines changed
  • parsec-openssl-provider/src/keymgmt

1 file changed

+4
-4
lines changed

parsec-openssl-provider/src/keymgmt/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ pub unsafe extern "C" fn parsec_provider_kmgmt_match(
372372
return Err("One of the keydatas to compare is null".into());
373373
}
374374

375-
if selection & OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS as std::os::raw::c_int != 0 {
375+
if selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY as std::os::raw::c_int != 0 {
376376
Arc::increment_strong_count(keydata1 as *const RwLock<ParsecProviderKeyObject>);
377377
Arc::increment_strong_count(keydata2 as *const RwLock<ParsecProviderKeyObject>);
378378

@@ -382,13 +382,13 @@ pub unsafe extern "C" fn parsec_provider_kmgmt_match(
382382
let reader_key_data1 = key_data1.read().unwrap();
383383
let reader_key_data2 = key_data2.read().unwrap();
384384

385-
if reader_key_data1.key_name == reader_key_data2.key_name {
385+
if reader_key_data1.get_rsa_key() == reader_key_data2.get_rsa_key() {
386386
Ok(OPENSSL_SUCCESS)
387387
} else {
388-
Err("Key names do not match".into())
388+
Err("Public parts of the keys do not match".into())
389389
}
390390
} else {
391-
Ok(OPENSSL_SUCCESS)
391+
Err("Keys do not match".into())
392392
}
393393
});
394394

0 commit comments

Comments
 (0)