DSA_GET0_PQG(3)
β¨ 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 withDSA_get0_pqg()andDSA_get0_key()are owned by the DSA object and may therefore not be passed toDSA_set0_pqg()orDSA_set0_key(). if you need to do that, duplicate them withBN_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 indDSA_test_flags()β tests the flags indDSA_set_flags()β sets the flags ind; 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
- alpine 3.24: libressl-doc 4.3.1-r0 Β· custom
- arch rolling: libressl 4.4.0-1 Β· ISC AND custom:OpenSSL
- Copyright (c) 2016 The OpenSSL Project. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms