Skip to content

fix: hint that ciphertext may be base64 encoded - #820

Open
evgpisarchik wants to merge 1 commit into
aws:masterfrom
evgpisarchik:fix/base64-encoded-message-hint-192
Open

evgpisarchik wants to merge 1 commit into
aws:masterfrom
evgpisarchik:fix/base64-encoded-message-hint-192

Conversation

@evgpisarchik

Copy link
Copy Markdown

Why

decrypt expects binary ciphertext, but callers may accidentally pass Base64-encoded ciphertext. The message prefixes are transformed as follows:

  • V1: 0x01 0x80 -> 0x41 0x59 (AY)
  • V2: 0x02 0x04/0x05 -> 0x41 0x67 (Ag)

The parser interprets the leading 0x41 as version 65 and currently returns the generic Unsupported version 65 error.

What changed

deserialize_header now recognizes both Base64 prefixes and reports that the message may be Base64 encoded. Valid messages and other invalid inputs retain their existing behavior.

Tests cover both V1 and V2 messages.

Fixes #192

A base64-encoded message starts with 0x41 0x59 (V1) or 0x41 0x67 (V2)
and currently fails with the generic "Unsupported version 65".
deserialize_header now detects these byte pairs and says the message
may be base64 encoded. Valid messages are handled exactly as before.

Fixes aws#192

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@evgpisarchik
evgpisarchik requested a review from a team as a code owner September 13, 2026 16:19
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.

Base64 error messaging in version and type verification

1 participant