ECDSA_SIGN(3ossl)
π ECDSA_size, ECDSA_sign, ECDSA_do_sign, ECDSA_verify, ECDSA_do_verify, ECDSA_sign_setup, ECDSA_sign_ex, ECDSA_do_sign_ex β the deprecated low-level elliptic curve digital signature algorithm (ECDSA) girlies π
okay bestie, so this is the OpenSSL manpage for the low-level ECDSA functions, and I need you to know upfront: every single one of these is deprecated. like, they're the vintage collection. still iconic, still in the docs, but we do not build new stuff on them. periodt.
β¨ 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>
π¨ bestie listen. The following functions have been deprecated since OpenSSL 3.0, and can be hidden entirely by definingOPENSSL_API_COMPATwith a suitable version value, seeopenssl_user_macros(7). yes, they can just... vanish on you. no cap.
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 πΈ
Want the tea on the ECDSA_SIG object itself? Go read ECDSA_SIG_new(3), it's all there. π
Encoding and decoding ECDSA signatures to/from DER? That's i2d_ECDSA_SIG(3) and d2i_ECDSA_SIG(3). π
All of the functions described below are deprecated. Like, every one. Applications should use the higher level EVP interface such as EVP_DigestSignInit(3) or EVP_DigestVerifyInit(3) instead. that's the glow-up, bestie. β¨
ECDSA_size()β returns the maximum length of a DER encoded ECDSA signature created with the private EC keyeckey. Wanna know the actual signature size instead of the ceiling? UseEVP_PKEY_sign(3)with aNULLsigparameter. πECDSA_sign()β computes a digital signature of thedgstlenbytes hash valuedgstusing the private EC keyeckey. The DER encoded signature gets stored insigand its length comes back insiglen. β οΈ Note:sigmust point toECDSA_size(eckey)bytes of memory. The parametertypeis currently ignored (literally just vibing there, doing nothing).ECDSA_sign()is a wrapper function forECDSA_sign_ex()withkinvandrpset toNULL.ECDSA_do_sign()β similar toECDSA_sign()except the signature is returned as a newly allocatedECDSA_SIGstructure (orNULLon error). It's 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. vibe check passed or not, we'll see. πECDSA_do_verify()β similar toECDSA_verify()except the signature is presented in the form of a pointer to anECDSA_SIGstructure.
The remaining functions utilise the internal kinv and r values used during signature computation. Most applications will never need to call these, and some external ECDSA ENGINE implementations may not support them at all if either kinv or r is not NULL. so like... proceed with caution, bestie. π
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, essentially. π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.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).
π«Ά reminder that1/0/-1are three different things here, bestie. don't conflate a bad signature with a broken call, iykyk.
π§ 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". (yes we're using the vintage stuff on purpose, it's a museum tour π)
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). she's certified, she's compliant, she's got receipts. π
π 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. like, the whole page. every function. rest in peace to the low-level era. π
π 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 ECDSA_SIGN(3ossl) from OpenSSL 3.5.9, dated 2026-09-29 β so go forth, use the EVP interface instead, and stay iconic. mwah. π
β¨π
π¦ where this page comes from
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms