---
product: Chilkat
product_version: 11.7.0
language: sqlserver
language_label: SQL Server
class: Dsa
license: bundle
deprecated: false
reference_html: https://www.chilkatsoft.com/refdoc/sqlserver_DsaRef.html
---
# Chilkat Dsa — SQL Server — v11.7.0

> Chilkat 11.7.0 · language=sqlserver · 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/sqlserver/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

**Object Creation**

```sql
DECLARE @hr int
DECLARE @dsa int
EXEC @hr = sp_OACreate 'Chilkat.Dsa', @dsa OUT
IF @hr <> 0
BEGIN
    PRINT 'Failed to create ActiveX component'
    RETURN
END

-- ... use @dsa ...

EXEC @hr = sp_OADestroy @dsa
```

T-SQL uses the Chilkat ActiveX through the OLE Automation stored procedures. They must be enabled once on the server (`EXEC sp_configure 'Ole Automation Procedures', 1; RECONFIGURE;`), and the Chilkat ActiveX registered must match the bitness of the SQL Server instance (64-bit for a 64-bit SQL Server). To bind to a specific major version of Chilkat, append the major version number to the ProgID, such as `sp_OACreate 'Chilkat.Dsa.11'` for Chilkat v11.\*.\*.

`sp_OACreate` returns an object token (an `int`) that is passed as the first argument of every `sp_OAMethod`, `sp_OAGetProperty` and `sp_OASetProperty` call, and released with `sp_OADestroy`. Objects returned by methods (such as an `HttpResponse` or `JsonObject`) are also tokens received through an `int` OUT parameter; they must likewise be destroyed, and the OUT parameter is `NULL` when the method fails to return an object. Objects passed as arguments are passed by their token. When an OLE Automation procedure itself fails (non-zero `@hr`), `sp_OAGetErrorInfo` describes the error.

Data types: strings are `nvarchar(4000)`; integers, booleans (1 or 0) and object tokens are `int`; dates are `datetime`. In the signatures on this page, `@success`, `@iResult`, `@sResult` and the like are the OUT variables receiving a method's return value, `@iValue` / `@sValue` receive or supply a property value, and the remaining `@` variables are the method's arguments in order.

A string returned through an OUT parameter is limited to 4000 characters. For longer values, retrieve the result as a result set into a table variable instead of an OUT parameter, for example `DECLARE @tmp TABLE (outputLine ntext)` followed by `INSERT INTO @tmp EXEC sp_OAGetProperty @dsa, 'LastErrorText'`. See [string length limitations for strings returned by sp_OAMethod calls](https://www.chilkatsoft.com/sql_server_nvarchar_max_limitation.asp).

Methods that pass or return raw byte arrays are not shown on this page, because `varbinary(max)` values cannot be exchanged through `sp_OAMethod` (see [varbinary(max) limitation](https://www.chilkatsoft.com/sql_server_varbinary_max_limitation.asp)). Use the `BinData`-based alternatives (methods ending in *Bd*) or the base64 / hex string-encoded variants instead. Binary *properties* (such as `LastBinaryResult`) can be retrieved as a result set into a table variable, as shown in their signatures. Asynchronous (*\*Async*) methods and event callbacks are not available from SQL Server.

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 SQL Server.

How failure is reported depends on the method's return type and is stated in the note under each method below. In every case the diagnostic text is in the `LastErrorText` property of the object whose method was called.

## 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` | `EXEC sp_OAGetProperty @dsa, 'DebugLogFilePath', @sValue OUT EXEC sp_OASetProperty @dsa, 'DebugLogFilePath', @sValue` | read/write | If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. |
| `LastBinaryResult` | `INSERT INTO @tmp EXEC sp_OAGetProperty @dsa, 'LastBinaryResult'` | read-only | This property is mainly used in SQL Server stored procedures to retrieve binary data from the last method call that returned binary data. |
| `LastErrorHtml` | `EXEC sp_OAGetProperty @dsa, 'LastErrorHtml', @sValue OUT` | read-only | Provides HTML-formatted information about the last called method or property. |
| `LastErrorText` | `EXEC sp_OAGetProperty @dsa, 'LastErrorText', @sValue OUT` | read-only | Provides plain text information about the last called method or property. |
| `LastErrorXml` | `EXEC sp_OAGetProperty @dsa, 'LastErrorXml', @sValue OUT` | read-only | Provides XML-formatted information about the last called method or property. |
| `LastMethodSuccess` | `EXEC sp_OAGetProperty @dsa, 'LastMethodSuccess', @iValue OUT EXEC sp_OASetProperty @dsa, 'LastMethodSuccess', @iValue` | read/write | Indicates the success or failure of the most recent method call: `1` means success, `0` means failure. |
| `LastStringResult` | `EXEC sp_OAGetProperty @dsa, 'LastStringResult', @sValue OUT` | read-only | In SQL Server stored procedures, this property holds the string return value of the most recent method call that returns a string. |
| `LastStringResultLen` | `EXEC sp_OAGetProperty @dsa, 'LastStringResultLen', @iValue OUT` | read-only | The length, in characters, of the string contained in the LastStringResult property. |
| `VerboseLogging` | `EXEC sp_OAGetProperty @dsa, 'VerboseLogging', @iValue OUT EXEC sp_OASetProperty @dsa, 'VerboseLogging', @iValue` | read/write | If set to `1`, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. |
| `Version` | `EXEC sp_OAGetProperty @dsa, 'Version', @sValue OUT` | read-only | Version of the component/library, such as "10.1.0" |

## Member index

| Member | Kind | Signature |
|---|---|---|
| `GroupSize` | property, read/write | `EXEC sp_OAGetProperty @dsa, 'GroupSize', @iValue OUT EXEC sp_OASetProperty @dsa, 'GroupSize', @iValue` |
| `Hash` | property, read/write | `INSERT INTO @tmp EXEC sp_OAGetProperty @dsa, 'Hash'` |
| `HexG` | property, read-only | `EXEC sp_OAGetProperty @dsa, 'HexG', @sValue OUT` |
| `HexP` | property, read-only | `EXEC sp_OAGetProperty @dsa, 'HexP', @sValue OUT` |
| `HexQ` | property, read-only | `EXEC sp_OAGetProperty @dsa, 'HexQ', @sValue OUT` |
| `HexX` | property, read-only | `EXEC sp_OAGetProperty @dsa, 'HexX', @sValue OUT` |
| `HexY` | property, read-only | `EXEC sp_OAGetProperty @dsa, 'HexY', @sValue OUT` |
| `Signature` | property, read/write | `INSERT INTO @tmp EXEC sp_OAGetProperty @dsa, 'Signature'` |
| `UncommonOptions` | property, read/write | `EXEC sp_OAGetProperty @dsa, 'UncommonOptions', @sValue OUT EXEC sp_OASetProperty @dsa, 'UncommonOptions', @sValue` |
| `FromDerBd` | method | `EXEC sp_OAMethod @dsa, 'FromDerBd', @success OUT, @bd` |
| `FromDerFile` | method | `EXEC sp_OAMethod @dsa, 'FromDerFile', @success OUT, @path` |
| `FromEncryptedPem` | method | `EXEC sp_OAMethod @dsa, 'FromEncryptedPem', @success OUT, @password, @pemData` |
| `FromPem` | method | `EXEC sp_OAMethod @dsa, 'FromPem', @success OUT, @pemData` |
| `FromPublicDerBd` | method | `EXEC sp_OAMethod @dsa, 'FromPublicDerBd', @success OUT, @bd` |
| `FromPublicDerFile` | method | `EXEC sp_OAMethod @dsa, 'FromPublicDerFile', @success OUT, @path` |
| `FromPublicPem` | method | `EXEC sp_OAMethod @dsa, 'FromPublicPem', @success OUT, @pemData` |
| `FromXml` | method | `EXEC sp_OAMethod @dsa, 'FromXml', @success OUT, @xmlKey` |
| `GenKey` | method | `EXEC sp_OAMethod @dsa, 'GenKey', @success OUT, @numBits` |
| `GenKey2` | method | `EXEC sp_OAMethod @dsa, 'GenKey2', @success OUT, @keyLenBits, @modLenBits` |
| `GenKeyFromParamsDerBd` | method | `EXEC sp_OAMethod @dsa, 'GenKeyFromParamsDerBd', @success OUT, @bd` |
| `GenKeyFromParamsDerFile` | method | `EXEC sp_OAMethod @dsa, 'GenKeyFromParamsDerFile', @success OUT, @path` |
| `GenKeyFromParamsPem` | method | `EXEC sp_OAMethod @dsa, 'GenKeyFromParamsPem', @success OUT, @pem` |
| `GenKeyFromParamsPemFile` | method | `EXEC sp_OAMethod @dsa, 'GenKeyFromParamsPemFile', @success OUT, @path` |
| `GenKeyFromPQG` | method | `EXEC sp_OAMethod @dsa, 'GenKeyFromPQG', @success OUT, @pHex, @qHex, @gHex` |
| `GetEncodedHash` | method | `EXEC sp_OAMethod @dsa, 'GetEncodedHash', @sResult OUT, @encoding` |
| `GetEncodedSignature` | method | `EXEC sp_OAMethod @dsa, 'GetEncodedSignature', @sResult OUT, @encoding` |
| `LoadText` | method | `EXEC sp_OAMethod @dsa, 'LoadText', @sResult OUT, @path` |
| `SaveText` | method | `EXEC sp_OAMethod @dsa, 'SaveText', @success OUT, @strToSave, @path` |
| `SetEncodedHash` | method | `EXEC sp_OAMethod @dsa, 'SetEncodedHash', @success OUT, @encoding, @encodedHash` |
| `SetEncodedSignature` | method | `EXEC sp_OAMethod @dsa, 'SetEncodedSignature', @success OUT, @encoding, @encodedSig` |
| `SetEncodedSignatureRS` | method | `EXEC sp_OAMethod @dsa, 'SetEncodedSignatureRS', @success OUT, @encoding, @encodedR, @encodedS` |
| `SetKeyExplicit` | method | `EXEC sp_OAMethod @dsa, 'SetKeyExplicit', @success OUT, @groupSizeInBytes, @pHex, @qHex, @gHex, @xHex` |
| `SetPubKeyExplicit` | method | `EXEC sp_OAMethod @dsa, 'SetPubKeyExplicit', @success OUT, @groupSizeInBytes, @pHex, @qHex, @gHex, @yHex` |
| `SignHash` | method | `EXEC sp_OAMethod @dsa, 'SignHash', @success OUT` |
| `ToDerBd` | method | `EXEC sp_OAMethod @dsa, 'ToDerBd', @success OUT, @bd` |
| `ToDerFile` | method | `EXEC sp_OAMethod @dsa, 'ToDerFile', @success OUT, @path` |
| `ToEncryptedPem` | method | `EXEC sp_OAMethod @dsa, 'ToEncryptedPem', @sResult OUT, @password` |
| `ToPem` | method | `EXEC sp_OAMethod @dsa, 'ToPem', @sResult OUT` |
| `ToPublicDerBd` | method | `EXEC sp_OAMethod @dsa, 'ToPublicDerBd', @success OUT, @bd` |
| `ToPublicDerFile` | method | `EXEC sp_OAMethod @dsa, 'ToPublicDerFile', @success OUT, @path` |
| `ToPublicPem` | method | `EXEC sp_OAMethod @dsa, 'ToPublicPem', @sResult OUT` |
| `ToXml` | method | `EXEC sp_OAMethod @dsa, 'ToXml', @sResult OUT, @bPublicOnly` |
| `Verify` | method | `EXEC sp_OAMethod @dsa, 'Verify', @success OUT` |
| `VerifyKey` | method | `EXEC sp_OAMethod @dsa, 'VerifyKey', @success OUT` |

## Properties

### Dsa.GroupSize

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

```sql
EXEC sp_OAGetProperty @dsa, 'GroupSize', @iValue OUT
EXEC sp_OASetProperty @dsa, 'GroupSize', @iValue
```

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

`Chilkat 11.7.0 · sqlserver · Dsa · Hash · property · read/write`

```sql
INSERT INTO @tmp EXEC sp_OAGetProperty @dsa, 'Hash'
```

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.

**Important:** Signing and verification must use identical digest bytes. A different hash algorithm, text encoding, canonicalization rule, or line-ending convention produces a different digest and causes verification to fail.

### Dsa.HexG

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

```sql
EXEC sp_OAGetProperty @dsa, 'HexG', @sValue OUT
```

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 · sqlserver · Dsa · HexP · property · read-only`

```sql
EXEC sp_OAGetProperty @dsa, 'HexP', @sValue OUT
```

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 · sqlserver · Dsa · HexQ · property · read-only`

```sql
EXEC sp_OAGetProperty @dsa, 'HexQ', @sValue OUT
```

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 · sqlserver · Dsa · HexX · property · read-only`

```sql
EXEC sp_OAGetProperty @dsa, 'HexX', @sValue OUT
```

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 · sqlserver · Dsa · HexY · property · read-only`

```sql
EXEC sp_OAGetProperty @dsa, 'HexY', @sValue OUT
```

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

`Chilkat 11.7.0 · sqlserver · Dsa · Signature · property · read/write`

```sql
INSERT INTO @tmp EXEC sp_OAGetProperty @dsa, 'Signature'
```

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.

### Dsa.UncommonOptions

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

```sql
EXEC sp_OAGetProperty @dsa, 'UncommonOptions', @sValue OUT
EXEC sp_OASetProperty @dsa, 'UncommonOptions', @sValue
```

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 · sqlserver · Dsa · FromDerBd · method · since 11.0.0`

```sql
EXEC sp_OAMethod @dsa, 'FromDerBd', @success OUT, @bd
```

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

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

Returns 1 for success, 0 for failure.

### Dsa.FromDerFile

`Chilkat 11.7.0 · sqlserver · Dsa · FromDerFile · method`

```sql
EXEC sp_OAMethod @dsa, 'FromDerFile', @success OUT, @path
```

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

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

Returns 1 for success, 0 for failure.

### Dsa.FromEncryptedPem

`Chilkat 11.7.0 · sqlserver · Dsa · FromEncryptedPem · method`

```sql
EXEC sp_OAMethod @dsa, 'FromEncryptedPem', @success OUT, @password, @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 `1` on success and `0` 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 1 for success, 0 for failure.

### Dsa.FromPem

`Chilkat 11.7.0 · sqlserver · Dsa · FromPem · method`

```sql
EXEC sp_OAMethod @dsa, 'FromPem', @success OUT, @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 1 for success, 0 for failure.

### Dsa.FromPublicDerBd

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

```sql
EXEC sp_OAMethod @dsa, 'FromPublicDerBd', @success OUT, @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 1 for success, 0 for failure.

### Dsa.FromPublicDerFile

`Chilkat 11.7.0 · sqlserver · Dsa · FromPublicDerFile · method`

```sql
EXEC sp_OAMethod @dsa, 'FromPublicDerFile', @success OUT, @path
```

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

Returns 1 for success, 0 for failure.

### Dsa.FromPublicPem

`Chilkat 11.7.0 · sqlserver · Dsa · FromPublicPem · method`

```sql
EXEC sp_OAMethod @dsa, 'FromPublicPem', @success OUT, @pemData
```

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

Returns 1 for success, 0 for failure.

### Dsa.FromXml

`Chilkat 11.7.0 · sqlserver · Dsa · FromXml · method`

```sql
EXEC sp_OAMethod @dsa, 'FromXml', @success OUT, @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 1 for success, 0 for failure.

### Dsa.GenKey

`Chilkat 11.7.0 · sqlserver · Dsa · GenKey · method`

```sql
EXEC sp_OAMethod @dsa, 'GenKey', @success OUT, @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 1 for success, 0 for failure.

### Dsa.GenKey2

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

```sql
EXEC sp_OAMethod @dsa, 'GenKey2', @success OUT, @keyLenBits, @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 1 for success, 0 for failure.

### Dsa.GenKeyFromParamsDerBd

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

```sql
EXEC sp_OAMethod @dsa, 'GenKeyFromParamsDerBd', @success OUT, @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 1 for success, 0 for failure.

### Dsa.GenKeyFromParamsDerFile

`Chilkat 11.7.0 · sqlserver · Dsa · GenKeyFromParamsDerFile · method`

```sql
EXEC sp_OAMethod @dsa, 'GenKeyFromParamsDerFile', @success OUT, @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 `1` when the parameters are loaded and a key pair is generated successfully.

Returns 1 for success, 0 for failure.

### Dsa.GenKeyFromParamsPem

`Chilkat 11.7.0 · sqlserver · Dsa · GenKeyFromParamsPem · method`

```sql
EXEC sp_OAMethod @dsa, 'GenKeyFromParamsPem', @success OUT, @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 1 for success, 0 for failure.

### Dsa.GenKeyFromParamsPemFile

`Chilkat 11.7.0 · sqlserver · Dsa · GenKeyFromParamsPemFile · method`

```sql
EXEC sp_OAMethod @dsa, 'GenKeyFromParamsPemFile', @success OUT, @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 1 for success, 0 for failure.

### Dsa.GenKeyFromPQG

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

```sql
EXEC sp_OAMethod @dsa, 'GenKeyFromPQG', @success OUT, @pHex, @qHex, @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 1 for success, 0 for failure.

### Dsa.GetEncodedHash

`Chilkat 11.7.0 · sqlserver · Dsa · GetEncodedHash · method`

```sql
EXEC sp_OAMethod @dsa, 'GetEncodedHash', @sResult OUT, @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 `NULL` on failure

### Dsa.GetEncodedSignature

`Chilkat 11.7.0 · sqlserver · Dsa · GetEncodedSignature · method`

```sql
EXEC sp_OAMethod @dsa, 'GetEncodedSignature', @sResult OUT, @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 `NULL` on failure

### Dsa.LoadText

`Chilkat 11.7.0 · sqlserver · Dsa · LoadText · method`

```sql
EXEC sp_OAMethod @dsa, 'LoadText', @sResult OUT, @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 `NULL` on failure

### Dsa.SaveText

`Chilkat 11.7.0 · sqlserver · Dsa · SaveText · method`

```sql
EXEC sp_OAMethod @dsa, 'SaveText', @success OUT, @strToSave, @path
```

Writes `strToSave` to the file specified by `path` using the legacy ANSI character encoding. Returns `1` 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 1 for success, 0 for failure.

### Dsa.SetEncodedHash

`Chilkat 11.7.0 · sqlserver · Dsa · SetEncodedHash · method`

```sql
EXEC sp_OAMethod @dsa, 'SetEncodedHash', @success OUT, @encoding, @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 1 for success, 0 for failure.

### Dsa.SetEncodedSignature

`Chilkat 11.7.0 · sqlserver · Dsa · SetEncodedSignature · method`

```sql
EXEC sp_OAMethod @dsa, 'SetEncodedSignature', @success OUT, @encoding, @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 1 for success, 0 for failure.

### Dsa.SetEncodedSignatureRS

`Chilkat 11.7.0 · sqlserver · Dsa · SetEncodedSignatureRS · method`

```sql
EXEC sp_OAMethod @dsa, 'SetEncodedSignatureRS', @success OUT, @encoding, @encodedR, @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 1 for success, 0 for failure.

### Dsa.SetKeyExplicit

`Chilkat 11.7.0 · sqlserver · Dsa · SetKeyExplicit · method`

```sql
EXEC sp_OAMethod @dsa, 'SetKeyExplicit', @success OUT, @groupSizeInBytes, @pHex, @qHex, @gHex, @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 1 for success, 0 for failure.

### Dsa.SetPubKeyExplicit

`Chilkat 11.7.0 · sqlserver · Dsa · SetPubKeyExplicit · method`

```sql
EXEC sp_OAMethod @dsa, 'SetPubKeyExplicit', @success OUT, @groupSizeInBytes, @pHex, @qHex, @gHex, @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 1 for success, 0 for failure.

### Dsa.SignHash

`Chilkat 11.7.0 · sqlserver · Dsa · SignHash · method`

```sql
EXEC sp_OAMethod @dsa, 'SignHash', @success OUT
```

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 1 for success, 0 for failure.

### Dsa.ToDerBd

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

```sql
EXEC sp_OAMethod @dsa, 'ToDerBd', @success OUT, @bd
```

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

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

Returns 1 for success, 0 for failure.

### Dsa.ToDerFile

`Chilkat 11.7.0 · sqlserver · Dsa · ToDerFile · method`

```sql
EXEC sp_OAMethod @dsa, 'ToDerFile', @success OUT, @path
```

Writes the loaded DSA private key to the DER file specified by `path`. Returns `1` 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 1 for success, 0 for failure.

### Dsa.ToEncryptedPem

`Chilkat 11.7.0 · sqlserver · Dsa · ToEncryptedPem · method`

```sql
EXEC sp_OAMethod @dsa, 'ToEncryptedPem', @sResult OUT, @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 `NULL` on failure

### Dsa.ToPem

`Chilkat 11.7.0 · sqlserver · Dsa · ToPem · method`

```sql
EXEC sp_OAMethod @dsa, 'ToPem', @sResult OUT
```

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 `NULL` on failure

### Dsa.ToPublicDerBd

`Chilkat 11.7.0 · sqlserver · Dsa · ToPublicDerBd · method · since 11.0.0`

```sql
EXEC sp_OAMethod @dsa, 'ToPublicDerBd', @success OUT, @bd
```

Writes the DER-encoded public portion of the loaded DSA key to the `BinData` object passed in `bd`. Returns `1` on success.

Returns 1 for success, 0 for failure.

### Dsa.ToPublicDerFile

`Chilkat 11.7.0 · sqlserver · Dsa · ToPublicDerFile · method`

```sql
EXEC sp_OAMethod @dsa, 'ToPublicDerFile', @success OUT, @path
```

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

Returns 1 for success, 0 for failure.

### Dsa.ToPublicPem

`Chilkat 11.7.0 · sqlserver · Dsa · ToPublicPem · method`

```sql
EXEC sp_OAMethod @dsa, 'ToPublicPem', @sResult OUT
```

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

### Dsa.ToXml

`Chilkat 11.7.0 · sqlserver · Dsa · ToXml · method`

```sql
EXEC sp_OAMethod @dsa, 'ToXml', @sResult OUT, @bPublicOnly
```

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

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

Returns `NULL` on failure

### Dsa.Verify

`Chilkat 11.7.0 · sqlserver · Dsa · Verify · method`

```sql
EXEC sp_OAMethod @dsa, 'Verify', @success OUT
```

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 `1` only when the signature is valid. A `0` result can indicate an invalid signature, malformed input, an incompatible key, or another operational error; inspect `LastErrorText` when the reason matters.

Returns 1 for success, 0 for failure.

### Dsa.VerifyKey

`Chilkat 11.7.0 · sqlserver · Dsa · VerifyKey · method`

```sql
EXEC sp_OAMethod @dsa, 'VerifyKey', @success OUT
```

Checks the mathematical validity and internal consistency of the DSA public or private key currently loaded in the object. Returns `1` 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.

## Related classes

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

