Dsa Node.js Reference Documentation
Dsa
Current Version: 11.5.0
Chilkat.Dsa
Create DSA key pairs and parameters for workflows that still require
DSA-based signing or verification.
Load and save private or public DSA keys in DER, PEM, encrypted PEM,
XML, component-based, and OpenSSL-compatible formats.
Create DSA signatures over message digests using a loaded private key
and the appropriate encoded hash input.
Verify DSA signatures using a public key, encoded hash, and signature
data.
Access DSA parameters and key components as hex-encoded SSH1-format
bignums for low-level interoperability scenarios.
Work with encoded hashes and signatures when applications need hex,
Base64, or other textual representations of binary values.
For an extended overview, see
Dsa Class Overview.
Generate, import, export, sign, and verify DSA keys and signatures.
Chilkat.Dsa is the Chilkat class for DSA key generation,
DSA key import/export, DSA hash signing, and DSA signature verification.
It supports private and public keys in DER, PEM, encrypted PEM, XML,
explicit component, and OpenSSL parameter workflows. It also exposes DSA key
components as hex-encoded SSH1-format bignums and provides helpers for
working with encoded hashes and signatures.
Generate DSA keys
Import and export keys
Sign hashes
Verify signatures
Key components
Encoded data helpers
Dsa to sign the hash with the private key or
verify the signature with the public key. For new protocol designs, consider
whether a more modern signature algorithm is preferred; use this class when
DSA is required for compatibility.
Object Creation
var obj = new chilkat.Dsa();
Properties
DebugLogFilePath
· string
If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. This logging helps identify the context and history of Chilkat calls leading up to any crash or hang, aiding in debugging.
Enabling the VerboseLogging property provides more detailed information. This property is mainly used for debugging rare instances where a Chilkat method call causes a hang or crash, which should generally not happen.
Possible causes of hangs include:
- A timeout property set to 0, indicating an infinite timeout.
- A hang occurring within an event callback in the application code.
- An internal bug in the Chilkat code causing the hang.
GroupSize
· integer
Specifies the size, in bits, of the DSA subgroup parameter Q used by the legacy GenKey method. The default is 160. This also determines the natural size of the DSA signature components r and s.
Applications should normally leave this property at its default. When an explicit standards-era (L, N) parameter pair is required, use GenKey2, where L is the bit length of P and N is the bit length of Q.
Hash
· Buffer
Contains the message digest to be signed by SignHash or checked by Verify. Set this property before calling either method. The same value can also be supplied in encoded form with SetEncodedHash.
The Dsa class does not hash the original message. The application must compute the exact digest required by the protocol or file format and provide the resulting bytes here.
HexG
· string, read-only
Returns the DSA domain parameter G, the generator of the subgroup of order Q modulo P.
The returned text is a hexadecimal encoding of Chilkat's SSH1-format bignum representation, which includes a two-byte bit-length prefix followed by the unsigned integer bytes.
topHexP
· string, read-only
Returns the DSA domain parameter P, the large prime modulus.
The returned text is a hexadecimal encoding of Chilkat's SSH1-format bignum representation, which includes a two-byte bit-length prefix followed by the unsigned integer bytes.
topHexQ
· string, read-only
Returns the DSA domain parameter Q, a prime divisor of P - 1. The bit length of Q is commonly written as N and determines the range of the private value X and signature components r and s.
The returned text is a hexadecimal encoding of Chilkat's SSH1-format bignum representation, which includes a two-byte bit-length prefix followed by the unsigned integer bytes.
topHexX
· string, read-only
Returns the DSA private value X. It is present only when the object contains a private key and satisfies 0 < X < Q.
The returned text is a hexadecimal encoding of Chilkat's SSH1-format bignum representation, which includes a two-byte bit-length prefix followed by the unsigned integer bytes.
X can create signatures as the key owner. Do not log, transmit, or persist this value unless it is protected as private-key material.HexY
· string, read-only
Returns the DSA public value Y, where Y = GX mod P. It is available when either a public or private DSA key is loaded.
The returned text is a hexadecimal encoding of Chilkat's SSH1-format bignum representation, which includes a two-byte bit-length prefix followed by the unsigned integer bytes.
topLastErrorHtml
· string, read-only
Provides HTML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.
topLastErrorText
· string, read-only
Provides plain text information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.
LastErrorXml
· string, read-only
Provides XML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.
topLastMethodSuccess
· boolean
Indicates the success or failure of the most recent method call: true means success, false means failure. This property remains unchanged by property setters or getters. This method is present to address challenges in checking for null or Nothing returns in certain programming languages. Note: This property does not apply to methods that return integer values or to boolean-returning methods where the boolean does not indicate success or failure.
Signature
· Buffer
Contains the DSA signature produced by SignHash. Before calling Verify, set this property to the signature being checked, or use SetEncodedSignature or SetEncodedSignatureRS.
Chilkat represents the signature as an ASN.1 DER SEQUENCE containing the two DSA integers r and s. Use GetEncodedSignature to obtain a hexadecimal or Base64 representation.
UncommonOptions
· string
Reserved for uncommon or compatibility-specific options. The default is the empty string, and applications should normally leave this property unchanged unless Chilkat documentation or support identifies a specific keyword required for the target system.
topVerboseLogging
· boolean
If set to true, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. The default value is false. Verbose logging should only be used for debugging. The potentially large quantity of logged information may adversely affect peformance.
Version
· string, read-only
Methods
FromDer
· Returns Boolean (true for success, false for failure).
· derData Buffer
Loads a DSA private key from the DER-encoded bytes in . On success, the object contains both the private and public key components and can sign or verify digests.derData
Returns true for success, false for failure.
topFromDerBd
· Returns Boolean (true for success, false for failure).
· bd BinData
Loads a DSA private key from the DER bytes contained in the BinData object passed in . Returns bdtrue on successful decoding.
BinData content contains secret key material and should be cleared or released when no longer needed.Returns true for success, false for failure.
topFromDerFile
· Returns Boolean (true for success, false for failure).
· path String
Loads a DSA private key from the DER-encoded file specified by . Returns pathtrue when the file is read and decoded successfully; otherwise returns false.
LastErrorText when loading fails.Returns true for success, false for failure.
FromEncryptedPem
· Returns Boolean (true for success, false for failure).
· password String
· pemData String
Loads a DSA private key from the PEM text in . pemData supplies the password when the PEM is encrypted. If the PEM is unencrypted, the password is ignored and the key is loaded normally.password
Returns true on success and false if the PEM cannot be decoded, the password is incorrect, or the contained key is not a supported DSA private key.
Returns true for success, false for failure.
topFromPem
· Returns Boolean (true for success, false for failure).
· pemData String
Loads an unencrypted DSA private key from the PEM text in . On success, the object contains the private key and its corresponding public components.pemData
FromEncryptedPem when password-protected PEM is available.Returns true for success, false for failure.
FromPublicDer
· Returns Boolean (true for success, false for failure).
· derData Buffer
Loads a DSA public key from the DER-encoded bytes in . A public key can be used with derDataVerify and can be exported, but it cannot be used by SignHash.
Returns true for success, false for failure.
topFromPublicDerBd
· Returns Boolean (true for success, false for failure).
· bd BinData
Loads a DSA public key from the DER bytes contained in the BinData object passed in . The resulting key can verify signatures but cannot sign.bd
Returns true for success, false for failure.
topFromPublicDerFile
· Returns Boolean (true for success, false for failure).
· path String
Loads a DSA public key from the DER-encoded file specified by . Returns pathtrue when the file is read and decoded successfully; otherwise returns false.
Returns true for success, false for failure.
topFromPublicPem
· Returns Boolean (true for success, false for failure).
· pemData String
Loads a DSA public key from the PEM text in . Returns pemDatatrue when the PEM contains a supported DSA public key and is decoded successfully.
Returns true for success, false for failure.
topFromXml
· Returns Boolean (true for success, false for failure).
· xmlKey String
Loads a DSA public or private key from the XML text in . The XML content determines whether the resulting object contains public components only or also includes the private value xmlKeyX.
X, it contains the complete private key and must be protected accordingly.Returns true for success, false for failure.
topGenKey
· Returns Boolean (true for success, false for failure).
· numBits Number
Generates a new DSA key pair with a P size of bits. numBits must be at least 1024 and a multiple of 64. This legacy method uses the subgroup size selected by numBitsGroupSize, whose default is 160 bits.
For explicit standard parameter pairs such as (2048, 224) or (3072, 256), use GenKey2.
Returns true for success, false for failure.
GenKey2
· Returns Boolean (true for success, false for failure).
· keyLenBits Number
· modLenBits Number
Generates a new DSA key pair using an explicit (L, N) parameter-size combination. is keyLenBitsL, the bit length of the prime modulus P. is modLenBitsN, the bit length of the subgroup prime Q.
| L | N | Historical FIPS 186-4 combination |
|---|---|---|
1024 | 160 | Legacy |
2048 | 224 or 256 | Supported parameter pairs |
3072 | 256 | Largest listed pair |
Returns true for success, false for failure.
topGenKeyFromParamsDer
· Returns Boolean (true for success, false for failure).
· derBytes Buffer
Generates a new DSA key pair from OpenSSL-style DSA parameters supplied as DER-encoded bytes in .derBytes
The supplied data contains DSA domain parameters P, Q, and G, not an existing private key. Chilkat validates or imports those parameters and generates a fresh private value X and corresponding public value Y.
Returns true for success, false for failure.
topGenKeyFromParamsDerBd
· Returns Boolean (true for success, false for failure).
· bd BinData
Generates a new DSA key pair from OpenSSL-style DSA parameters stored as DER bytes in the BinData object passed in .bd
The supplied data contains DSA domain parameters P, Q, and G, not an existing private key. Chilkat validates or imports those parameters and generates a fresh private value X and corresponding public value Y.
Returns true for success, false for failure.
topGenKeyFromParamsDerFile
· Returns Boolean (true for success, false for failure).
· path String
Generates a new DSA key pair from the OpenSSL-style DER DSA-parameters file specified by .path
The supplied data contains DSA domain parameters P, Q, and G, not an existing private key. Chilkat validates or imports those parameters and generates a fresh private value X and corresponding public value Y.
Returns true when the parameters are loaded and a key pair is generated successfully.
Returns true for success, false for failure.
GenKeyFromParamsPem
· Returns Boolean (true for success, false for failure).
· pem String
Generates a new DSA key pair from OpenSSL-style DSA parameters supplied as PEM text in .pem
The supplied data contains DSA domain parameters P, Q, and G, not an existing private key. Chilkat validates or imports those parameters and generates a fresh private value X and corresponding public value Y.
Returns true for success, false for failure.
topGenKeyFromParamsPemFile
· Returns Boolean (true for success, false for failure).
· path String
Generates a new DSA key pair from the OpenSSL-style PEM DSA-parameters file specified by .path
The supplied data contains DSA domain parameters P, Q, and G, not an existing private key. Chilkat validates or imports those parameters and generates a fresh private value X and corresponding public value Y.
A typical parameter file is PEM-armored with a BEGIN DSA PARAMETERS header. The newly generated private key can be exported with the applicable To* methods.
Returns true for success, false for failure.
topGenKeyFromPQG
· Returns Boolean (true for success, false for failure).
· pHex String
· qHex String
· gHex String
Generates a new DSA private/public key pair using the preselected domain parameters P, Q, and G supplied in , pHex, and qHex.gHex
Each argument is hexadecimal text in Chilkat's SSH1-format bignum representation. Chilkat generates a fresh private value X and derives Y; the supplied values are domain parameters, not an existing key pair.
Returns true for success, false for failure.
topGetEncodedHash
· Returns a String.
· encoding String
Returns the current Hash bytes encoded according to . Use encodinghex or base64.
This method does not compute a hash; it only converts the bytes already stored in the Hash property to text.
Returns null on failure
GetEncodedSignature
· Returns a String.
· encoding String
Returns the current Signature bytes encoded according to . Use encodinghex or base64.
After a successful SignHash call, the returned bytes are the ASN.1 DER-encoded DSA signature containing the integers r and s.
Returns null on failure
LoadText
· Returns a String.
· path String
Loads the entire file specified by and returns its contents as text using the legacy ANSI character encoding.path
Returns null on failure
SaveText
· Returns Boolean (true for success, false for failure).
· strToSave String
· path String
Writes to the file specified by strToSave using the legacy ANSI character encoding. Returns pathtrue on success.
Returns true for success, false for failure.
topSetEncodedHash
· Returns Boolean (true for success, false for failure).
· encoding String
· encodedHash String
Decodes using the encoding named by encodedHash and stores the resulting bytes in the encodingHash property. Use hex or base64.
The decoded value must be the already-computed message digest that will be signed by SignHash or checked by Verify.
Returns true for success, false for failure.
topSetEncodedSignature
· Returns Boolean (true for success, false for failure).
· encoding String
· encodedSig String
Decodes the signature text in using the encoding named by encodedSig and stores the resulting bytes in the encodingSignature property. Use hex or base64.
The decoded bytes are expected to contain the ASN.1 DER-encoded DSA signature. Set the corresponding Hash and public key before calling Verify.
Returns true for success, false for failure.
topSetEncodedSignatureRS
· Returns Boolean (true for success, false for failure).
· encoding String
· encodedR String
· encodedS String
Builds the DSA signature from separately encoded r and s integer values. identifies the encoding used by both encoding and encodedR; use encodedShex or base64.
On success, Signature contains the ASN.1 DER SEQUENCE of the two integers and is ready for use with Verify.
Returns true for success, false for failure.
topSetKeyExplicit
· Returns Boolean (true for success, false for failure).
· groupSizeInBytes Number
· pHex String
· qHex String
· gHex String
· xHex String
Loads a DSA private key from explicitly supplied components. is the size of groupSizeInBytesQ in bytes. , pHex, qHex, and gHex provide xHexP, Q, G, and the private value X, respectively.
The corresponding public value Y = GX mod P is derived from the private key.
xHex contains the private key. Do not expose it in logs or transmit it over an unprotected channel.Returns true for success, false for failure.
topSetPubKeyExplicit
· Returns Boolean (true for success, false for failure).
· groupSizeInBytes Number
· pHex String
· qHex String
· gHex String
· yHex String
Loads a DSA public key from explicitly supplied components. is the size of groupSizeInBytesQ in bytes. , pHex, qHex, and gHex provide yHexP, Q, G, and the public value Y, respectively.
The resulting object can verify DSA signatures but cannot create them.
Returns true for success, false for failure.
topSignHash
· Returns Boolean (true for success, false for failure).
Creates a DSA signature over the digest currently stored in Hash. A DSA private key must be loaded, and the digest must be set directly or with SetEncodedHash before this method is called.
On success, Signature contains an ASN.1 DER-encoded sequence of the DSA values r and s. Retrieve it with GetEncodedSignature or read the Signature property.
Returns true for success, false for failure.
ToDer
· Returns a Buffer.
Returns the loaded DSA private key as DER-encoded bytes. A private key must be present; a public-only key cannot be exported by this method.
Returns null on failure
ToDerBd
· Returns Boolean (true for success, false for failure).
· bd BinData
Writes the DER-encoded DSA private key to the BinData object passed in . Returns bdtrue on success.
Returns true for success, false for failure.
topToDerFile
· Returns Boolean (true for success, false for failure).
· path String
Writes the loaded DSA private key to the DER file specified by . Returns pathtrue on success.
Returns true for success, false for failure.
ToEncryptedPem
· Returns a String.
· password String
Returns the loaded DSA private key as password-encrypted PEM text using as the password.password
Returns null on failure
ToPem
· Returns a String.
Returns the loaded DSA private key as unencrypted PEM text.
ToEncryptedPem when password protection is required.Returns null on failure
ToPublicDer
· Returns a Buffer.
Returns the public portion of the loaded DSA key as DER-encoded bytes. This works whether the object contains a public key or a private key with a corresponding public value.
Returns null on failure
ToPublicDerBd
· Returns Boolean (true for success, false for failure).
· bd BinData
Writes the DER-encoded public portion of the loaded DSA key to the BinData object passed in . Returns bdtrue on success.
Returns true for success, false for failure.
topToPublicDerFile
· Returns Boolean (true for success, false for failure).
· path String
Writes the public portion of the loaded DSA key to the DER file specified by . Returns pathtrue on success.
Returns true for success, false for failure.
ToPublicPem
· Returns a String.
Returns the public portion of the loaded DSA key as PEM text. Public-key PEM may be distributed to parties that need to verify signatures; it does not contain the private value X.
Returns null on failure
ToXml
· Returns a String.
· bPublicOnly Boolean
Returns the loaded DSA key as XML. Set to bPublicOnlytrue to export public components only. Set it to false to include the private component when a private key is loaded.
bPublicOnly is false, the XML can contain the private value X. Protect it as private-key material.Returns null on failure
Verify
· Returns Boolean (true for success, false for failure).
Verifies the DSA signature currently stored in Signature against the digest stored in Hash, using the loaded public key. Both values must be set before calling this method.
Returns true only when the signature is valid. A false result can indicate an invalid signature, malformed input, an incompatible key, or another operational error; inspect LastErrorText when the reason matters.
Returns true for success, false for failure.
VerifyKey
· Returns a Boolean.
Checks the mathematical validity and internal consistency of the DSA public or private key currently loaded in the object. Returns true when the key parameters and available key components pass validation.
This does not establish who owns the key, whether the key came from a trusted source, or whether it is suitable for a particular protocol.