Skip to content

Commit

Permalink
Merge pull request trussed-dev#4 from robin-nitrokey/overlong-credent…
Browse files Browse the repository at this point in the history
…ial-id

Return error if credential ID is too long
  • Loading branch information
robin-nitrokey authored Aug 3, 2022
2 parents b0408cb + 184e667 commit 4022d6c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/credential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ impl Credential {
let nonce: [u8; 12] = self.nonce.as_slice().try_into().unwrap();
let encrypted_serialized_credential = EncryptedSerializedCredential(syscall!(trussed
.encrypt_chacha8poly1305(key_encryption_key, message, associated_data, Some(&nonce))));
let credential_id: CredentialId = encrypted_serialized_credential.try_into().unwrap();
let credential_id: CredentialId = encrypted_serialized_credential.try_into()
.map_err(|_| Error::RequestTooLarge)?;

Ok(credential_id)
}
Expand Down

0 comments on commit 4022d6c

Please sign in to comment.