P11ex.ECSignature (p11ex v0.4.1)

Copy Markdown View Source

This module provides functions to convert between the raw signature bytes and the ASN.1 encoding of the signature.

Summary

Functions

Convert the raw signature bytes (r and s values) to the ASN.1 encoding of the signature.

Functions

recode_as_asn1(r_and_s_bytes)

@spec recode_as_asn1(binary()) :: {:ok, binary()} | {:error, String.t()}

Convert the raw signature bytes (r and s values) to the ASN.1 encoding of the signature.

Examples

iex> P11ex.ECSignature.recode_as_asn1(<<0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef>>)
{:ok, <<0x30, 0x24, 0x02, 0x01, 0x01, 0x02, 0x01, 0x02>>}

iex> P11ex.ECSignature.recode_as_asn1(<<0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0x01>>)
{:error, "Invalid signature size: 9"}