def sig.make

bend-kit-jwt@0.11.0.1 · jwt.bend:535

import bend-kit-jwt@0.11.0.1/jwt.bend as Jwt
import Base
import bend-kit-bytes@0.3.3.0/bytes.bend as Bytes

535# The signature of input under key for alg. RS256 and ES256 sign with a PEM private key.
536def sig.make(a: Alg, key: Key, input: Bytes.Bytes) -> IO(Result<&1, &1, Err, Bytes.Bytes>):
537  match a key:
538    case HS256{} Hmac{k}:
539      mac("SHA256", 32, k, input)
540    case HS384{} Hmac{k}:
541      mac("SHA384", 48, k, input)
542    case HS512{} Hmac{k}:
543      mac("SHA512", 64, k, input)
544    case RS256{} Pem{p}:
545      rsa.sign(p, input)
546    case ES256{} Pem{p}:
547      ec.sign(p, input)
548    case _ _:
549      IO.pure(Result<&1, &1, Err, Bytes.Bytes>, Fail{KeyType{}})

Uses (10)

Used by (1)