Skip to content

Conversation

@gdams
Copy link
Member

@gdams gdams commented Dec 23, 2024

fixes: #22

@gdams gdams requested a review from qmuntal December 23, 2024 22:21
@gdams gdams marked this pull request as draft December 23, 2024 22:36
Comment on lines +114 to +120
if len(plaintext) < len(labelHash) {
return nil, errors.New("invalid ciphertext: missing label hash")
}
// Extract and verify the label hash
if !bytes.Equal(plaintext[:len(labelHash)], labelHash) {
return nil, errors.New("invalid label hash")
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Almost) never use bytes.Equal in crypto code, as it is vulnerable to oracle side channel attacks. Use suble.ConstantTimeCompare. Also, don't short-circuit if the length are not equal, for the same reason.

}
}

func TestRSAEncryptDecryptOAEP(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test that upstream crypto/rsa can decrypt ciphertexts (with labels) generated by us and vice-versa.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RSAOAEP: Add support for passing labels

4 participants