Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misleading Function Prototype #1847

Open
MatusKysel opened this issue Nov 11, 2024 · 0 comments
Open

Misleading Function Prototype #1847

MatusKysel opened this issue Nov 11, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@MatusKysel
Copy link
Contributor

Is your feature request related to a problem? Please describe.
In the package github.com/ssv-labs/ssv/utils/rsaencryption, the following function is
defined:

// DecodeKey with secret key (rsa) and hash (base64), return the decrypted key
func DecodeKey(sk *rsa.PrivateKey, hash []byte) ([]byte, error) {
decryptedKey, err := rsa.DecryptPKCS1v15(rand.Reader, sk, hash)
if err != nil {
return nil, errors.Wrap(err, "could not decrypt key")
}
return decryptedKey, nil
}

Describe the solution you'd like
Rather than simply a decoding function, it is a decryption function. Its hash argument is not a hash but a
ciphertext. This is confusing for readers, who have to check the implementation of the function to find out
that it is in fact performing PKCS1v1.5 decryption.

Additional context
This is result of the dkg audit

@MatusKysel MatusKysel added the enhancement New feature or request label Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant