Function sigRStoASN1

  • convert ECDSA signature value from RS concatinated to ASN.1 encoded

    Parameters

    • hRS: string

      hexadecimal string of R and S concatinated signature value

    Returns string

    ASN.1 DER encoded ECDSA signature value

    See

    sigASN1toRS

    Description

    ECDSA signature value has two types of encoding:

    • R and S value concatinated encoding used in W3C Web Crypto API or JSON Web Signature.
    • ASN.1 SEQUENCE of INTEGER R and S value used in OpenSSL or Java

    This function converts a ECDSA signature encoding from concatinated to ASN.1. This function supports ECDSA signatures by P-256, P-384 and P-521.

    Example

    sigRStoASN1("
    69c3e2489cc23044f91dce1e5efab7a47f8c2a545cdce9b58e408c6a2aabd060
    76ba3d70771c00451adcf608d93f20cc79ccaf872f42028aa05ff57b14e5959f")
    ->
    "3044
    0220
    69c3e2489cc23044f91dce1e5efab7a47f8c2a545cdce9b58e408c6a2aabd060
    0220
    76ba3d70771c00451adcf608d93f20cc79ccaf872f42028aa05ff57b14e5959f"
    // new lines and specs added to understand their structues