aws / aws/aws-encryption-sdk-java

CryptoOutputStream outputs invalid message when used to encrypt empty plaintext

Open
#218 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
240
Forks
125
PR merge metrics
No merged PRs in 30d

Description

In order to perform the "encrypt a zero length plaintext" using a CryptoOutputStream, the correct setup would be to create the CryptoOutputStream, don't write any bytes to it, then immediately call `close()`.

This results in the CryptoOutputStream only writing bytes for an empty final frame (and possibly a footer). It does not write any header bytes, resulting in an invalid message that cannot be parsed by any AWS Encryption SDK implementation.

This should be fixed such that this use case will correctly write header bytes before the message body and footer, resulting in a message that can be successfully decrypted into the plaintext "".

Contributor guide

Open the contributing guide

Research direction

Start with CryptoOutputStream and reproduce the case that calls close() without writing plaintext. Trace how the empty final frame is emitted and verify that the resulting message can be parsed and decrypted by an AWS Encryption SDK implementation to the empty plaintext.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
cryptography, security
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.