new DerNode(nodeType)
DerNode implements the DER node types used in encoding/decoding DER-formatted
data.
Create a generic DER node with the given nodeType. This is a private
constructor used by one of the public DerNode subclasses defined below.
Parameters:
Name | Type | Description |
---|---|---|
nodeType |
number | One of the defined DER DerNodeType constants. |
- Source:
Methods
(static) DerBitString(inputBuf, paddingLen)
A DerBitString extends DerNode to handle a bit string.
Create a DerBitString with the given padding and inputBuf.
Parameters:
Name | Type | Description |
---|---|---|
inputBuf |
Buffer | An input buffer containing the bit octets to encode. |
paddingLen |
number | The number of bits of padding at the end of the bit string. Should be less than 8. |
- Source:
(static) DerBoolean(value)
DerBoolean extends DerNode to encode a boolean value.
Create a new DerBoolean for the value.
Parameters:
Name | Type | Description |
---|---|---|
value |
boolean | The value to encode. |
- Source:
(static) DerByteString(inputData, nodeType)
A DerByteString extends DerNode to handle byte strings.
Create a DerByteString with the given inputData and nodeType. This is a
private constructor used by one of the public subclasses such as
DerOctetString or DerPrintableString.
Parameters:
Name | Type | Description |
---|---|---|
inputData |
Buffer | An input buffer containing the string to encode. |
nodeType |
number | One of the defined DER DerNodeType constants. |
- Source:
(static) DerGeneralizedTime(msSince1970)
A DerGeneralizedTime extends DerNode to represent a date and time, with
millisecond accuracy.
Create a DerGeneralizedTime with the given milliseconds since 1970.
Parameters:
Name | Type | Description |
---|---|---|
msSince1970 |
number | The timestamp as milliseconds since Jan 1, 1970. |
- Source:
(static) DerInteger(integer)
DerInteger extends DerNode to encode an integer value.
Create a new DerInteger for the value.
Parameters:
Name | Type | Description |
---|---|---|
integer |
number | Buffer | The value to encode. If integer is a Buffer byte array of a positive integer, you must ensure that the first byte is less than 0x80. |
- Source:
(static) DerNull()
A DerNull extends DerNode to encode a null value.
Create a DerNull.
- Source:
(static) DerOctetString(inputData)
DerOctetString extends DerByteString to encode a string of bytes.
Create a new DerOctetString for the inputData.
Parameters:
Name | Type | Description |
---|---|---|
inputData |
Buffer | An input buffer containing the string to encode. |
- Source:
(static) DerOid(oid)
A DerOid extends DerNode to represent an object identifier.
Create a DerOid with the given object identifier. The object identifier
string must begin with 0,1, or 2 and must contain at least 2 digits.
Parameters:
Name | Type | Description |
---|---|---|
oid |
string | OID | The OID string or OID object to encode. |
- Source:
(static) DerPrintableString(inputData)
A DerPrintableString extends DerByteString to handle a a printable string. No
escaping or other modification is done to the string.
Create a DerPrintableString with the given inputData.
Parameters:
Name | Type | Description |
---|---|---|
inputData |
Buffer | An input buffer containing the string to encode. |
- Source:
(static) DerSequence()
A DerSequence extends DerStructure to contains an ordered sequence of other
nodes.
Create a DerSequence.
- Source:
(static) DerStructure(nodeType)
A DerStructure extends DerNode to hold other DerNodes.
Create a DerStructure with the given nodeType. This is a private
constructor. To create an object, use DerSequence.
Parameters:
Name | Type | Description |
---|---|---|
nodeType |
number | One of the defined DER DerNodeType constants. |
- Source:
(static) getSequence(children, index) → {DerNode.DerSequence}
Check that index is in bounds for the children list, return children[index].
Parameters:
Name | Type | Description |
---|---|---|
children |
Array.<DerNode> | The list of DerNode, usually returned by another call to getChildren. |
index |
number | The index of the children. |
- Source:
Throws:
DerDecodingException if index is out of bounds or if children[index]
is not a DerSequence.
Returns:
children[index].
- Type
- DerNode.DerSequence
(static) parse(inputBuf, startIdx) → {DerNode}
Parse the data from the input buffer recursively and return the root as an
object of a subclass of DerNode.
Parameters:
Name | Type | Description |
---|---|---|
inputBuf |
Buffer | The input buffer to read from. |
startIdx |
number | (optional) The offset into the buffer. If omitted, use 0. |
- Source:
Returns:
An object of a subclass of DerNode.
- Type
- DerNode
decode(inputBuf, startIdx)
Decode and store the data from an input buffer.
Parameters:
Name | Type | Description |
---|---|---|
inputBuf |
Buffer | The input buffer to read from. This reads from startIdx (regardless of the buffer's position) and does not change the position. |
startIdx |
number | The offset into the buffer. |
- Source:
decodeHeader(inputBuf, startIdx) → {number}
Extract the header from an input buffer and return the size.
Parameters:
Name | Type | Description |
---|---|---|
inputBuf |
Buffer | The input buffer to read from. |
startIdx |
number | The offset into the buffer. |
- Source:
Returns:
The parsed size in the header.
- Type
- number
encode() → {Blob}
Get the raw data encoding for this node.
- Source:
Returns:
The raw data encoding.
- Type
- Blob
encodeHeader(size)
Encode the given size and update the header.
Parameters:
Name | Type | Description |
---|---|---|
size |
number |
- Source:
getChildren() → {Array.<DerNode>}
If this object is a DerNode.DerSequence, get the children of this node.
Otherwise, throw an exception. (DerSequence overrides to implement this
method.)
- Source:
Throws:
DerDecodingException if this object is not a DerSequence.
Returns:
The children as an array of DerNode.
- Type
- Array.<DerNode>
getPayload() → {Blob}
Get a copy of the payload bytes.
- Source:
Returns:
A copy of the payload.
- Type
- Blob
getSize() → {number}
Return the number of bytes in DER
- Source:
Returns:
- Type
- number
payloadAppend(buffer)
Copy buffer to this.payload_ at this.payloadPosition_ and update
this.payloadPosition_.
Parameters:
Name | Type | Description |
---|---|---|
buffer |
Buffer | The buffer to copy. |
- Source:
toVal() → {Blob}
Convert the encoded data to a standard representation. Overridden by some
subclasses (e.g. DerBoolean).
- Source:
Returns:
The encoded data as a Blob.
- Type
- Blob