Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: trim base64 input before attempting decryption #25

Merged
merged 1 commit into from
May 2, 2024

Conversation

sergio-correia
Copy link
Contributor

As the decryption input is base64-encoded, we can safely trim leading and trailing whitespace from it.

If the input has a newline, it will fail validation, e.g:

jwe="$(echo "foobar" | clevis-pin-tpm2 encrypt {})"
echo "${jwe}" | clevis-pin-tpm2 decrypt
Error: Error decrypting JWE

Caused by:
    0: Invalid JWE format: Invalid byte 10, offset 22.
    1: Invalid byte 10, offset 22.

Also include additional integration tests written in shell script.

As the decryption input is base64-encoded, we can safely trim
leading and trailing whitespace from it.

If the input has a newline, it will fail validation, e.g:

```
jwe="$(echo "foobar" | clevis-pin-tpm2 encrypt {})"
echo "${jwe}" | clevis-pin-tpm2 decrypt
Error: Error decrypting JWE

Caused by:
    0: Invalid JWE format: Invalid byte 10, offset 22.
    1: Invalid byte 10, offset 22.
```

Also include additional integration tests written in shell script.

Signed-off-by: Sergio Correia <[email protected]>
Copy link
Member

@nullr0ute nullr0ute left a comment

Choose a reason for hiding this comment

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

LGTM

@nullr0ute nullr0ute merged commit ed95396 into fedora-iot:main May 2, 2024
3 checks passed
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.

2 participants