Package jose aims to provide an implementation of the Javascript Object Signing and Encryption set of standards. This includes support for JSON Web Encryption, JSON Web Signature, and JSON Web Token standards.
The implementation follows the
JSON Web Encryption (RFC 7516),
JSON Web Signature (RFC 7515), and
JSON Web Token (RFC 7519) specifications.
Tables of supported algorithms are shown below. The library supports both
the compact and JWS/JWE JSON Serialization formats, and has optional support for
multiple recipients. It also comes with a small command-line utility
(jose-util)
for dealing with JOSE messages in a shell.
Older versions of this package used a forked version of encoding/json, but v5
uses encoding/json/v2. It continues to have case-sensitive matching and
rejection of duplicate field names.
Version 5 is in development on the main branch of this repository. It will be
released with several breaking API changes, and will require Go's
encoding/json/v2 and Go 1.27. In the future it will support at least the
current and previous Go release.
Version 4 is now feature-frozen, receiving only bug fixes.
import "github.com/go-jose/go-jose/v4"
It supports at least the current and previous Go release. Version 4 will be supported until Go 1.29 is released in August 2027.
Version 3 is only receiving critical security updates. Migration to Version 4 is recommended. Version 3 will no longer be supported once Go 1.28 is released in February 2027.
Versions 1 and 2 are obsolete, but can be found in the old repository, square/go-jose.
See below for a table of supported algorithms. Algorithm identifiers match the names in the JSON Web Algorithms standard where possible. The Godoc reference has a list of constants.
| Key encryption | Algorithm identifier(s) |
|---|---|
| RSA-PKCS#1v1.5 | RSA1_5 |
| RSA-OAEP | RSA-OAEP, RSA-OAEP-256 |
| AES key wrap | A128KW, A192KW, A256KW |
| AES-GCM key wrap | A128GCMKW, A192GCMKW, A256GCMKW |
| ECDH-ES + AES key wrap | ECDH-ES+A128KW, ECDH-ES+A192KW, ECDH-ES+A256KW |
| ECDH-ES (direct) | ECDH-ES1 |
| Direct encryption | dir1 |
| Signing / MAC | Algorithm identifier(s) |
|---|---|
| RSASSA-PKCS#1v1.5 | RS256, RS384, RS512 |
| RSASSA-PSS | PS256, PS384, PS512 |
| HMAC | HS256, HS384, HS512 |
| ECDSA | ES256, ES384, ES512 |
| Ed25519 | EdDSA |
| ML-DSA | ML-DSA-44, ML-DSA-65, ML-DSA-87 |
| Content encryption | Algorithm identifier(s) |
|---|---|
| AES-CBC+HMAC | A128CBC-HS256, A192CBC-HS384, A256CBC-HS512 |
| AES-GCM | A128GCM, A192GCM, A256GCM |
| Compression | Algorithm identifiers(s) |
|---|---|
| DEFLATE (RFC 1951) | DEF |
See below for a table of supported key types. These are understood by the
library, and can be passed to corresponding functions such as NewEncrypter or
NewSigner. Each of these keys can also be wrapped in a JWK if desired, which
allows attaching a key id.
| Algorithm(s) | Corresponding types |
|---|---|
| RSA | *rsa.PublicKey, *rsa.PrivateKey |
| ECDH, ECDSA | *ecdsa.PublicKey, *ecdsa.PrivateKey |
| EdDSA1 | ed25519.PublicKey, ed25519.PrivateKey |
| ML-DSA2 | *mldsa.PublicKey, *mldsa.PrivateKey |
| AES, HMAC | []byte |
Examples can be found in the Godoc
reference for this package. The
jose-util
subdirectory also contains a small command-line utility which might be useful
as an example as well.