Class Index | File Index

Classes


Class ASN1HEX

ASN.1 DER encoded hexadecimal string utility class
Defined in: asn1hex-1.1.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
ASN.1 DER encoded hexadecimal string utility class This class provides a parser for hexadecimal string of DER encoded ASN.1 binary data.
Method Summary
Method Attributes Method Name and Description
<static>  
ASN1HEX.checkStrictDER(hex)
strict ASN.1 DER hexadecimal string checker This method checks wheather the argument 'hex' is a hexadecimal string of ASN.1 data or not.
<static>  
ASN1HEX.dump(hexOrObj, flags, idx, indent)
get string of simple ASN.1 dump from hexadecimal ASN.1 data
This method will get an ASN.1 dump from hexadecmal string of ASN.1 DER encoded data.
<static>  
ASN1HEX.getChildIdx(h, idx)
get array of string indexes of child ASN.1 objects
This method returns array of integers for a concatination of ASN.1 objects in a ASN.1 value.
<static>  
ASN1HEX.getIdxbyList(h, currentIndex, nthList, checkingTag)
get string index of nth child object of ASN.1 object refered by h, idx
<static>  
ASN1HEX.getIdxbyListEx(h, currentIndex, nthList, checkingTag)
get string index of nth child object of ASN.1 object refered by h, idx
This method returns the string index in h specified by currentIndex and nthList.
<static>  
ASN1HEX.getInt(h, idx, errorReturn)
get integer value from ASN.1 V(value) of Integer or BitString
<static>  
ASN1HEX.getL(s, idx)
get hexadecimal string for ASN.1 L(length) bytes
<static>  
ASN1HEX.getLblen(s, idx)
get byte length for ASN.1 L(length) bytes
<static>  
ASN1HEX.getNextSiblingIdx(s, idx)
get next sibling starting index for ASN.1 object string (DEPRECATED)
<static>  
ASN1HEX.getNthChildIdx(h, idx, nth)
get string index of nth child object of ASN.1 object refered by h, idx
<static>  
ASN1HEX.getOID(h, idx, errorReturn)
get object identifier string from ASN.1 V(value)
<static>  
ASN1HEX.getOIDName(h, idx, errorReturn)
get object identifier name from ASN.1 V(value)
This static method returns object identifier name such as "sha256" if registered.
<static>  
ASN1HEX.getString(h, idx, errorReturn)
get raw string from ASN.1 V(value)
This static method returns a raw string from any ASN.1 DER primitives.
<static>  
ASN1HEX.getTLV(s, idx)
get hexadecimal string of ASN.1 TLV at
<static>  
ASN1HEX.getTLVblen(h, idx)
get byte length of ASN.1 TLV at specified string index
This method returns a byte length of ASN.1 TLV at specified string index.
<static>  
ASN1HEX.getTLVbyList(h, currentIndex, nthList, checkingTag)
get ASN.1 TLV by nthList
This static method is to get a ASN.1 value which specified "nthList" position with checking expected tag "checkingTag".
<static>  
ASN1HEX.getTLVbyListEx(h, currentIndex, nthList, checkingTag)
get ASN.1 TLV by nthList
This static method is to get a ASN.1 value which specified "nthList" position with checking expected tag "checkingTag".
<static>  
ASN1HEX.getV(s, idx)
get hexadecimal string of ASN.1 V(value)
<static>  
ASN1HEX.getVblen(s, idx)
get integer value of ASN.1 length for ASN.1 data
<static>  
ASN1HEX.getVbyList(h, currentIndex, nthList, checkingTag, removeUnusedbits)
get ASN.1 value by nthList
This static method is to get a ASN.1 value which specified "nthList" position with checking expected tag "checkingTag".
<static>  
ASN1HEX.getVbyListEx(h, currentIndex, nthList, checkingTag, removeUnusedbits)
get ASN.1 V by nthList
This static method is to get a ASN.1 value which specified "nthList" position with checking expected tag "checkingTag".
<static>  
ASN1HEX.getVidx(s, idx)
get ASN.1 value starting string position for ASN.1 object refered by index 'idx'.
<static>  
ASN1HEX.hextooidstr(hex)
get OID string from hexadecimal encoded value
This static method converts from ASN.1 DER encoded hexadecimal object identifier value to dot concatinated OID value.
<static>  
ASN1HEX.isASN1HEX(hex)
simple ASN.1 DER hexadecimal string checker
This method checks wheather the argument 'hex' is a hexadecimal string of ASN.1 data or not.
<static>  
ASN1HEX.isContextTag(hex, context)
check if a hexadecimal tag is a specified ASN.1 context specific tag This method checks if a hexadecimal tag is a specified ASN.1 context specific tag.
<static>  
ASN1HEX.oidname(oidDotOrHex)
get hexacedimal string from PEM format data
This static method gets a OID name for a specified string of number dot notation (i.e.
<static>  
ASN1HEX.parse(h)
parse ASN.1 DER hexadecimal string
This method parses ASN.1 DER hexadecimal string.
Class Detail
ASN1HEX()
ASN.1 DER encoded hexadecimal string utility class This class provides a parser for hexadecimal string of DER encoded ASN.1 binary data. Here are major methods of this class.
Since:
jsrsasign 1.1
Method Detail
<static> ASN1HEX.checkStrictDER(hex)
strict ASN.1 DER hexadecimal string checker This method checks wheather the argument 'hex' is a hexadecimal string of ASN.1 data or not. If the argument is not DER string, this raise an exception.
ASN1HEX.checkStrictDER('0203012345') → NO EXCEPTION FOR PROPER ASN.1 INTEGER
ASN1HEX.checkStrictDER('0203012345ff') → RAISE EXCEPTION FOR TOO LONG VALUE
ASN1HEX.checkStrictDER('02030123') → false RAISE EXCEPITON FOR TOO SHORT VALUE
ASN1HEX.checkStrictDER('fa3bcd') → false RAISE EXCEPTION FOR WRONG ASN.1
Parameters:
{String} hex
string to check whether it is hexadecmal string for ASN.1 DER or not
Since:
jsrsasign 8.0.19 asn1hex 1.2.1
Throws:
Error when malformed ASN.1 DER hexadecimal string
Returns:
unspecified

<static> {String} ASN1HEX.dump(hexOrObj, flags, idx, indent)
get string of simple ASN.1 dump from hexadecimal ASN.1 data
This method will get an ASN.1 dump from hexadecmal string of ASN.1 DER encoded data. Here are features: NOTE1: Argument KJUR.asn1.ASN1Object object is supported since jsrsasign 6.2.4 asn1hex 1.0.8
// 1) ASN.1 INTEGER
ASN1HEX.dump('0203012345')
↓
INTEGER 012345

// 2) ASN.1 Object Identifier
ASN1HEX.dump('06052b0e03021a')
↓
ObjectIdentifier sha1 (1 3 14 3 2 26)

// 3) ASN.1 SEQUENCE
ASN1HEX.dump('3006020101020102')
↓
SEQUENCE
  INTEGER 01
  INTEGER 02

// 4) ASN.1 SEQUENCE since jsrsasign 6.2.4
o = KJUR.asn1.ASN1Util.newObject({seq: [{int: 1}, {int: 2}]});
ASN1HEX.dump(o)
↓
SEQUENCE
  INTEGER 01
  INTEGER 02
// 5) ASN.1 DUMP FOR X.509 CERTIFICATE
ASN1HEX.dump(pemtohex(certPEM))
↓
SEQUENCE
  SEQUENCE
    [0]
      INTEGER 02
    INTEGER 0c009310d206dbe337553580118ddc87
    SEQUENCE
      ObjectIdentifier SHA256withRSA (1 2 840 113549 1 1 11)
      NULL
    SEQUENCE
      SET
        SEQUENCE
          ObjectIdentifier countryName (2 5 4 6)
          PrintableString 'US'
            :
Parameters:
{Object} hexOrObj
hexadecmal string of ASN.1 data or ASN1Object object
{Array} flags
associative array of flags for dump (OPTION)
{Number} idx
string index for starting dump (OPTION)
{String} indent
indent string (OPTION)
Since:
jsrsasign 4.8.3 asn1hex 1.1.6
Returns:
{String} string of simple ASN.1 dump

<static> {Array of Number} ASN1HEX.getChildIdx(h, idx)
get array of string indexes of child ASN.1 objects
This method returns array of integers for a concatination of ASN.1 objects in a ASN.1 value. As for BITSTRING, one byte of unusedbits is skipped. As for other ASN.1 simple types such as INTEGER, OCTET STRING or PRINTABLE STRING, it returns a array of a string index of its ASN.1 value.
NOTE: Since asn1hex 1.1.7 of jsrsasign 6.1.2, Encapsulated BitString is supported.
ASN1HEX.getChildIdx("0203012345", 0) ⇒ [4] // INTEGER 012345
ASN1HEX.getChildIdx("1303616161", 0) ⇒ [4] // PrintableString aaa
ASN1HEX.getChildIdx("030300ffff", 0) ⇒ [6] // BITSTRING ffff (unusedbits=00a)
ASN1HEX.getChildIdx("3006020104020105", 0) ⇒ [4, 10] // SEQUENCE(INT4,INT5)
Parameters:
{String} h
hexadecimal string of ASN.1 DER encoded data
{Number} idx
start string index of ASN.1 object
Since:
jsrsasign 7.2.0 asn1hex 1.1.11
Returns:
{Array of Number} array of indexes for childen of ASN.1 objects

<static> {Number} ASN1HEX.getIdxbyList(h, currentIndex, nthList, checkingTag)
get string index of nth child object of ASN.1 object refered by h, idx
The "nthList" is a index list of structured ASN.1 object
reference. Here is a sample structure and "nthList"s which
refers each objects.

SQUENCE               - 
  SEQUENCE            - [0]
    IA5STRING 000     - [0, 0]
    UTF8STRING 001    - [0, 1]
  SET                 - [1]
    IA5STRING 010     - [1, 0]
    UTF8STRING 011    - [1, 1]
Parameters:
{String} h
hexadecimal string of ASN.1 DER encoded data
{Number} currentIndex
start string index of ASN.1 object
{Array of Number} nthList
array list of nth
{String} checkingTag
(OPTIONAL) string of expected ASN.1 tag for nthList
Since:
jsrsasign 7.1.4 asn1hex 1.1.10.
Returns:
{Number} string index refered by nthList

<static> {Number} ASN1HEX.getIdxbyListEx(h, currentIndex, nthList, checkingTag)
get string index of nth child object of ASN.1 object refered by h, idx
This method returns the string index in h specified by currentIndex and nthList. This is useful to dig into a deep structured ASN.1 object by indexes called nthList.
A nthList consists of a position number in children of ASN.1 structured data or a context specific tag string (ex. "[1]"). Here is a sample deep structured ASN.1 data and nthLists referring decendent objects.
SQUENCE               - referring nthList is below:
  SEQUENCE            - [0]
    IA5STRING "a1"    - [0, 0]
    UTF8STRING "a2"   - [0, 1]
  SET                 - [1]
    IA5STRING "b1"    - [1, 0]
    UTF8STRING "b2"   - [1, 1]
    [0] "b3"          - [1, "[0]"] // optional since context tag
    [1] "b4"          - [1, "[1]"] // optional since context tag
    IA5STRING "b5"    - [1, 2] // context is skipped. next is 2
    UTF8STRING "b6"   - [1, 3]

This method can dig into ASN.1 object encapsulated by OctetString or BitString with unused bits.
3014 seq idx=0
  3012 seq idx=4
    020101 int:1 idx=8
    020102 int:2 idx=14
    800103 [0]:3 idx=20
    810104 [1]:4 idx=26
    020105 int:5 idx=32
    020106 int:6 idx=38
h = "30140412020101020102800103810104020105020106";
ASN1HEX.getIdxbyListEx(h, 0, [0, "[0]"]) → 16
ASN1HEX.getIdxbyListEx(h, 0, [0, 2]) → 28
ASN1HEX.getIdxbyListEx(h, 0, [0, 2], "0c") → -1 //not UTF8String(0c)
Parameters:
{String} h
hexadecimal string of ASN.1 DER encoded data
{Number} currentIndex
start string index of ASN.1 object
{Array of Object} nthList
array list of nth index value or context specific tag string (ex. "[0]")
{String} checkingTag
(OPTIONAL) string of expected ASN.1 tag for nthList
Since:
jsrsasign 8.0.21 asn1hex 1.2.2
Returns:
{Number} string index refered by nthList. return -1 if not found
See:
ASN1HEX.getIdxbyListEx tutorial wiki page

<static> {Number} ASN1HEX.getInt(h, idx, errorReturn)
get integer value from ASN.1 V(value) of Integer or BitString
ASN1HEX.getInt("xxxx020103xxxxxx", 4) &rarr 3 // DER Integer
ASN1HEX.getInt("xxxx03020780xxxxxx", 4) &rarr 1 // DER BitStringx
ASN1HEX.getInt("xxxx030203c8xxxxxx", 4) &rarr 25 // DER BitStringx
Parameters:
{String} h
hexadecimal string
{Number} idx
string index in h to get ASN.1 DER Integer or BitString
{Object} errorReturn
(OPTION) error return value (DEFAULT: -1)
Since:
jsrsasign 10.1.0 asn1hex 1.2.7
Returns:
{Number} ASN.1 DER Integer or BitString value
See:
bitstrtoint

<static> {String} ASN1HEX.getL(s, idx)
get hexadecimal string for ASN.1 L(length) bytes
Parameters:
{String} s
hexadecimal string of ASN.1 DER encoded data
{Number} idx
string index to get L of ASN.1 object
Since:
jsrsasign 7.2.0 asn1hex 1.1.11
Returns:
{String} hexadecimal string for ASN.1 L(length) bytes

<static> ASN1HEX.getLblen(s, idx)
get byte length for ASN.1 L(length) bytes
ASN1HEX.getLblen('020100', 0) → 1 for '01'
ASN1HEX.getLblen('020200', 0) → 1 for '02'
ASN1HEX.getLblen('02818003...', 0) → 2 for '8180'
ASN1HEX.getLblen('0282025b03...', 0) → 3 for '82025b'
ASN1HEX.getLblen('0280020100...', 0) → -1 for '80' BER indefinite length
ASN1HEX.getLblen('02ffab...', 0) → -2 for malformed ASN.1 length
Parameters:
{String} s
hexadecimal string of ASN.1 DER encoded data
{Number} idx
string index
Since:
jsrsasign 7.2.0 asn1hex 1.1.11
Returns:
byte length for ASN.1 L(length) bytes

<static> {Number} ASN1HEX.getNextSiblingIdx(s, idx)
get next sibling starting index for ASN.1 object string (DEPRECATED)
SEQUENCE { INTEGER 3, INTEGER 4 }
3006
    020103 :idx=4
          020104 :next sibling idx=10
getNextSiblingIdx("3006020103020104", 4) & rarr 10
Parameters:
{String} s
hexadecimal string of ASN.1 DER encoded data
{Number} idx
string index
Deprecated:
jsrsasign 9.1.5 asn1hex 1.2.5 Please use ASN1HEX.getTLVblen
Since:
jsrsasign 7.2.0 asn1hex 1.1.11
Returns:
{Number} next sibling starting index for ASN.1 object string

<static> {Number} ASN1HEX.getNthChildIdx(h, idx, nth)
get string index of nth child object of ASN.1 object refered by h, idx
Parameters:
{String} h
hexadecimal string of ASN.1 DER encoded data
{Number} idx
start string index of ASN.1 object
{Number} nth
for child
Since:
jsrsasign 7.2.0 asn1hex 1.1.11
Returns:
{Number} string index of nth child.

<static> {String} ASN1HEX.getOID(h, idx, errorReturn)
get object identifier string from ASN.1 V(value)
ASN1HEX.getInt("xxxx06032a0304xxxxxx", 4) &rarr "1.2.3.4"
Parameters:
{String} h
hexadecimal string
{Number} idx
string index in h to get ASN.1 DER ObjectIdentifier
{Object} errorReturn
(OPTION) error return value (DEFAULT: null)
Since:
jsrsasign 10.1.0 asn1hex 1.2.7
Returns:
{String} object identifier string (ex. "1.2.3.4")

<static> {String} ASN1HEX.getOIDName(h, idx, errorReturn)
get object identifier name from ASN.1 V(value)
This static method returns object identifier name such as "sha256" if registered. If not registered, it returns OID string. (ex. "1.2.3.4")
ASN1HEX.getOIDName("xxxx0609608648016503040201xxxxxx", 4) &rarr "sha256"
ASN1HEX.getOIDName("xxxx06032a0304xxxxxx", 4) &rarr "1.2.3.4"
Parameters:
{String} h
hexadecimal string
{Number} idx
string index in h to get ASN.1 DER ObjectIdentifier
{Object} errorReturn
(OPTION) error return value (DEFAULT: null)
Since:
jsrsasign 10.1.0 asn1hex 1.2.7
Returns:
{String} object identifier name (ex. "sha256") oir OID string

<static> {String} ASN1HEX.getString(h, idx, errorReturn)
get raw string from ASN.1 V(value)
This static method returns a raw string from any ASN.1 DER primitives.
ASN1HEX.getString("xxxx1303616161xxxxxx", 4) &rarr "aaa"
ASN1HEX.getString("xxxx0c03616161xxxxxx", 4) &rarr "aaa"
Parameters:
{String} h
hexadecimal string
{Number} idx
string index in h to get any ASN.1 DER String
{Object} errorReturn
(OPTION) error return value (DEFAULT: null)
Since:
jsrsasign 10.1.3 asn1hex 1.2.8
Returns:
{String} raw string

<static> {String} ASN1HEX.getTLV(s, idx)
get hexadecimal string of ASN.1 TLV at
Parameters:
{String} s
hexadecimal string of ASN.1 DER encoded data
{Number} idx
string index
Since:
jsrsasign 7.2.0 asn1hex 1.1.11
Returns:
{String} hexadecimal string of ASN.1 TLV.

<static> {Number} ASN1HEX.getTLVblen(h, idx)
get byte length of ASN.1 TLV at specified string index
This method returns a byte length of ASN.1 TLV at specified string index.
                       v string indx=42
ASN1HEX.getTLVblen("...1303616161...", 42) → 10 (PrintableString 'aaa')
Parameters:
{String} h
hexadecimal string of ASN.1 DER encoded data
{Number} idx
string index to get ASN.1 TLV byte length
Since:
jsrsasign 9.1.5 asn1hex 1.1.11
Returns:
{Number} byte length of ASN.1 TLV

<static> {String} ASN1HEX.getTLVbyList(h, currentIndex, nthList, checkingTag)
get ASN.1 TLV by nthList
This static method is to get a ASN.1 value which specified "nthList" position with checking expected tag "checkingTag".
When referring value can't be found, this returns null.
Parameters:
{String} h
hexadecimal string of ASN.1 structure
{Integer} currentIndex
string index to start searching in hexadecimal string "h"
{Array} nthList
array of nth list index
{String} checkingTag
(OPTIONAL) string of expected ASN.1 tag for nthList
Since:
jsrsasign 7.1.4 asn1hex 1.1.10
Returns:
{String} referred hexadecimal string of ASN.1 TLV or null

<static> {String} ASN1HEX.getTLVbyListEx(h, currentIndex, nthList, checkingTag)
get ASN.1 TLV by nthList
This static method is to get a ASN.1 value which specified "nthList" position with checking expected tag "checkingTag". This method can dig into ASN.1 object encapsulated by OctetString or BitString with unused bits.
3014 seq idx=0
  0312 seq idx=4
    020101 int:1 idx=8
    020102 int:2 idx=14
    800103 [0]:3 idx=20
    810104 [1]:4 idx=26
    020105 int:5 idx=32
    020106 int:6 idx=38
h = "30140412020101020102800103810104020105020106";
ASN1HEX.getTLVbyList(h, 0, [0, "[0]"]) → 800103
ASN1HEX.getTLVbyList(h, 0, [0, 2]) → 020105
ASN1HEX.getTLVbyList(h, 0, [0, 2], "0c") → null //not UTF8String(0c)
Parameters:
{String} h
hexadecimal string of ASN.1 structure
{Integer} currentIndex
string index to start searching in hexadecimal string "h"
{Array of Object} nthList
array list of nth index value or context specific tag string (ex. "[0]")
{String} checkingTag
(OPTIONAL) string of expected ASN.1 tag for nthList
Since:
jsrsasign 8.0.21 asn1hex 1.2.2
Returns:
{String} hexadecimal ASN.1 TLV string refered by nthList. return null if not found
See:
ASN1HEX.getIdxbyListEx tutorial wiki page

<static> {String} ASN1HEX.getV(s, idx)
get hexadecimal string of ASN.1 V(value)
Parameters:
{String} s
hexadecimal string of ASN.1 DER encoded data
{Number} idx
string index
Since:
jsrsasign 7.2.0 asn1hex 1.1.11
Returns:
{String} hexadecimal string of ASN.1 value.

<static> {Number} ASN1HEX.getVblen(s, idx)
get integer value of ASN.1 length for ASN.1 data
Parameters:
{String} s
hexadecimal string of ASN.1 DER encoded data
{Number} idx
string index
Since:
jsrsasign 7.2.0 asn1hex 1.1.11
Returns:
{Number} ASN.1 L(length) integer value

<static> {String} ASN1HEX.getVbyList(h, currentIndex, nthList, checkingTag, removeUnusedbits)
get ASN.1 value by nthList
This static method is to get a ASN.1 value which specified "nthList" position with checking expected tag "checkingTag".
When referring value can't be found, this returns null.
NOTE: 'removeUnusedbits' flag has been supported since jsrsasign 7.1.14 asn1hex 1.1.10.
Parameters:
{String} h
hexadecimal string of ASN.1 structure
{Integer} currentIndex
string index to start searching in hexadecimal string "h"
{Array} nthList
array of nth list index
{String} checkingTag
(OPTIONAL) string of expected ASN.1 tag for nthList
{Boolean} removeUnusedbits
(OPTIONAL) flag for remove first byte for value (DEFAULT false)
Since:
asn1hex 1.1.4
Returns:
{String} referred hexadecimal string of ASN.1 value(V) or null
See:
ASN1HEX.getIdxbyList
ASN1HEX.getVbyListEx

<static> {String} ASN1HEX.getVbyListEx(h, currentIndex, nthList, checkingTag, removeUnusedbits)
get ASN.1 V by nthList
This static method is to get a ASN.1 value which specified "nthList" position with checking expected tag "checkingTag". This method can dig into ASN.1 object encapsulated by OctetString or BitString with unused bits.
3014 seq idx=0
  3012 seq idx=4
    020101 int:1 idx=8
    020102 int:2 idx=14
    800103 [0]:3 idx=20
    810104 [1]:4 idx=26
    020105 int:5 idx=32
    020106 int:6 idx=38
h = "30140412020101020102800103810104020105020106";
ASN1HEX.getTLVbyList(h, 0, [0, "[0]"]) → 03
ASN1HEX.getTLVbyList(h, 0, [0, 2]) → 05
ASN1HEX.getTLVbyList(h, 0, [0, 2], "0c") → null //not UTF8String(0c)
Parameters:
{String} h
hexadecimal string of ASN.1 structure
{Integer} currentIndex
string index to start searching in hexadecimal string "h"
{Array of Object} nthList
array list of nth index value or context specific tag string (ex. "[0]")
{String} checkingTag
(OPTIONAL) string of expected ASN.1 tag for nthList (default is undefined)
{Boolean} removeUnusedbits
(OPTIONAL) flag for trim unused bit from result value (default is undefined)
Since:
jsrsasign 8.0.21 asn1hex 1.2.2
Returns:
{String} hexadecimal ASN.1 V string refered by nthList. return null if not found
See:
ASN1HEX.getIdxbyListEx tutorial wiki page

<static> ASN1HEX.getVidx(s, idx)
get ASN.1 value starting string position for ASN.1 object refered by index 'idx'.
Parameters:
{String} s
hexadecimal string of ASN.1 DER encoded data
{Number} idx
string index
Since:
jsrsasign 7.2.0 asn1hex 1.1.11

<static> {String} ASN1HEX.hextooidstr(hex)
get OID string from hexadecimal encoded value
This static method converts from ASN.1 DER encoded hexadecimal object identifier value to dot concatinated OID value. KJUR.asn1.ASN1Util.oidIntToHex is a reverse function of this.
ASN1HEX.hextooidstr("550406") → "2.5.4.6"
Parameters:
{String} hex
hexadecmal string of ASN.1 DER encoded OID value
Since:
asn1hex 1.1.5
Returns:
{String} OID string (ex. '1.2.3.4.567')
See:

<static> {Boolean} ASN1HEX.isASN1HEX(hex)
simple ASN.1 DER hexadecimal string checker
This method checks wheather the argument 'hex' is a hexadecimal string of ASN.1 data or not.
ASN1HEX.isASN1HEX('0203012345') → true // PROPER ASN.1 INTEGER
ASN1HEX.isASN1HEX('0203012345ff') → false // TOO LONG VALUE
ASN1HEX.isASN1HEX('02030123') → false // TOO SHORT VALUE
ASN1HEX.isASN1HEX('fa3bcd') → false // WRONG FOR ASN.1
Parameters:
{String} hex
string to check whether it is hexadecmal string for ASN.1 DER or not
Since:
jsrsasign 4.8.3 asn1hex 1.1.6
Returns:
{Boolean} true if it is hexadecimal string of ASN.1 data otherwise false

<static> {Boolean} ASN1HEX.isContextTag(hex, context)
check if a hexadecimal tag is a specified ASN.1 context specific tag This method checks if a hexadecimal tag is a specified ASN.1 context specific tag. Structured and non-structured type of tag have the same string representation of context specific tag. For example tag "a0" and "80" have the same string representation "[0]". The sTag has a range from from "[0]" to "[31]".
ASN1HEX.isContextTag('a0', '[0]') → true // structured
ASN1HEX.isContextTag('a1', '[1]') → true // structured
ASN1HEX.isContextTag('a2', '[2]') → true // structured
ASN1HEX.isContextTag('80', '[0]') → true // non structured
ASN1HEX.isContextTag('81', '[1]') → true // non structured
ASN1HEX.isContextTag('82', '[2]') → true // non structured
ASN1HEX.isContextTag('a0', '[3]') → false
ASN1HEX.isContextTag('80', '[15]') → false

ASN.1 tag bits
12345679
++        tag class(universal:00, context specific:10)
  +       structured:1, primitive:0
   +++++  tag number (0 - 31)
Parameters:
{hTag} hex
string of a hexadecimal ASN.1 tag consists by two characters (e.x. "a0")
{sTag} context
specific tag in string represention (OPTION) (e.x. "[0]")
Since:
jsrsasign 8.0.21 asn1hex 1.2.2
Returns:
{Boolean} true if hTag is a ASN.1 context specific tag specified by sTag value.

<static> {String} ASN1HEX.oidname(oidDotOrHex)
get hexacedimal string from PEM format data
This static method gets a OID name for a specified string of number dot notation (i.e. 1.2.3) or hexadecimal string.
ASN1HEX.oidname("2.5.29.37") → extKeyUsage
ASN1HEX.oidname("551d25") → extKeyUsage
ASN1HEX.oidname("0.1.2.3") → 0.1.2.3 // unknown
Parameters:
{String} oidDotOrHex
number dot notation(i.e. 1.2.3) or hexadecimal string for OID
Since:
jsrsasign 7.2.0 asn1hex 1.1.11
Returns:
{String} name for OID

<static> {Object} ASN1HEX.parse(h)
parse ASN.1 DER hexadecimal string
This method parses ASN.1 DER hexadecimal string. Its result can be applied to KJUR.asn1.ASN1Util.newOjbect.
ASN1HEX.parse("31193017...") → // RDN
{set: [{seq: [{oid: "localityName"}, {utf8str: {str: "Test"}}] }]}
Parameters:
{String} h
hexadecimal string of ASN1. DER
Since:
jsrsasign 10.5.3 asn1hex 1.1.x
Returns:
{Object} associative array of ASN.1 parsed result
See:
KJUR.asn1.ASN1Util.newOjbect

© 2012-2023 Kenji Urushima, All rights reserved
Documentation generated by JsDoc Toolkit 2.4.0