Skip to content

Commit

Permalink
Add invalid padding warnings to decryption ops
Browse files Browse the repository at this point in the history
Adding `PsaErrorInvalidPadding` and a related warning on
`psa_asymmetric_decrypt` and `psa_cipher_decrypt` to notify clients of
the need for mitigations.

Signed-off-by: Ionut Mihalcea <[email protected]>
  • Loading branch information
ionut-arm committed Jun 29, 2022
1 parent 62d1f5a commit 545b15d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/parsec_client/operations/psa_asymmetric_decrypt.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,17 @@ Decrypt a short message with a private key. Opcode: 11 (`0x000B`)

- `PsaErrorNotPermitted`: The key does not have the `decrypt` flag, or it does not permit the
requested algorithm.
- `PsaErrorInvalidPadding`: The decrypted padding is incorrect. See Warning below.

## Description

This function will decrypt a short message with the private key of the provided key pair.

**WARNING:** In some protocols, when decrypting data, it is essential that the behavior of the
application does not depend on whether the padding is correct, down to precise timing. If the
application must perform a decryption of unauthenticated data, the application writer must take care
not to reveal whether the padding is invalid.

## Contract

[Protobuf](https://github.com/parallaxsecond/parsec-operations/blob/master/protobuf/psa_asymmetric_decrypt.proto)
Expand Down
7 changes: 7 additions & 0 deletions src/parsec_client/operations/psa_cipher_decrypt.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,18 @@ Decrypt a short message with a symmetric cipher. Opcode: 21 (`0x0015`)

- `PsaErrorNotPermitted`: The key does not have the `decrypt` flag, or it does not permit the
requested algorithm.
- `PsaErrorInvalidPadding`: The decrypted padding is incorrect. See Warning below.

## Description

This function will decrypt a short message using the provided initialisation vector (IV).

**Warning:** In some protocols, when decrypting data, it is essential that the behavior of the
application does not depend on whether the padding is correct, down to precise timing. Protocols
that use authenticated encryption are recommended for use by applications, rather than plain
encryption. If the application must perform a decryption of unauthenticated data, the application
writer must take care not to reveal whether the padding is invalid.

## Contract

[Protobuf](https://github.com/parallaxsecond/parsec-operations/blob/master/protobuf/psa_cipher_decrypt.proto)
Expand Down

0 comments on commit 545b15d

Please sign in to comment.