]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: jws: implement JWS signing
authorWilliam Lallemand <wlallemand@haproxy.com>
Thu, 6 Mar 2025 16:14:26 +0000 (17:14 +0100)
committerWilliam Lallemand <wlallemand@haproxy.com>
Tue, 11 Mar 2025 21:29:40 +0000 (22:29 +0100)
commit3abb428fc8a001649758585990093ee6da56fc81
treed1fafa12bb7b2797ed40b481872ee8b57275d69d
parent3cbeb6a74b3532be4938409bf10833b893543d1d
MINOR: jws: implement JWS signing

This commits implement JWS signing, this is divided in 3 parts:

- jws_b64_protected() creates a JWS "protected" header, which takes the
  algorithm, kid or jwk, nonce and url as input, and fill a destination
  buffer with the base64url version of the header
- jws_b64_payload() just encode a payload in base64url
- jws_b64_signature() generates a signature using as input the protected
  header and the payload, it supports ES256, ES384 and ES512 for ECDSA
  keys, and RS256 for RSA ones. The RSA signature just use the
  EVP_DigestSign() API with its result encoded in base64url. For ECDSA
  it's a little bit more complicated, and should follow section 3.4 of
  RFC7518, R and S should be padded to byte size.

Then the JWS can be output with jws_flattened() which just formats the 3
base64url output in a JSON representation with the 3 fields, protected,
payload and signature.
src/jws.c