ECDSA_SIGN(3SSL)
π ECDSA_SIGN β the deprecated ECDSA girlies π
okay so bestie, we're in ECDSA_SIGN(3SSL) territory, and I need you to sit down for this one because literally every function on this page is deprecated and I'm not exaggerating. It's the low-level elliptic curve digital signature algorithm (ECDSA) crew: ECDSA_size, ECDSA_sign, ECDSA_do_sign, ECDSA_verify, ECDSA_do_verify, ECDSA_sign_setup, ECDSA_sign_ex, ECDSA_do_sign_ex. They still work, they're justβ¦ vintage. Like a flip phone. Cute, iconic, but babe, we have EVP now. π«Ά
β¨ NAME β¨
ECDSA_size, ECDSA_sign, ECDSA_do_sign, ECDSA_verify, ECDSA_do_verify, ECDSA_sign_setup, ECDSA_sign_ex, ECDSA_do_sign_ex β deprecated low-level elliptic curve digital signature algorithm (ECDSA) functions π
πΈ SYNOPSIS πΈ
#include <openssl/ecdsa.h>
The following functions have been deprecated since OpenSSL 3.0, and can be hidden entirely by defining OPENSSL_API_COMPAT with a suitable version value, see openssl_user_macros(7):
int ECDSA_size(const EC_KEY *eckey);
int ECDSA_sign(int type, const unsigned char *dgst, int dgstlen,
unsigned char *sig, unsigned int *siglen, EC_KEY *eckey);
ECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst, int dgst_len,
EC_KEY *eckey);
int ECDSA_verify(int type, const unsigned char *dgst, int dgstlen,
const unsigned char *sig, int siglen, EC_KEY *eckey);
int ECDSA_do_verify(const unsigned char *dgst, int dgst_len,
const ECDSA_SIG *sig, EC_KEY* eckey);
ECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, int dgstlen,
const BIGNUM *kinv, const BIGNUM *rp,
EC_KEY *eckey);
int ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinv, BIGNUM **rp);
int ECDSA_sign_ex(int type, const unsigned char *dgst, int dgstlen,
unsigned char *sig, unsigned int *siglen,
const BIGNUM *kinv, const BIGNUM *rp, EC_KEY *eckey);
π¦ DESCRIPTION π¦
Wanna know what an ECDSA_SIG object even is? Go read ECDSA_SIG_new(3), she explains herself.
Encoding and decoding ECDSA signatures to/from DER? That's i2d_ECDSA_SIG(3) and d2i_ECDSA_SIG(3), respectively. Slay.
β οΈ Real talk first: ALL of the functions described below are deprecated. Applications should use the higher level EVP interface such asEVP_DigestSignInit(3)orEVP_DigestVerifyInit(3)instead. Periodt. π
ECDSA_size()β returns the maximum length of a DER encoded ECDSA signature created with the private EC keyeckey. And if you want the actual signature size instead of the juicy maximum? UseEVP_PKEY_sign(3)with aNULLsigparameter. iykyk. β¨ECDSA_sign()β computes a digital signature of thedgstlenbytes hash valuedgstusing the private EC keyeckey. The DER encoded signature is stored insigand its length is returned insiglen. Note:sigmust point toECDSA_size(eckey)bytes of memory β like, do not skimp on the buffer, bestie. The parametertypeis currently ignored (she's just there for vibes).ECDSA_sign()is a wrapper function forECDSA_sign_ex()withkinvandrpset toNULL.ECDSA_do_sign()β same energy asECDSA_sign()except the signature is returned as a newly allocatedECDSA_SIGstructure (orNULLon error).ECDSA_do_sign()is a wrapper function forECDSA_do_sign_ex()withkinvandrpset toNULL.ECDSA_verify()β verifies that the signature insigof sizesiglenis a valid ECDSA signature of the hash valuedgstof sizedgstlenusing the public keyeckey. The parametertypeis ignored (again, decorative π ).ECDSA_do_verify()β similar toECDSA_verify()except the signature is presented in the form of a pointer to anECDSA_SIGstructure.- The remaining functions β these utilise the internal
kinvandrvalues used during signature computation. Most applications will never need to call these. And honestly? If you're most applications, you don't. π§ ECDSA_sign_setup()β may be used to precompute parts of the signing operation.eckeyis the private EC key andctxis a pointer toBN_CTXstructure (orNULL). The precomputed values are returned inkinvandrpand can be used in a later call toECDSA_sign_ex()orECDSA_do_sign_ex(). Pre-gaming the math, icon behaviour. πECDSA_sign_ex()β computes a digital signature of thedgstlenbytes hash valuedgstusing the private EC keyeckeyand the optional pre-computed valueskinvandrp. The DER encoded signature is stored insigand its length is returned insiglen. Note:sigmust point toECDSA_size(eckey)bytes of memory. The parametertypeis ignored. (Yes, still. She's committed to the bit.)ECDSA_do_sign_ex()β similar toECDSA_sign_ex()except the signature is returned as a newly allocatedECDSA_SIGstructure (orNULLon error).
π RETURN VALUES π
ECDSA_size()β returns the maximum length signature, or0on error.ECDSA_sign(),ECDSA_sign_ex()andECDSA_sign_setup()β return1if successful or0on error.ECDSA_do_sign()andECDSA_do_sign_ex()β return a pointer to an allocatedECDSA_SIGstructure orNULLon error.ECDSA_verify()andECDSA_do_verify()β return1for a valid signature,0for an invalid signature and-1on error. The error codes can be obtained byERR_get_error(3). So like,0and-1are NOT the same thing, do not conflate them, this is not a drill π
π EXAMPLES π
Creating an ECDSA signature of a given SHA-256 hash value using the named curve prime256v1 (aka P-256). This example uses deprecated functionality. See "DESCRIPTION". (I did warn you. π)
First step: create an EC_KEY object (note: this part is not ECDSA specific)
int ret;
ECDSA_SIG *sig;
EC_KEY *eckey;
eckey = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
if (eckey == NULL)
/* error */
if (EC_KEY_generate_key(eckey) == 0)
/* error */
Second step: compute the ECDSA signature of a SHA-256 hash value using ECDSA_do_sign():
sig = ECDSA_do_sign(digest, 32, eckey);
if (sig == NULL)
/* error */
or using ECDSA_sign():
unsigned char *buffer, *pp;
int buf_len;
buf_len = ECDSA_size(eckey);
buffer = OPENSSL_malloc(buf_len);
pp = buffer;
if (ECDSA_sign(0, dgst, dgstlen, pp, &buf_len, eckey) == 0)
/* error */
Third step: verify the created ECDSA signature using ECDSA_do_verify():
ret = ECDSA_do_verify(digest, 32, sig, eckey);
or using ECDSA_verify():
ret = ECDSA_verify(0, digest, 32, buffer, buf_len, eckey);
and finally evaluate the return value:
if (ret == 1)
/* signature ok */
else if (ret == 0)
/* incorrect signature */
else
/* error */
β CONFORMING TO β
ANSI X9.62, US Federal Information Processing Standard FIPS186-2 (Digital Signature Standard, DSS)
π SEE ALSO π
EC_KEY_new(3), EVP_DigestSignInit(3), EVP_DigestVerifyInit(3), EVP_PKEY_sign(3) i2d_ECDSA_SIG(3), d2i_ECDSA_SIG(3)
π HISTORY π
All functionality described here was deprecated in OpenSSL 3.0. (not me being sad about it π₯²)
π COPYRIGHT π
Copyright 2004-2022 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, from the ECDSA_SIGN(3SSL) manual. Go forth, use EVP, and drink some water. mwah π«ΆπΈ
π¦ where this page comes from
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms