---
product: Chilkat
product_version: 11.7.0
language: c
language_label: C
class: Dsa
license: bundle
deprecated: false
reference_html: https://www.chilkatsoft.com/refdoc/c_CkDsaRef.html
---
# Chilkat Dsa — C — v11.7.0

> Chilkat 11.7.0 · language=c · class=Dsa
> Other versions: replace `11.7.0` in this URL. Other languages: `https://www.chilkatsoft.com/ai-docs/v/11.7.0/<lang>/classes/Dsa.md`.
> Language-wide rules (install, unlock, error model, strings/bytes): `https://www.chilkatsoft.com/ai-docs/v/11.7.0/c/guide.md`.

## Purpose

**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**

Create DSA key pairs and parameters for workflows that still require DSA-based signing or verification.

**Import and export keys**

Load and save private or public DSA keys in DER, PEM, encrypted PEM, XML, component-based, and OpenSSL-compatible formats.

**Sign hashes**

Create DSA signatures over message digests using a loaded private key and the appropriate encoded hash input.

**Verify signatures**

Verify DSA signatures using a public key, encoded hash, and signature data.

**Key components**

Access DSA parameters and key components as hex-encoded SSH1-format bignums for low-level interoperability scenarios.

**Encoded data helpers**

Work with encoded hashes and signatures when applications need hex, Base64, or other textual representations of binary values.

**Common pattern:** Load or generate a DSA key, compute the message hash with the desired hash algorithm, then use `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.

For an extended overview, see [Dsa Class Overview](https://www.chilkatsoft.com/dsa_class_overview.asp).

## Object creation, unlocking and error handling

**Create/Dispose**

```c
HCkDsa instance = CkDsa_Create();
// ...
CkDsa_Dispose(instance);
```

`HCkDsa CkDsa_Create(void);`

Creates an instance of the HCkDsa object and returns a handle ("void \*" pointer). The handle is passed in the 1st argument for the functions listed on this page.

`void CkDsa_Dispose(HCkDsa handle);`

Objects created by calling CkDsa_Create must be freed by calling this method. A memory leak occurs if a handle is not disposed by calling this function. Also, any handle returned by a Chilkat "C" function must also be freed by the application by calling the appropriate Dispose method, such as CkDsa_Dispose.

Call `Global.UnlockBundle` once at the start of the program, before using this or any other Chilkat class. Any string unlocks a fully functional 30-day trial; a purchased unlock code is used in production. See `guide.md` for the exact code in C.

## Members common to every Chilkat class

Documented once per language in `common-members.md`; listed here so this page is self-contained.

| Property | Signature | Access | Meaning |
|---|---|---|---|
| `DebugLogFilePath` | `void CkDsa_getDebugLogFilePath(HCkDsa cHandle, HCkString retval); void CkDsa_putDebugLogFilePath(HCkDsa cHandle, const char *newVal); const char *CkDsa_debugLogFilePath(HCkDsa cHandle);` | read/write | If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. |
| `LastErrorHtml` | `void CkDsa_getLastErrorHtml(HCkDsa cHandle, HCkString retval); const char *CkDsa_lastErrorHtml(HCkDsa cHandle);` | read-only | Provides HTML-formatted information about the last called method or property. |
| `LastErrorText` | `void CkDsa_getLastErrorText(HCkDsa cHandle, HCkString retval); const char *CkDsa_lastErrorText(HCkDsa cHandle);` | read-only | Provides plain text information about the last called method or property. |
| `LastErrorXml` | `void CkDsa_getLastErrorXml(HCkDsa cHandle, HCkString retval); const char *CkDsa_lastErrorXml(HCkDsa cHandle);` | read-only | Provides XML-formatted information about the last called method or property. |
| `LastMethodSuccess` | `BOOL CkDsa_getLastMethodSuccess(HCkDsa cHandle); void CkDsa_putLastMethodSuccess(HCkDsa cHandle, BOOL newVal);` | read/write | Indicates the success or failure of the most recent method call: `TRUE` means success, `FALSE` means failure. |
| `Utf8` | `BOOL CkDsa_getUtf8(HCkDsa cHandle); void CkDsa_putUtf8(HCkDsa cHandle, BOOL newVal);` | read/write | When set to `TRUE`, all `const char *` arguments and return values are interpreted as UTF-8 strings. |
| `VerboseLogging` | `BOOL CkDsa_getVerboseLogging(HCkDsa cHandle); void CkDsa_putVerboseLogging(HCkDsa cHandle, BOOL newVal);` | read/write | If set to `TRUE`, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. |
| `Version` | `void CkDsa_getVersion(HCkDsa cHandle, HCkString retval); const char *CkDsa_version(HCkDsa cHandle);` | read-only | Version of the component/library, such as "10.1.0" |

## Member index

| Member | Kind | Signature |
|---|---|---|
| `GroupSize` | property, read/write | `int CkDsa_getGroupSize(HCkDsa cHandle); void CkDsa_putGroupSize(HCkDsa cHandle, int newVal);` |
| `HexG` | property, read-only | `void CkDsa_getHexG(HCkDsa cHandle, HCkString retval); const char *CkDsa_hexG(HCkDsa cHandle);` |
| `HexP` | property, read-only | `void CkDsa_getHexP(HCkDsa cHandle, HCkString retval); const char *CkDsa_hexP(HCkDsa cHandle);` |
| `HexQ` | property, read-only | `void CkDsa_getHexQ(HCkDsa cHandle, HCkString retval); const char *CkDsa_hexQ(HCkDsa cHandle);` |
| `HexX` | property, read-only | `void CkDsa_getHexX(HCkDsa cHandle, HCkString retval); const char *CkDsa_hexX(HCkDsa cHandle);` |
| `HexY` | property, read-only | `void CkDsa_getHexY(HCkDsa cHandle, HCkString retval); const char *CkDsa_hexY(HCkDsa cHandle);` |
| `UncommonOptions` | property, read/write | `void CkDsa_getUncommonOptions(HCkDsa cHandle, HCkString retval); void CkDsa_putUncommonOptions(HCkDsa cHandle, const char *newVal); const char *CkDsa_uncommonOptions(HCkDsa cHandle);` |
| `FromDerBd` | method | `BOOL CkDsa_FromDerBd(HCkDsa cHandle, HCkBinData bd);` |
| `FromDerFile` | method | `BOOL CkDsa_FromDerFile(HCkDsa cHandle, const char *path);` |
| `FromEncryptedPem` | method | `BOOL CkDsa_FromEncryptedPem(HCkDsa cHandle, const char *password, const char *pemData);` |
| `FromPem` | method | `BOOL CkDsa_FromPem(HCkDsa cHandle, const char *pemData);` |
| `FromPublicDerBd` | method | `BOOL CkDsa_FromPublicDerBd(HCkDsa cHandle, HCkBinData bd);` |
| `FromPublicDerFile` | method | `BOOL CkDsa_FromPublicDerFile(HCkDsa cHandle, const char *path);` |
| `FromPublicPem` | method | `BOOL CkDsa_FromPublicPem(HCkDsa cHandle, const char *pemData);` |
| `FromXml` | method | `BOOL CkDsa_FromXml(HCkDsa cHandle, const char *xmlKey);` |
| `GenKey` | method | `BOOL CkDsa_GenKey(HCkDsa cHandle, int numBits);` |
| `GenKey2` | method | `BOOL CkDsa_GenKey2(HCkDsa cHandle, int keyLenBits, int modLenBits);` |
| `GenKeyFromParamsDerBd` | method | `BOOL CkDsa_GenKeyFromParamsDerBd(HCkDsa cHandle, HCkBinData bd);` |
| `GenKeyFromParamsDerFile` | method | `BOOL CkDsa_GenKeyFromParamsDerFile(HCkDsa cHandle, const char *path);` |
| `GenKeyFromParamsPem` | method | `BOOL CkDsa_GenKeyFromParamsPem(HCkDsa cHandle, const char *pem);` |
| `GenKeyFromParamsPemFile` | method | `BOOL CkDsa_GenKeyFromParamsPemFile(HCkDsa cHandle, const char *path);` |
| `GenKeyFromPQG` | method | `BOOL CkDsa_GenKeyFromPQG(HCkDsa cHandle, const char *pHex, const char *qHex, const char *gHex);` |
| `GetEncodedHash` | method | `BOOL CkDsa_GetEncodedHash(HCkDsa cHandle, const char *encoding, HCkString outStr); const char *CkDsa_getEncodedHash(HCkDsa cHandle, const char *encoding);` |
| `GetEncodedSignature` | method | `BOOL CkDsa_GetEncodedSignature(HCkDsa cHandle, const char *encoding, HCkString outStr); const char *CkDsa_getEncodedSignature(HCkDsa cHandle, const char *encoding);` |
| `LoadText` | method | `BOOL CkDsa_LoadText(HCkDsa cHandle, const char *path, HCkString outStr); const char *CkDsa_loadText(HCkDsa cHandle, const char *path);` |
| `SaveText` | method | `BOOL CkDsa_SaveText(HCkDsa cHandle, const char *strToSave, const char *path);` |
| `SetEncodedHash` | method | `BOOL CkDsa_SetEncodedHash(HCkDsa cHandle, const char *encoding, const char *encodedHash);` |
| `SetEncodedSignature` | method | `BOOL CkDsa_SetEncodedSignature(HCkDsa cHandle, const char *encoding, const char *encodedSig);` |
| `SetEncodedSignatureRS` | method | `BOOL CkDsa_SetEncodedSignatureRS(HCkDsa cHandle, const char *encoding, const char *encodedR, const char *encodedS);` |
| `SetKeyExplicit` | method | `BOOL CkDsa_SetKeyExplicit(HCkDsa cHandle, int groupSizeInBytes, const char *pHex, const char *qHex, const char *gHex, const char *xHex);` |
| `SetPubKeyExplicit` | method | `BOOL CkDsa_SetPubKeyExplicit(HCkDsa cHandle, int groupSizeInBytes, const char *pHex, const char *qHex, const char *gHex, const char *yHex);` |
| `SignHash` | method | `BOOL CkDsa_SignHash(HCkDsa cHandle);` |
| `ToDerBd` | method | `BOOL CkDsa_ToDerBd(HCkDsa cHandle, HCkBinData bd);` |
| `ToDerFile` | method | `BOOL CkDsa_ToDerFile(HCkDsa cHandle, const char *path);` |
| `ToEncryptedPem` | method | `BOOL CkDsa_ToEncryptedPem(HCkDsa cHandle, const char *password, HCkString outStr); const char *CkDsa_toEncryptedPem(HCkDsa cHandle, const char *password);` |
| `ToPem` | method | `BOOL CkDsa_ToPem(HCkDsa cHandle, HCkString outStr); const char *CkDsa_toPem(HCkDsa cHandle);` |
| `ToPublicDerFile` | method | `BOOL CkDsa_ToPublicDerFile(HCkDsa cHandle, const char *path);` |
| `ToPublicPem` | method | `BOOL CkDsa_ToPublicPem(HCkDsa cHandle, HCkString outStr); const char *CkDsa_toPublicPem(HCkDsa cHandle);` |
| `ToXml` | method | `BOOL CkDsa_ToXml(HCkDsa cHandle, BOOL bPublicOnly, HCkString outStr); const char *CkDsa_toXml(HCkDsa cHandle, BOOL bPublicOnly);` |
| `Verify` | method | `BOOL CkDsa_Verify(HCkDsa cHandle);` |
| `VerifyKey` | method | `BOOL CkDsa_VerifyKey(HCkDsa cHandle);` |

Deprecated members are listed at the end of this file with their replacements; do not use them in new code.

## Properties

### Dsa.GroupSize

`Chilkat 11.7.0 · c · Dsa · GroupSize · property · read/write`

```c
int CkDsa_getGroupSize(HCkDsa cHandle);
void CkDsa_putGroupSize(HCkDsa cHandle, int newVal);
```

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`.

**Legacy algorithm:** NIST FIPS 186-5 no longer approves DSA for generating new digital signatures. Retain DSA generation and signing only for interoperability with systems or data formats that specifically require it; DSA verification remains useful for legacy signatures.

### Dsa.HexG

`Chilkat 11.7.0 · c · Dsa · HexG · property · read-only`

```c
void CkDsa_getHexG(HCkDsa cHandle, HCkString retval);
const char *CkDsa_hexG(HCkDsa cHandle);
```

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.

### Dsa.HexP

`Chilkat 11.7.0 · c · Dsa · HexP · property · read-only`

```c
void CkDsa_getHexP(HCkDsa cHandle, HCkString retval);
const char *CkDsa_hexP(HCkDsa cHandle);
```

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.

### Dsa.HexQ

`Chilkat 11.7.0 · c · Dsa · HexQ · property · read-only`

```c
void CkDsa_getHexQ(HCkDsa cHandle, HCkString retval);
const char *CkDsa_hexQ(HCkDsa cHandle);
```

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.

### Dsa.HexX

`Chilkat 11.7.0 · c · Dsa · HexX · property · read-only`

```c
void CkDsa_getHexX(HCkDsa cHandle, HCkString retval);
const char *CkDsa_hexX(HCkDsa cHandle);
```

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.

**Sensitive value:** Anyone who obtains `X` can create signatures as the key owner. Do not log, transmit, or persist this value unless it is protected as private-key material.

### Dsa.HexY

`Chilkat 11.7.0 · c · Dsa · HexY · property · read-only`

```c
void CkDsa_getHexY(HCkDsa cHandle, HCkString retval);
const char *CkDsa_hexY(HCkDsa cHandle);
```

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.

### Dsa.UncommonOptions

`Chilkat 11.7.0 · c · Dsa · UncommonOptions · property · read/write · since 9.5.0.90`

```c
void CkDsa_getUncommonOptions(HCkDsa cHandle, HCkString retval);
void CkDsa_putUncommonOptions(HCkDsa cHandle, const char *newVal);
const char *CkDsa_uncommonOptions(HCkDsa cHandle);
```

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.

## Methods

### Dsa.FromDerBd

`Chilkat 11.7.0 · c · Dsa · FromDerBd · method · since 11.0.0`

```c
BOOL CkDsa_FromDerBd(HCkDsa cHandle, HCkBinData bd);
```

Loads a DSA private key from the DER bytes contained in the `BinData` object passed in `bd`. Returns `TRUE` on successful decoding.

**Private-key handling:** The `BinData` content contains secret key material and should be cleared or released when no longer needed.

Returns TRUE for success, FALSE for failure.

### Dsa.FromDerFile

`Chilkat 11.7.0 · c · Dsa · FromDerFile · method`

```c
BOOL CkDsa_FromDerFile(HCkDsa cHandle, const char *path);
```

Loads a DSA private key from the DER-encoded file specified by `path`. Returns `TRUE` when the file is read and decoded successfully; otherwise returns `FALSE`.

**Private-key handling:** Restrict access to the file because it contains secret key material. Check `LastErrorText` when loading fails.

Returns TRUE for success, FALSE for failure.

### Dsa.FromEncryptedPem

`Chilkat 11.7.0 · c · Dsa · FromEncryptedPem · method`

```c
BOOL CkDsa_FromEncryptedPem(HCkDsa cHandle, const char *password, const char *pemData);
```

Loads a DSA private key from the PEM text in `pemData`. `password` supplies the password when the PEM is encrypted. If the PEM is unencrypted, the password is ignored and the key is loaded normally.

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.

**Security:** Do not embed production passwords in source code or log the PEM text. Prefer protected secret storage and encrypted private-key files where practical.

Returns TRUE for success, FALSE for failure.

### Dsa.FromPem

`Chilkat 11.7.0 · c · Dsa · FromPem · method`

```c
BOOL CkDsa_FromPem(HCkDsa cHandle, const char *pemData);
```

Loads an unencrypted DSA private key from the PEM text in `pemData`. On success, the object contains the private key and its corresponding public components.

**Unencrypted private key:** PEM armor is only a text encoding; it does not protect the private key. Treat the string as highly sensitive and use `FromEncryptedPem` when password-protected PEM is available.

Returns TRUE for success, FALSE for failure.

### Dsa.FromPublicDerBd

`Chilkat 11.7.0 · c · Dsa · FromPublicDerBd · method · since 11.0.0`

```c
BOOL CkDsa_FromPublicDerBd(HCkDsa cHandle, HCkBinData bd);
```

Loads a DSA public key from the DER bytes contained in the `BinData` object passed in `bd`. The resulting key can verify signatures but cannot sign.

Returns TRUE for success, FALSE for failure.

### Dsa.FromPublicDerFile

`Chilkat 11.7.0 · c · Dsa · FromPublicDerFile · method`

```c
BOOL CkDsa_FromPublicDerFile(HCkDsa cHandle, const char *path);
```

Loads a DSA public key from the DER-encoded file specified by `path`. Returns `TRUE` when the file is read and decoded successfully; otherwise returns `FALSE`.

Returns TRUE for success, FALSE for failure.

### Dsa.FromPublicPem

`Chilkat 11.7.0 · c · Dsa · FromPublicPem · method`

```c
BOOL CkDsa_FromPublicPem(HCkDsa cHandle, const char *pemData);
```

Loads a DSA public key from the PEM text in `pemData`. Returns `TRUE` when the PEM contains a supported DSA public key and is decoded successfully.

Returns TRUE for success, FALSE for failure.

### Dsa.FromXml

`Chilkat 11.7.0 · c · Dsa · FromXml · method`

```c
BOOL CkDsa_FromXml(HCkDsa cHandle, const char *xmlKey);
```

Loads a DSA public or private key from the XML text in `xmlKey`. The XML content determines whether the resulting object contains public components only or also includes the private value `X`.

**Security:** XML is only a representation format. If the XML contains `X`, it contains the complete private key and must be protected accordingly.

Returns TRUE for success, FALSE for failure.

### Dsa.GenKey

`Chilkat 11.7.0 · c · Dsa · GenKey · method`

```c
BOOL CkDsa_GenKey(HCkDsa cHandle, int numBits);
```

Generates a new DSA key pair with a `P` size of `numBits` bits. `numBits` must be at least 1024 and a multiple of 64. This legacy method uses the subgroup size selected by `GroupSize`, whose default is 160 bits.

For explicit standard parameter pairs such as `(2048, 224)` or `(3072, 256)`, use `GenKey2`.

**Legacy algorithm:** DSA signature generation is no longer approved by FIPS 186-5. Generate new DSA keys only when required for compatibility with an existing protocol, key store, or signature format.

Returns TRUE for success, FALSE for failure.

### Dsa.GenKey2

`Chilkat 11.7.0 · c · Dsa · GenKey2 · method · since 9.5.0.90`

```c
BOOL CkDsa_GenKey2(HCkDsa cHandle, int keyLenBits, int modLenBits);
```

Generates a new DSA key pair using an explicit `(L, N)` parameter-size combination. `keyLenBits` is `L`, the bit length of the prime modulus `P`. `modLenBits` is `N`, 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 |

**Current standards status:** These combinations come from the superseded FIPS 186-4 DSA specification. FIPS 186-5 no longer approves DSA signature generation; use this method only for compatibility.

Returns TRUE for success, FALSE for failure.

### Dsa.GenKeyFromParamsDerBd

`Chilkat 11.7.0 · c · Dsa · GenKeyFromParamsDerBd · method · since 11.0.0`

```c
BOOL CkDsa_GenKeyFromParamsDerBd(HCkDsa cHandle, HCkBinData bd);
```

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.

### Dsa.GenKeyFromParamsDerFile

`Chilkat 11.7.0 · c · Dsa · GenKeyFromParamsDerFile · method`

```c
BOOL CkDsa_GenKeyFromParamsDerFile(HCkDsa cHandle, const char *path);
```

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.

### Dsa.GenKeyFromParamsPem

`Chilkat 11.7.0 · c · Dsa · GenKeyFromParamsPem · method`

```c
BOOL CkDsa_GenKeyFromParamsPem(HCkDsa cHandle, const char *pem);
```

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.

### Dsa.GenKeyFromParamsPemFile

`Chilkat 11.7.0 · c · Dsa · GenKeyFromParamsPemFile · method`

```c
BOOL CkDsa_GenKeyFromParamsPemFile(HCkDsa cHandle, const char *path);
```

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.

### Dsa.GenKeyFromPQG

`Chilkat 11.7.0 · c · Dsa · GenKeyFromPQG · method · since 9.5.0.90`

```c
BOOL CkDsa_GenKeyFromPQG(HCkDsa cHandle, const char *pHex, const char *qHex, const char *gHex);
```

Generates a new DSA private/public key pair using the preselected domain parameters `P`, `Q`, and `G` supplied in `pHex`, `qHex`, and `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.

**Parameter provenance:** Only use DSA parameters obtained from a trusted, validated source. Malformed or maliciously chosen domain parameters can undermine signature security.

Returns TRUE for success, FALSE for failure.

### Dsa.GetEncodedHash

`Chilkat 11.7.0 · c · Dsa · GetEncodedHash · method`

```c
BOOL CkDsa_GetEncodedHash(HCkDsa cHandle, const char *encoding, HCkString outStr);
const char *CkDsa_getEncodedHash(HCkDsa cHandle, const char *encoding);
```

Returns the current `Hash` bytes encoded according to `encoding`. Use `hex` or `base64`.

This method does not compute a hash; it only converts the bytes already stored in the `Hash` property to text.

Returns TRUE for success, FALSE for failure.

### Dsa.GetEncodedSignature

`Chilkat 11.7.0 · c · Dsa · GetEncodedSignature · method`

```c
BOOL CkDsa_GetEncodedSignature(HCkDsa cHandle, const char *encoding, HCkString outStr);
const char *CkDsa_getEncodedSignature(HCkDsa cHandle, const char *encoding);
```

Returns the current `Signature` bytes encoded according to `encoding`. Use `hex` 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 TRUE for success, FALSE for failure.

### Dsa.LoadText

`Chilkat 11.7.0 · c · Dsa · LoadText · method`

```c
BOOL CkDsa_LoadText(HCkDsa cHandle, const char *path, HCkString outStr);
const char *CkDsa_loadText(HCkDsa cHandle, const char *path);
```

Loads the entire file specified by `path` and returns its contents as text using the legacy ANSI character encoding.

**Encoding note:** This convenience method is suitable for ASCII-compatible PEM and similar legacy text. It is not a general Unicode file reader; use an API with an explicit character encoding when UTF-8 or other Unicode text must be preserved.

Returns TRUE for success, FALSE for failure.

### Dsa.SaveText

`Chilkat 11.7.0 · c · Dsa · SaveText · method`

```c
BOOL CkDsa_SaveText(HCkDsa cHandle, const char *strToSave, const char *path);
```

Writes `strToSave` to the file specified by `path` using the legacy ANSI character encoding. Returns `TRUE` on success.

**Encoding note:** This convenience method is appropriate for ASCII-compatible PEM text. It can lose characters that are not representable in the active ANSI encoding, so use an explicitly encoded text-writing API for general Unicode content.

Returns TRUE for success, FALSE for failure.

### Dsa.SetEncodedHash

`Chilkat 11.7.0 · c · Dsa · SetEncodedHash · method`

```c
BOOL CkDsa_SetEncodedHash(HCkDsa cHandle, const char *encoding, const char *encodedHash);
```

Decodes `encodedHash` using the encoding named by `encoding` and stores the resulting bytes in the `Hash` 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.

### Dsa.SetEncodedSignature

`Chilkat 11.7.0 · c · Dsa · SetEncodedSignature · method`

```c
BOOL CkDsa_SetEncodedSignature(HCkDsa cHandle, const char *encoding, const char *encodedSig);
```

Decodes the signature text in `encodedSig` using the encoding named by `encoding` and stores the resulting bytes in the `Signature` 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.

### Dsa.SetEncodedSignatureRS

`Chilkat 11.7.0 · c · Dsa · SetEncodedSignatureRS · method`

```c
BOOL CkDsa_SetEncodedSignatureRS(HCkDsa cHandle, const char *encoding, const char *encodedR, const char *encodedS);
```

Builds the DSA signature from separately encoded `r` and `s` integer values. `encoding` identifies the encoding used by both `encodedR` and `encodedS`; use `hex` 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.

### Dsa.SetKeyExplicit

`Chilkat 11.7.0 · c · Dsa · SetKeyExplicit · method`

```c
BOOL CkDsa_SetKeyExplicit(HCkDsa cHandle, int groupSizeInBytes, const char *pHex, const char *qHex, const char *gHex, const char *xHex);
```

Loads a DSA private key from explicitly supplied components. `groupSizeInBytes` is the size of `Q` in bytes. `pHex`, `qHex`, `gHex`, and `xHex` provide `P`, `Q`, `G`, and the private value `X`, respectively.

The corresponding public value `Y = GX mod P` is derived from the private key.

**SSH1 bignums:** Each component string is hexadecimal text representing an SSH1-format bignum: a two-byte bit-length prefix followed by the unsigned integer bytes.

**Sensitive value:** `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.

### Dsa.SetPubKeyExplicit

`Chilkat 11.7.0 · c · Dsa · SetPubKeyExplicit · method`

```c
BOOL CkDsa_SetPubKeyExplicit(HCkDsa cHandle, int groupSizeInBytes, const char *pHex, const char *qHex, const char *gHex, const char *yHex);
```

Loads a DSA public key from explicitly supplied components. `groupSizeInBytes` is the size of `Q` in bytes. `pHex`, `qHex`, `gHex`, and `yHex` provide `P`, `Q`, `G`, and the public value `Y`, respectively.

The resulting object can verify DSA signatures but cannot create them.

**SSH1 bignums:** Each component string is hexadecimal text representing an SSH1-format bignum: a two-byte bit-length prefix followed by the unsigned integer bytes.

Returns TRUE for success, FALSE for failure.

### Dsa.SignHash

`Chilkat 11.7.0 · c · Dsa · SignHash · method`

```c
BOOL CkDsa_SignHash(HCkDsa cHandle);
```

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.

**Security-critical nonce:** Each DSA signature requires a secret per-signature value. Reuse or poor generation of that value can reveal the private key. Chilkat performs this generation internally; applications should not attempt to reuse signature state.

**Standards status:** FIPS 186-5 no longer approves DSA for generating new signatures. Use this method only for required legacy interoperability.

Returns TRUE for success, FALSE for failure.

### Dsa.ToDerBd

`Chilkat 11.7.0 · c · Dsa · ToDerBd · method · since 11.0.0`

```c
BOOL CkDsa_ToDerBd(HCkDsa cHandle, HCkBinData bd);
```

Writes the DER-encoded DSA private key to the `BinData` object passed in `bd`. Returns `TRUE` on success.

**Sensitive output:** The destination contains unencrypted private-key bytes after a successful call. Protect and clear it appropriately.

Returns TRUE for success, FALSE for failure.

### Dsa.ToDerFile

`Chilkat 11.7.0 · c · Dsa · ToDerFile · method`

```c
BOOL CkDsa_ToDerFile(HCkDsa cHandle, const char *path);
```

Writes the loaded DSA private key to the DER file specified by `path`. Returns `TRUE` on success.

**Sensitive output:** The file contains unencrypted private-key material. Apply restrictive filesystem permissions and avoid writing it to shared or temporary locations.

Returns TRUE for success, FALSE for failure.

### Dsa.ToEncryptedPem

`Chilkat 11.7.0 · c · Dsa · ToEncryptedPem · method`

```c
BOOL CkDsa_ToEncryptedPem(HCkDsa cHandle, const char *password, HCkString outStr);
const char *CkDsa_toEncryptedPem(HCkDsa cHandle, const char *password);
```

Returns the loaded DSA private key as password-encrypted PEM text using `password` as the password.

**Password protection:** Use a strong password and protect it separately from the PEM. Encrypted PEM reduces exposure at rest but does not make it safe to log or transmit indiscriminately.

Returns TRUE for success, FALSE for failure.

### Dsa.ToPem

`Chilkat 11.7.0 · c · Dsa · ToPem · method`

```c
BOOL CkDsa_ToPem(HCkDsa cHandle, HCkString outStr);
const char *CkDsa_toPem(HCkDsa cHandle);
```

Returns the loaded DSA private key as unencrypted PEM text.

**Unencrypted private key:** PEM armor is not encryption. Anyone who obtains this text can use the private key, so prefer `ToEncryptedPem` when password protection is required.

Returns TRUE for success, FALSE for failure.

### Dsa.ToPublicDerFile

`Chilkat 11.7.0 · c · Dsa · ToPublicDerFile · method`

```c
BOOL CkDsa_ToPublicDerFile(HCkDsa cHandle, const char *path);
```

Writes the public portion of the loaded DSA key to the DER file specified by `path`. Returns `TRUE` on success.

Returns TRUE for success, FALSE for failure.

### Dsa.ToPublicPem

`Chilkat 11.7.0 · c · Dsa · ToPublicPem · method`

```c
BOOL CkDsa_ToPublicPem(HCkDsa cHandle, HCkString outStr);
const char *CkDsa_toPublicPem(HCkDsa cHandle);
```

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 TRUE for success, FALSE for failure.

### Dsa.ToXml

`Chilkat 11.7.0 · c · Dsa · ToXml · method`

```c
BOOL CkDsa_ToXml(HCkDsa cHandle, BOOL bPublicOnly, HCkString outStr);
const char *CkDsa_toXml(HCkDsa cHandle, BOOL bPublicOnly);
```

Returns the loaded DSA key as XML. Set `bPublicOnly` to `TRUE` to export public components only. Set it to `FALSE` to include the private component when a private key is loaded.

**Security:** When `bPublicOnly` is `FALSE`, the XML can contain the private value `X`. Protect it as private-key material.

Returns TRUE for success, FALSE for failure.

### Dsa.Verify

`Chilkat 11.7.0 · c · Dsa · Verify · method`

```c
BOOL CkDsa_Verify(HCkDsa cHandle);
```

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.

### Dsa.VerifyKey

`Chilkat 11.7.0 · c · Dsa · VerifyKey · method`

```c
BOOL CkDsa_VerifyKey(HCkDsa cHandle);
```

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.

## Deprecated members — do not use in new code

| Member | Kind | Deprecated in | Use instead |
|---|---|---|---|
| `FromDer` | method | before 11.6.1 | — |
| `FromPublicDer` | method | before 11.6.1 | — |
| `GenKeyFromParamsDer` | method | before 11.6.1 | — |
| `ToDer` | method | before 11.6.1 | — |
| `ToPublicDer` | method | before 11.6.1 | — |
| `ToPublicDerBd` | method | before 11.6.1 | — |

## Related classes

[`BinData`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/c/classes/BinData.md)

