---
name: "libressl-DSA_set_method"
section: "3"
platform: "linux"
package: "libressl"
version: "4.4.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libressl-DSA_set_method"
---

# libressl-DSA\_set\_method(3)

select DSA method

## NAME

**DSA\_set\_default\_method**, **DSA\_get\_default\_method**, **DSA\_set\_method**, **DSA\_new\_method**, **DSA\_OpenSSL** – select DSA method

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

**#include \<openssl/dsa.h\>**

*void*\

**DSA\_set\_default\_method**(*const DSA\_METHOD \*meth*);

*const* *DSA\_METHOD* *\**\

**DSA\_get\_default\_method**(*void*);

*int*\

**DSA\_set\_method**(*DSA \*dsa*, *const DSA\_METHOD \*meth*);

*DSA* *\**\

**DSA\_new\_method**(*ENGINE \*engine*);

*DSA\_METHOD* *\**\

**DSA\_OpenSSL**(*void*);

## DESCRIPTION

A *DSA\_METHOD* object contains pointers to the functions used for DSA operations. By default, the internal implementation returned by **DSA\_OpenSSL**() is used. By selecting another method, alternative implementations such as hardware accelerators may be used.

**DSA\_set\_default\_method**() selects *meth* as the default method for all *DSA* structures created later.

**DSA\_get\_default\_method**() returns a pointer to the current default method.

**DSA\_set\_method**() selects *meth* to perform all operations using the key *dsa*. This replaces the *DSA\_METHOD* used by the DSA key. It is possible to have DSA keys that only work with certain *DSA\_METHOD* implementations, and in such cases attempting to change the *DSA\_METHOD* for the key can have unexpected results.

**DSA\_new\_method**() allocates and initializes a *DSA* structure. The *engine* argument is ignored and the default method controlled by **DSA\_set\_default\_method**() is used.

The *DSA\_METHOD* structure is defined as follows:

```
struct {
	/* name of the implementation */
	const char *name;
	/* sign */
	DSA_SIG *(*dsa_do_sign)(const unsigned char *dgst, int dlen,
	    DSA *dsa);
	/* pre-compute k^-1 and r */
	int (*dsa_sign_setup)(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp,
	    BIGNUM **rp);
	/* verify */
	int (*dsa_do_verify)(const unsigned char *dgst, int dgst_len,
	    DSA_SIG *sig, DSA *dsa);
	/* called at DSA_new */
	int (*init)(DSA *DSA);
	/* called at DSA_free */
	int (*finish)(DSA *DSA);
	int flags;
} DSA_METHOD;
```

## RETURN VALUES

**DSA\_OpenSSL**() and **DSA\_get\_default\_method**() return pointers to the respective *DSA\_METHOD*.

**DSA\_set\_method**() returns 1 on success or 0 on failure. Currently, it cannot fail.

**DSA\_new\_method**() returns NULL and sets an error code that can be obtained by ERR\_get\_error(3) if the allocation fails. Otherwise it returns a pointer to the newly allocated structure.

## SEE ALSO

DSA\_meth\_new(3), DSA\_new(3)

## HISTORY

**DSA\_set\_default\_method**(), **DSA\_get\_default\_method**(), **DSA\_set\_method**(), **DSA\_new\_method**(), and **DSA\_OpenSSL**() first appeared in OpenSSL 0.9.5 and have been available since OpenBSD 2.7.
