---
name: "libressl-DSA_get0_pqg"
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_get0_pqg"
---

# libressl-DSA\_get0\_pqg(3)

get data from and set data in a DSA object

## NAME

**DSA\_get0\_pqg**, **DSA\_get0\_p**, **DSA\_get0\_q**, **DSA\_get0\_g**, **DSA\_set0\_pqg**, **DSA\_get0\_key**, **DSA\_get0\_pub\_key**, **DSA\_get0\_priv\_key**, **DSA\_set0\_key**, **DSA\_clear\_flags**, **DSA\_test\_flags**, **DSA\_set\_flags**, **DSA\_get0\_engine** – get data from and set data in a DSA object

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

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

*void*\

**DSA\_get0\_pqg**(*const DSA \*d*, *const BIGNUM \*\*p*, *const BIGNUM \*\*q*, *const BIGNUM \*\*g*);

*const* *BIGNUM* *\**\

**DSA\_get0\_p**(*const DSA \*d*);

*const* *BIGNUM* *\**\

**DSA\_get0\_q**(*const DSA \*d*);

*const* *BIGNUM* *\**\

**DSA\_get0\_g**(*const DSA \*d*);

*int*\

**DSA\_set0\_pqg**(*DSA \*d*, *BIGNUM \*p*, *BIGNUM \*q*, *BIGNUM \*g*);

*void*\

**DSA\_get0\_key**(*const DSA \*d*, *const BIGNUM \*\*pub\_key*, *const BIGNUM \*\*priv\_key*);

*const* *BIGNUM* *\**\

**DSA\_get0\_pub\_key**(*const DSA \*d*);

*const* *BIGNUM* *\**\

**DSA\_get0\_priv\_key**(*const DSA \*d*);

*int*\

**DSA\_set0\_key**(*DSA \*d*, *BIGNUM \*pub\_key*, *BIGNUM \*priv\_key*);

*void*\

**DSA\_clear\_flags**(*DSA \*d*, *int flags*);

*int*\

**DSA\_test\_flags**(*const DSA \*d*, *int flags*);

*void*\

**DSA\_set\_flags**(*DSA \*d*, *int flags*);

*ENGINE* *\**\

**DSA\_get0\_engine**(*DSA \*d*);

## DESCRIPTION

A *DSA* object contains the parameters *p*, *q*, and *g*. It also contains a public key *pub\_key* and an optional private key *priv\_key*.

The *p*, *q*, and *g* parameters can be obtained by calling **DSA\_get0\_pqg**(). If the parameters have not yet been set, then \**p*, \**q*, and \**g* are set to NULL. Otherwise, they are set to pointers to the internal representations of the values that should not be freed by the application.

The *p*, *q*, and *g* values can be set by calling **DSA\_set0\_pqg**(). Calling this function transfers the memory management of the values to *d*, and therefore they should not be freed by the caller.

The **DSA\_get0\_key**() function stores pointers to the internal representations of the public key in \**pub\_key* and to the private key in \**priv\_key*. Either may be NULL if it has not yet been set. If the private key has been set, then the public key must be.

The public and private key values can be set using **DSA\_set0\_key**(). The public key must be non-NULL the first time this function is called on a given *DSA* object. The private key may be NULL. On subsequent calls, either may be NULL, which means the corresponding *DSA* field is left untouched. **DSA\_set0\_key**() transfers the memory management of the key values to *d*, and therefore they should not be freed by the caller.

Values retrieved with **DSA\_get0\_pqg**() and **DSA\_get0\_key**() are owned by the *DSA* object and may therefore not be passed to **DSA\_set0\_pqg**() or **DSA\_set0\_key**(). If needed, duplicate the received values using BN\_dup(3) and pass the duplicates.

Any of the values *p*, *q*, *g*, *pub\_key*, and *priv\_key* can also be retrieved separately by the corresponding functions **DSA\_get0\_p**(), **DSA\_get0\_q**(), **DSA\_get0\_g**(), **DSA\_get0\_pub\_key**(), and **DSA\_get0\_priv\_key**(), respectively. The pointers are owned by the *DSA* object.

**DSA\_clear\_flags**() clears the specified *flags* in *d*. **DSA\_test\_flags**() tests the *flags* in *d*. **DSA\_set\_flags**() sets the *flags* in *d*; any flags already set remain set. For all three functions, multiple flags can be passed in one call, OR'ed together bitwise.

## RETURN VALUES

**DSA\_get0\_p**(), **DSA\_get0\_q**(), **DSA\_get0\_g**(), **DSA\_get0\_pub\_key**(), and **DSA\_get0\_priv\_key**() return a pointer owned by the *DSA* object if the corresponding value has been set, otherwise they return NULL. **DSA\_set0\_pqg**() and **DSA\_set0\_key**() return 1 on success or 0 on failure.

**DSA\_test\_flags**() returns those of the given *flags* currently set in *d* or 0 if none of the given *flags* are set.

**DSA\_get0\_engine**() always returns NULL.

## SEE ALSO

DSA\_do\_sign(3), DSA\_dup\_DH(3), DSA\_generate\_key(3), DSA\_generate\_parameters\_ex(3), DSA\_new(3), DSA\_print(3), DSA\_security\_bits(3), DSA\_sign(3), DSA\_size(3)

## HISTORY

**DSA\_get0\_pqg**(), **DSA\_set0\_pqg**(), **DSA\_get0\_key**(), **DSA\_set0\_key**(), **DSA\_clear\_flags**(), **DSA\_test\_flags**(), **DSA\_set\_flags**(), and **DSA\_get0\_engine**() first appeared in OpenSSL 1.1.0 and have been available since OpenBSD 6.3.

**DSA\_get0\_p**(), **DSA\_get0\_q**(), **DSA\_get0\_g**(), **DSA\_get0\_pub\_key**(), and **DSA\_get0\_priv\_key**() first appeared in OpenSSL 1.1.1 and have been available since OpenBSD 7.1.
