http_message_signatures/signer

Public signing API.

Types

pub type CombineError {
  EmptySignatureList
  DuplicateLabel(String)
}

Constructors

  • EmptySignatureList
  • DuplicateLabel(String)
pub type SignError {
  UnsupportedAlgorithm(String)
  ComponentError(component.ComponentError)
}

Constructors

One signature produced by sign_one, not yet packed into header values. combine composes one or more of these into a SignedHeaders — the unit that supports signing the same message multiple times.

pub type Signed {
  Signed(
    label: String,
    params_element: types.Element,
    signature_bytes: BitArray,
  )
}

Constructors

  • Signed(
      label: String,
      params_element: types.Element,
      signature_bytes: BitArray,
    )
pub type SignedHeaders {
  SignedHeaders(signature_input: String, signature: String)
}

Constructors

  • SignedHeaders(signature_input: String, signature: String)

Values

pub fn combine(
  signed: List(Signed),
) -> Result(SignedHeaders, CombineError)

Packs one or more independently-produced Signed values (see sign_one) into a single Signature-Input/Signature header pair, per RFC 9421’s dictionary-of-labels model for multiple signatures on the same message. Fails if signed is empty or if two entries share a label — each signature on a message must have a distinct label.

pub fn sign(
  message: message.Message,
  private_key: eddsa.PrivateKey,
  label: String,
  signature_params: params.SignatureParams,
) -> Result(SignedHeaders, SignError)

Signs message, covering signature_params.components, and returns the Signature-Input/Signature header values to attach to the outgoing message. This library only computes header values — it does not touch a transport-layer request object.

Only the "ed25519" algorithm is implemented: any other signature_params.algorithm value short-circuits with UnsupportedAlgorithm before any component canonicalization or crypto happens.

To sign the same message multiple times (e.g. once by the client, once by a forwarding proxy, each potentially with a different key or covered component set), use sign_one and combine instead: RFC 9421 models each signature independently, so composing several Signed values is more flexible than a single call that takes a list of labels.

pub fn sign_one(
  message: message.Message,
  private_key: eddsa.PrivateKey,
  label: String,
  signature_params: params.SignatureParams,
) -> Result(Signed, SignError)

Produces a single signature without packing it into header values, so it can be combined with others via combine to sign one message multiple times under different labels. Prefer sign for the common single- signature case.

Search Document