cose-sign1

2026-11-29

No Description

Upstream URL

github.com/nathanvy/cose-sign1

License

MIT
README

COSE_Sign1 (ES256) for Common Lisp

This library implements a small, focused subset of COSE: COSE_Sign1 messages using ES256 (ECDSA over P-256 with SHA-256).

Dependencies

Example: Verifying a COSE_Sign1 structure

The library expects bytes as a (simple-array (unsigned-byte 8) (*)), for example:

(defun read-u8-file (path)
  (with-open-file (s path :element-type '(unsigned-byte 8))
    (let* ((n (file-length s))
           (v (make-array n :element-type '(unsigned-byte 8))))
      (read-sequence v s)
      v)))

Build a P256 key using 32-byte big-endian byte vectors

(let* ((x-bytes ...32 bytes...)
       (y-bytes ...32 bytes...)
       (pub (cose:p256-jwk->public-key x-bytes y-bytes)))
  ...)

Verify

(let* ((cose-bytes (read-u8-file "message.cose"))
       (payload (multiple-value-bind (payload info)
                    (cose:verify1 cose-bytes pub)
                  (declare (ignore info))
                  payload)))
  ;; PAYLOAD is the embedded payload bytes (or the detached payload you supplied)
  payload)

Dependencies (3)

  • alexandria
  • cbor
  • ironclad

Dependents (0)

    • GitHub
    • Quicklisp