microsoft / CCF

Confidential Consortium Framework
https://microsoft.github.io/CCF/
Apache License 2.0
786 stars 215 forks source link

Fix RSAPublicKey hierarchy and hidden virtual functions #6673

Open maxtropets opened 1 day ago

maxtropets commented 1 day ago

List of problems to solve while refactoring the interface for signature verification

maxtropets commented 18 hours ago

A sketch partially displaying the current state.

I'm confused about a real purpose of having verifying methods in (RSA)KeyPair interface, while we could have KeyPair as a child of PublicKey, so we won't copy verification interface, as well as public_key_der(), public_key_pem, etc.

Image

maxtropets commented 15 hours ago

Suspected #6405 to hide the verify(args..., md) overloads by adding salt_size, but ruled that out, because it turns out the PublicKey::verify(args, md) is not virtual (🤦).

Instead, it has an implementation, which computes a hash of the contents and them calls virtual verify(args, md, hash_out)

However, salt_size shall also be removed, as it doesn't fit the common interface. I'm thinking of some sort of separate params struct/variant to pass depending on the underlying key type, and leave signature and contents as the only interface.