DSA_GET0_PQG(3ossl)
π DSA_GET0_PQG β the OpenSSL manual, but make it make sense
okay bestie, this is DSA_GET0_PQG(3ossl), a page from the OpenSSL manual, and it's all about peeking at and poking at the inside of a DSA object. yes it's deprecated. no we're not crying about it. (we are a little.) π«Ά
β¨ NAME β¨
DSA_get0_pqg, DSA_set0_pqg, DSA_get0_key, DSA_set0_key, DSA_get0_p, DSA_get0_q, DSA_get0_g, DSA_get0_pub_key, DSA_get0_priv_key, DSA_clear_flags, DSA_test_flags, DSA_set_flags, DSA_get0_engine β routines for getting and setting data in a DSA object. that's the whole vibe. π
πΈ SYNOPSIS πΈ
#include <openssl/dsa.h>
so, real talk: the following functions have been deprecated since OpenSSL 3.0, and you can hide them entirely by defining OPENSSL_API_COMPAT with a suitable version value β see openssl_user_macros(7). slay, but also, they're on their way out. π
void DSA_get0_pqg(const DSA *d,
const BIGNUM **p, const BIGNUM **q, const BIGNUM **g);
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);
int DSA_set0_key(DSA *d, BIGNUM *pub_key, BIGNUM *priv_key);
const BIGNUM *DSA_get0_p(const DSA *d);
const BIGNUM *DSA_get0_q(const DSA *d);
const BIGNUM *DSA_get0_g(const DSA *d);
const BIGNUM *DSA_get0_pub_key(const DSA *d);
const BIGNUM *DSA_get0_priv_key(const DSA *d);
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 π
first things first, and I need you to hear me on this: all of the functions described on this page are deprecated. applications should instead use EVP_PKEY_get_bn_param(3). that's the glow-up. periodt.
a DSA object contains the parameters p, q and g. it also contains a public key (pub_key) and (optionally) a private key (priv_key). iconic little container, ngl. π§
getting the parameters
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 will be set to NULL. otherwise they are set to pointers to their respective values. and here's the thing β these point directly to the internal representations of the values and therefore should not be freed directly. do not free them. do not touch them. just look. π
setting the parameters
the p, q and g values can be set by calling DSA_set0_pqg() and passing the new values for p, q and g as parameters to the function. calling this function transfers the memory management of the values to the DSA object, and therefore the values that have been passed in should not be freed directly after this function has been called. it's giving "handed over the aux, it's not yours anymore." π§
getting the keys
to get the public and private key values use the DSA_get0_key() function. a pointer to the public key will be stored in *pub_key, and a pointer to the private key will be stored in *priv_key. either may be NULL if they have not been set yet, although if the private key has been set then the public key must be. the values point to the internal representation of the public key and private key values. this memory should not be freed directly. again. don't. π
setting the keys
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. as for DSA_set0_pqg() this function transfers the memory management of the key values to the DSA object, and therefore they should not be freed directly after this function has been called. same rules, same energy. π
the singles
any of the values p, q, g, priv_key, and pub_key can also be retrieved separately by the corresponding function DSA_get0_p(), DSA_get0_q(), DSA_get0_g(), DSA_get0_priv_key(), and DSA_get0_pub_key(), respectively. one at a time, no group chat needed. β¨
flags, flags, flags
DSA_set_flags() sets the flags in the flags parameter on the DSA object. multiple flags can be passed in one go (bitwise ORed together). any flags that are already set are left set. DSA_test_flags() tests to see whether the flags passed in the flags parameter are currently set in the DSA object. multiple flags can be tested in one go. all flags that are currently set are returned, or zero if none of the flags are set. DSA_clear_flags() clears the specified flags within the DSA object. set, test, clear. the holy trinity. π₯
the engine
DSA_get0_engine() returns a handle to the ENGINE that has been set for this DSA object, or NULL if no such ENGINE has been set. no engine, no problem, just NULL. π¦
π NOTES π
values retrieved with DSA_get0_key() are owned by the DSA object used in the call and may therefore not be passed to DSA_set0_key(). if needed, duplicate the received value using BN_dup() and pass the duplicate. the same applies to DSA_get0_pqg() and DSA_set0_pqg(). so like, don't regift the same object back. BN_dup() it first. π
π RETURN VALUES π
DSA_set0_pqg()andDSA_set0_key()return1on success or0on failure. classic binary. βDSA_test_flags()returns the current state of the flags in theDSAobject.DSA_get0_engine()returns theENGINEset for theDSAobject orNULLif noENGINEhas been set.
π SEE ALSO π
EVP_PKEY_get_bn_param(3), DSA_new(3), DSA_new(3), DSA_generate_parameters(3), DSA_generate_key(3), DSA_dup_DH(3), DSA_do_sign(3), DSA_set_method(3), DSA_SIG_new(3), DSA_sign(3), DSA_size(3), DSA_meth_new(3)
(yes, DSA_new(3) is listed twice. no, I'm not fixing it. the manpage said it, so it stays. π)
π°οΈ HISTORY π°οΈ
the functions described here were added in OpenSSL 1.1.0 and deprecated in OpenSSL 3.0. they had a good run. a main character run, honestly. π
Β©οΈ COPYRIGHT Β©οΈ
Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
and that's the whole page, bestie. this was OpenSSL 3.5.9, dated 2026-09-29, and the page itself is DSA_GET0_PQG(3ossl). go forth, get your p, q and g, and remember: do not free what you did not allocate. mwah. π
π¦ where this page comes from
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms