https://github.com/fukamachi/jose
A JOSE implementation
https://github.com/fukamachi/jose
jose jws jwt
Last synced: 3 months ago
JSON representation
A JOSE implementation
- Host: GitHub
- URL: https://github.com/fukamachi/jose
- Owner: fukamachi
- Created: 2017-06-19T03:20:42.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2024-11-25T06:16:35.000Z (7 months ago)
- Last Synced: 2025-02-11T19:13:13.385Z (4 months ago)
- Topics: jose, jws, jwt
- Language: Common Lisp
- Size: 40 KB
- Stars: 34
- Watchers: 5
- Forks: 8
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- trackawesomelist - JOSE (⭐34) - A JSON Object Signing and Encryption (JOSE) implementation for Common Lisp. BSD\_2Clause. (Recently Updated / [Feb 16, 2025](/content/2025/02/16/README.md))
README
# jose
[](http://quickdocs.org/jose/)
[](https://travis-ci.org/fukamachi/jose)
[](https://coveralls.io/r/fukamachi/jose)A JSON Object Signing and Encryption (JOSE) implementation for Common Lisp.
## Usage
### HMAC
```common-lisp
(defvar *key* (ironclad:ascii-string-to-byte-array "my$ecret"))(defvar *token*
(jose:encode :hs256 *key* '(("hello" . "world"))))*token*
;=> "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJoZWxsbyI6IndvcmxkIn0.Vr0VKL9WHX9lUPWzrE0DX4fEvl0_CgnKlzI2mWiro8E"(jose:decode :hs256 *key* *token*)
;=> (("hello" . "world"))
; (("alg" . "HS256") ("typ" . "JWT"));; Decoding without signature verification.
(jose:inspect-token *token*)
;=> (("hello" . "world"))
; (("alg" . "HS256") ("typ" . "JWT"))
; #(142 123 175 222 84 4 134 19 70 182 50 209 29 113 176 40 82 42 241 90 230 91
; 176 235 254 57 221 93 97 220 6 101)
```### RSA
For RSA algorithm, the key must be an instance of Ironclad public/private key, that can be generated with `ironclad:generate-key-pair`.
To read from OpenSSH key files, use [cl-ssh-keys](https://github.com/dnaeon/cl-ssh-keys). To parse ASN.1 keys, [asn1](https://github.com/fukamachi/asn1) library will help.
```common-lisp
;; Generate a new key pairs with Ironclad
(defvar *private-key*
(ironclad:generate-key-pair :rsa :num-bits 2048));; Or, read a private key file generated by OpenSSH
(defvar *private-key*
(ssh-keys:parse-private-key-file #P"~/.ssh/id_rsa"))(defvar *token*
(jose:encode :rs256 *private-key* '(("hello" . "world"))))
```## Supported Algorithms
* HS256
* HS384
* HS512
* RS256
* RS384
* RS512
* PS256
* PS384
* PS512
* none## See Also
* [JOSE Working Group](https://datatracker.ietf.org/wg/jose/about/)
## Author
* Eitaro Fukamachi ([email protected])
## Copyright
Copyright (c) 2017 Eitaro Fukamachi ([email protected])
## License
Licensed under the BSD 2-Clause License.