DSA_SIGN(3SSL)

πŸ’– DSA_SIGN πŸ’–

okay bestie, gather round, because we're talking about DSA_sign, DSA_sign_setup, and DSA_verify β€” the DSA signature girlies from the OpenSSL manual, section 3SSL. yes they're the OGs. yes they're also a little ✨retired✨. let's get into it 🫢


🌸 NAME 🌸

DSA_sign, DSA_sign_setup, DSA_verify β€” DSA signatures, babes πŸ’…


✨ SYNOPSIS ✨

#include <openssl/dsa.h>

sooooo here's the thing. 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 β€” peep openssl_user_macros(7) for the deets πŸ“–

int DSA_sign(int type, const unsigned char *dgst, int len,
             unsigned char *sigret, unsigned int *siglen, DSA *dsa);

int DSA_sign_setup(DSA *dsa, BN_CTX *ctx, BIGNUM **kinvp, BIGNUM **rp);

int DSA_verify(int type, const unsigned char *dgst, int len,
               unsigned char *sigbuf, int siglen, DSA *dsa);

πŸ’œ DESCRIPTION πŸ’œ

okay so first thing first, and I need you to hear me on this: all of the functions described on this page are deprecated. no cap. the way that you should NOT be using these anymore... 😭

applications should instead use EVP_PKEY_sign_init(3), EVP_PKEY_sign(3), EVP_PKEY_verify_init(3) and EVP_PKEY_verify(3). those are the main characters now, periodt πŸ‘‘


πŸŽ€ DSA_sign() πŸŽ€

she computes a digital signature on the len byte message digest dgst using the private key dsa, and places its ASN.1 DER encoding at sigret. the length of the signature goes into *siglen. and listen β€” sigret must point to DSA_size(dsa) bytes of memory. that's not a suggestion, that's the vibe check. don't skimp on the buffer bestie πŸ™ˆ


πŸ’€ DSA_sign_setup() πŸ’€

it's giving legacy. it's giving fossil. DSA_sign_setup() is defined only for backward binary compatibility and should not be used. fr fr.

since OpenSSL 1.1.0 the DSA type is opaque, and the output of DSA_sign_setup() can't be used anyway β€” so calling this function will only cause overhead, and does not affect the actual signature (pre-)computation. so it's just... doing cardio for nothing πŸƒβ™€οΈπŸ’¨ iconic in a tragic way


πŸ¦‹ DSA_verify() πŸ¦‹

she verifies that the signature sigbuf of size siglen matches a given message digest dgst of size len. and dsa here? that's the signer's public key πŸ”‘


🌈 the type parameter 🌈

literally ignored. she said "not my problem, not my business" πŸ’…


🌟 the random generator 🌟

the random generator must be seeded when DSA_sign() (or DSA_sign_setup()) is called. and if the automatic seeding or reseeding of the OpenSSL CSPRNG fails due to external circumstances (check RAND(7) for that whole situation), then the operation will fail. no cap, no workaround, no nothing 😭


πŸ‘‘ RETURN VALUES πŸ‘‘

  • DSA_sign() and DSA_sign_setup() β€” return 1 on success, 0 on error. simple. clean. slay ✨
  • DSA_verify() β€” returns 1 for a valid signature, 0 for an incorrect signature, and -1 on error. three whole moods 🎭

you can grab the error codes with ERR_get_error(3) 🫢


πŸ“œ CONFORMING TO πŸ“œ

  • US Federal Information Processing Standard FIPS186-4 (Digital Signature Standard, DSS)
  • ANSI X9.30

πŸ” SEE ALSO πŸ”


πŸ•°οΈ HISTORY πŸ•°οΈ

all of these functions were deprecated in OpenSSL 3.0. rip to a real one, respectfully πŸͺ¦πŸ’


Copyright 2000-2021 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 4.0.3, dated 2026-09-29, filed under DSA_SIGN(3SSL) β€” go forth and use EVP_PKEY_sign_init(3) instead, mwah, love u, bye πŸ§šπŸ’–πŸŒΈ

πŸ“¦ where this page comes from