• get value from parsed ASN.1

    Parameters

    • pASN: ASN1Object

      JSON object of parsed ASN.1 structure

    • key: string

      dot concatinated string of ASN.1 tag name or index of structured object

    • Optional defaultValue: any

      default return value when ASN.1 item can't be found

    Returns ASN1Value | ASN1Object

    item identified by key. When item is not found, return defaultValue

    Describe

    This function will get an item refered by "key" in "pASN" which may be created by the function asn1parse. When the item identified by "key" isn't found, it returns undefined or "defaultValue".

    Example

    const parsedASN = {
    t: "seq",
    v: [
    {t:"int", v:"01"},
    {t:"seq", v:[{t:"utf8str", v:{str: "test"}}]}
    ]
    };
    dig(parsedASN, "seq.0") -> {t:"int", v:"01"}
    dig(parsedASN, "seq.1.seq.0.utf8str") -> {str: "test"}
    dig(parsedASN, "utctime", null) -> null // not found