Skip to content

It isn't possible to encrypt binary data !? #553

Closed
@user163

Description

@user163

Version(s) affected

3.3

Description

In this JWE example, the following can be read as a comment on the payload:

The payload we want to encrypt. It MUST be a string

and indeed if the message is not a UTF-8 compatible byte sequence, an

InvalidArgumentException: The payload must be encoded in UTF-8

is thrown.

Why is there this constraint, i.e. why can't the payload be any byte sequence? In RFC7516 JWE this restriction does not seem to be specified. Other JWE implementations, such as JWCrypto allow arbitrary byte sequences.

How to reproduce

Run the linked example and use a non-UTF-8 compliant byte sequence as payload.

Possible Solution

The restriction to UTF-8 compatible byte sequences as payload should be removed. It should be possible to use any byte sequence as payload.

Additional Context

There is a similar (meanwhile fixed) bug, but in the context of signing detachd payloads: #491.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions