JSON Web Keys
JSON Web Keys
Handling keys is the most important feature for the security of your applications. This package provides tools to help you manage them easily.
The JSON Web Keys standard defines JSON representations for each cryptographic key used by JSON Web Algorithms. You may use this representation to easily save and share your keys.
Warning
This package does not provide tools to securely save and share your keys. It helps you to generate them using the correct parameters, and provides easy ways to consume them. However, the mediums used to persist and share those keys are entirely up to you.
The jwk.Key
type
Key managers are built around the jwk.Key
format. This is a special struct that can hold both JSON and concrete key data.
To use the key encoded in a given jwk.Key
object, just call its Key()
method. The object can also be directly marshalled into valid JSON, using the standard encoding/json
package - or any compatible package.
var jsonKey jwk.Key[T]
// The concrete key, that can be directly used for cryptographic operations.
key := jsonKey.Key()
// Produces a valid JSON out-of-the-box, given it was generated by
// the library.
serialized, _ := json.Marshal(jsonKey)