DSA_DO_SIGN(3)

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

πŸ’œ DSA_do_sign β€” raw DSA signature operations πŸ’œ

okay so this is DSA_DO_SIGN(3), a page from the Library Functions Manual β€” it lives in libcrypto, bestie, and it's all about the ✨raw✨ DSA signature moves. no wrapper, no fluff, just you and the math. πŸŽ€


🌸 SYNOPSIS 🌸

first things first, you gotta pull in the library:

library β€œlibcrypto” #include <openssl/dsa.h>

then the two functions, iconic duo behavior:

DSA_SIG *
DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa);

int
DSA_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig,
    DSA *dsa);

πŸ¦‹ DESCRIPTION πŸ¦‹

πŸ’… DSA_do_sign()

so DSA_do_sign() computes a digital signature on a message digest. the digest is dgst, and it's dlen bytes long, and it signs using the private key dsa. then it hands you back the signature in a newly allocated DSA_SIG structure β€” brand new, freshly malloc'd, main character energy. πŸ‘‘

and listen β€” if signature generation is time-critical for you (like, clock is ticking, deadline is looming 😭), you can use DSA_sign_setup(3) to precompute part of the signing operation ahead of time. lowkey a lifesaver.

🧚 DSA_do_verify()

DSA_do_verify() does the vibe check: it verifies that the signature sig actually matches a given message digest dgst of size dgst_len. and dsa here is the signer's public key β€” not the private one, bestie, the public one. 🫢


⭐ RETURN VALUES ⭐

  • DSA_do_sign() β€” returns the signature, or NULL on error. πŸ’€
  • DSA_do_verify() β€” returns 1 for a valid signature βœ…, 0 for an incorrect signature ❌, and -1 on error 😭.

and if you're sitting there like "okay but why did it error" β€” the error codes can be obtained by ERR_get_error(3). iykyk. πŸ”₯


🌈 SEE ALSO 🌈

go read these next, fr fr:


πŸ‘‘ HISTORY πŸ‘‘

DSA_do_sign() and DSA_do_verify() first appeared in OpenSSL 0.9.3 and have been available since OpenBSD 2.6. literal legends. ✨


πŸ“ real talk: this is raw DSA signature work β€” know your key material and check those return values, okay? no cap.

mwah πŸ’‹ that's the whole page β€” this Debian build is dated June 8, 2025, sourced from the Debian edition of the manual, and it's filed under DSA_DO_SIGN(3). slay, go sign something. πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from