Skip to content

Make AES export format compatible with JavaScript Web Crypto (TAG as last element) #29

@MayMeow

Description

@MayMeow

Description:

Currently, the AES encryption export format in this project returns a single concatenated string or buffer in the following order:

[ IV | TAG | CIPHERTEXT ]

However, JavaScript's Web Crypto API (e.g., crypto.subtle.encrypt with AES-GCM) returns the data in this format:

[ IV | CIPHERTEXT | TAG ]

This mismatch causes compatibility issues when trying to decrypt data across platforms (e.g., encrypting in JavaScript and decrypting in this project, or vice versa). For interoperability with modern browsers and the Web Crypto API, it would be helpful to:

  • Either adopt the JavaScript-compatible format as the default: [ IV | CIPHERTEXT | TAG ]
  • Or offer an option/parameter to switch between formats when exporting encrypted data.

Suggested fix:

Introduce a config flag like exportFormat: 'js-compatible' | 'legacy' or similar, to allow for cross-platform compatibility without breaking existing implementations.

Let me know if you’d like a PR for this!


Let me know if you'd like to include example code or error messages as well.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions