DSA_GET0_PQG(3SSL)
π DSA_GET0_PQG β the 3SSL glow-up π
okay so bestie, this is a page from the OpenSSL manual set (that's the <pink>3SSL</pink> bit, iykyk) and it's all about the getting-and-setting of data inside a DSA object. yes, that DSA. pull up a chair, we're doing this together π«Ά
β¨ 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 β literally the routines for getting and setting data in a DSA object. that's the whole gig π
πΈ SYNOPSIS πΈ
#include <openssl/dsa.h>
β οΈ heads up bestie: the following functions have been deprecated since OpenSSL 3.0, and can be hidden entirely by definingOPENSSL_API_COMPATwith a suitable version value, seeopenssl_user_macros(7):
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, the vibe check: all of the functions described on this page are deprecated π applications should instead use EVP_PKEY_get_bn_param(3). yes, the whole squad. it's giving "we're moving on" energy, and honestly? respect.
so. 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). main character data structure, no cap π₯
π getting the params
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're set to pointers to their respective values. and here's the important bit, bestie: these point directly to the internal representations of the values, and therefore should not be freed directly. like, do not touch. hands off. π
π§ setting the params
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. the object owns them now. it's their parent. periodt π
π 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. same rules, different function, we stay consistent β¨
π 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. say it with me: the object owns it now π«Ά
β grab 'em one at a time
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. solo missions. individual serve. π
π© the flags situation
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 whole flag lifecycle, iconic behavior honestly π
βοΈ 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. lowkey mysterious. we love a maybe-NULL moment π
π 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().
bestie please internalize this one: you cannot just hand the borrowed pointer back. make a copy with BN_dup() first. it's the difference between "borrowing your hoodie" and "keeping your hoodie" π§₯
π RETURN VALUES π
DSA_set0_pqg()andDSA_set0_key()β return1on success or0on failure. that's it. that's the 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 in there twice β the original said it twice and I'm not about to edit the source material, that's not my job π
)
πΈ HISTORY πΈ
the functions described here were added in OpenSSL 1.1.0 and deprecated in OpenSSL 3.0. a whole glow-up-to-glow-down arc, 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 page, bestie! π¦ this little beauty is from OpenSSL 3.5.7, dated 2026-06-09 β go forth, read your params, duplicate your BIGNUMs, and never free an internal pointer. mwah ππ
π¦ where this page comes from
- debian trixie: libssl-doc 3.5.7-1~deb13u2 Β· Apache-2.0
- debian trixie: libssl-doc 3.5.7-1~deb13u3 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms