DSA_GET0_PQG(3)

πŸ“¦ version 4.4.0, in alpine 3.24, arch rolling

✨ DSA_GET0_PQG β€” bestie edition ✨

okay so this is from the Library Functions Manual, and we're diving into libcrypto's DSA functions. buckle up, bestie, we're getting into some crypto internals πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

library "libcrypto"
#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 πŸ’–

so a DSA object? it's literally holding the parameters p, q, and g β€” those are the vibes. it also contains a public key pub_key and an optional private key priv_key. main character energy fr fr 🫢

🌸 getting the parameters

you can grab p, q, and g by calling DSA_get0_pqg(). if they haven't been set yet? then *p, *q, and *g get set to NULL. no cap. otherwise, they point to the internal representations of those values β€” and do not free them, okay? they're not yours to touch like that πŸ™ˆ

🌸 setting the parameters

wanna set p, q, and g? that's DSA_set0_pqg()'s moment. calling this function transfers memory management of the values to d β€” so the caller should NOT free them. it's giving "handoff" energy ✨

🌸 getting the keys

DSA_get0_key() stores pointers to the internal representations of the public key in *pub_key and the private key in *priv_key. either can be NULL if not set yet. but real talk: if the private key has been set, then the public key must be set too. iykyk πŸ’…

🌸 setting the keys

you can set the public and private key values with DSA_set0_key(). the public key must be non-NULL the first time you call this on a given DSA object. the private key can be NULL. on subsequent calls, either may be NULL β€” which means that DSA field is left untouched, no questions asked. and just like with DSA_set0_pqg(), DSA_set0_key() transfers memory management of the key values to d β€” so don't free them yourself, bestie 😭

⚠️ important warning: 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 you need to do that, duplicate them with BN_dup(3) and pass the duplicates. periodt.

🌸 getting individual values

any of p, q, g, pub_key, and priv_key can also be retrieved separately by their corresponding functions: DSA_get0_p(), DSA_get0_q(), DSA_get0_g(), DSA_get0_pub_key(), and DSA_get0_priv_key(). the pointers are owned by the DSA object, so same rules apply πŸ¦‹

🌸 flags, flags, flags

  • 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 (no unsetting here, bestie)

for all three functions, you can pass multiple flags in one call β€” just OR them together bitwise. slay πŸ”₯


πŸ‘‘ 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. simple as that πŸ’β€β™€οΈ

DSA_set0_pqg() and DSA_set0_key() return 1 on success or 0 on failure. iconic binary moment ✨

DSA_test_flags() returns those of the given flags currently set in d, or 0 if none of the given flags are set. no in-between, bestie.

DSA_get0_engine() always returns NULL. that's it. that's the whole function. πŸ’€


🌈 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. history was made, honestly 🌟

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. the glow-up is real πŸ’–


and that's the whole page, bestie! this was brought to you by Debian, dated June 13, 2025 β€” stay curious, stay slay, and don't forget to BN_dup(3) when you need to πŸŽ€πŸ’œ

πŸ“¦ where this page comes from