hyperledger / aries-askar

Secure storage designed for Hyperledger Aries agents.
Apache License 2.0
58 stars 44 forks source link

Error handling in crypto box #213

Closed angellllk closed 7 months ago

angellllk commented 7 months ago

Hi. I'm submitting this issue in regard to crypto_box_seal_open. Passing a [u8], with length less than 32 as ciphertext, results in a panic (range end index 32 out of range for slice).

let ephem_pk = X25519KeyPair::from_public_bytes(&ciphertext[..CBOX_KEY_LENGTH])?;

It should be checked if the array has the correct length, as it is checked in crypto_box_open:

if buf_len < CBOX_TAG_LENGTH {
        return Err(err_msg!(Encryption, "Invalid size for encrypted data"));
}