1ECDSA_SIGN(3ossl)                   OpenSSL                  ECDSA_SIGN(3ossl)
2
3
4

NAME

6       ECDSA_size, ECDSA_sign, ECDSA_do_sign, ECDSA_verify, ECDSA_do_verify,
7       ECDSA_sign_setup, ECDSA_sign_ex, ECDSA_do_sign_ex - deprecated
8       low-level elliptic curve digital signature algorithm (ECDSA) functions
9

SYNOPSIS

11        #include <openssl/ecdsa.h>
12
13       The following functions have been deprecated since OpenSSL 3.0, and can
14       be hidden entirely by defining OPENSSL_API_COMPAT with a suitable
15       version value, see openssl_user_macros(7):
16
17        int ECDSA_size(const EC_KEY *eckey);
18
19        int ECDSA_sign(int type, const unsigned char *dgst, int dgstlen,
20                       unsigned char *sig, unsigned int *siglen, EC_KEY *eckey);
21        ECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst, int dgst_len,
22                                 EC_KEY *eckey);
23
24        int ECDSA_verify(int type, const unsigned char *dgst, int dgstlen,
25                         const unsigned char *sig, int siglen, EC_KEY *eckey);
26        int ECDSA_do_verify(const unsigned char *dgst, int dgst_len,
27                            const ECDSA_SIG *sig, EC_KEY* eckey);
28
29        ECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, int dgstlen,
30                                    const BIGNUM *kinv, const BIGNUM *rp,
31                                    EC_KEY *eckey);
32        int ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinv, BIGNUM **rp);
33        int ECDSA_sign_ex(int type, const unsigned char *dgst, int dgstlen,
34                          unsigned char *sig, unsigned int *siglen,
35                          const BIGNUM *kinv, const BIGNUM *rp, EC_KEY *eckey);
36

DESCRIPTION

38       See ECDSA_SIG_new(3) for a description of the ECDSA_SIG object.
39
40       See i2d_ECDSA_SIG(3) and d2i_ECDSA_SIG(3) for information about
41       encoding and decoding ECDSA signatures to/from DER.
42
43       All of the functions described below are deprecated. Applications
44       should use the higher level EVP interface such as EVP_DigestSignInit(3)
45       or EVP_DigestVerifyInit(3) instead.
46
47       ECDSA_size() returns the maximum length of a DER encoded ECDSA
48       signature created with the private EC key eckey. To obtain the actual
49       signature size use EVP_PKEY_sign(3) with a NULL sig parameter.
50
51       ECDSA_sign() computes a digital signature of the dgstlen bytes hash
52       value dgst using the private EC key eckey. The DER encoded signatures
53       is stored in sig and its length is returned in sig_len. Note: sig must
54       point to ECDSA_size(eckey) bytes of memory. The parameter type is
55       currently ignored. ECDSA_sign() is wrapper function for ECDSA_sign_ex()
56       with kinv and rp set to NULL.
57
58       ECDSA_do_sign() is similar to ECDSA_sign() except the signature is
59       returned as a newly allocated ECDSA_SIG structure (or NULL on error).
60       ECDSA_do_sign() is a wrapper function for ECDSA_do_sign_ex() with kinv
61       and rp set to NULL.
62
63       ECDSA_verify() verifies that the signature in sig of size siglen is a
64       valid ECDSA signature of the hash value dgst of size dgstlen using the
65       public key eckey.  The parameter type is ignored.
66
67       ECDSA_do_verify() is similar to ECDSA_verify() except the signature is
68       presented in the form of a pointer to an ECDSA_SIG structure.
69
70       The remaining functions utilise the internal kinv and r values used
71       during signature computation. Most applications will never need to call
72       these and some external ECDSA ENGINE implementations may not support
73       them at all if either kinv or r is not NULL.
74
75       ECDSA_sign_setup() may be used to precompute parts of the signing
76       operation.  eckey is the private EC key and ctx is a pointer to BN_CTX
77       structure (or NULL). The precomputed values or returned in kinv and rp
78       and can be used in a later call to ECDSA_sign_ex() or
79       ECDSA_do_sign_ex().
80
81       ECDSA_sign_ex() computes a digital signature of the dgstlen bytes hash
82       value dgst using the private EC key eckey and the optional pre-computed
83       values kinv and rp. The DER encoded signature is stored in sig and its
84       length is returned in sig_len. Note: sig must point to
85       ECDSA_size(eckey) bytes of memory. The parameter type is ignored.
86
87       ECDSA_do_sign_ex() is similar to ECDSA_sign_ex() except the signature
88       is returned as a newly allocated ECDSA_SIG structure (or NULL on
89       error).
90

RETURN VALUES

92       ECDSA_size() returns the maximum length signature or 0 on error.
93
94       ECDSA_sign(), ECDSA_sign_ex() and ECDSA_sign_setup() return 1 if
95       successful or 0 on error.
96
97       ECDSA_do_sign() and ECDSA_do_sign_ex() return a pointer to an allocated
98       ECDSA_SIG structure or NULL on error.
99
100       ECDSA_verify() and ECDSA_do_verify() return 1 for a valid signature, 0
101       for an invalid signature and -1 on error.  The error codes can be
102       obtained by ERR_get_error(3).
103

EXAMPLES

105       Creating an ECDSA signature of a given SHA-256 hash value using the
106       named curve prime256v1 (aka P-256).  This example uses deprecated
107       functionality. See "DESCRIPTION".
108
109       First step: create an EC_KEY object (note: this part is not ECDSA
110       specific)
111
112        int ret;
113        ECDSA_SIG *sig;
114        EC_KEY *eckey;
115
116        eckey = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
117        if (eckey == NULL)
118            /* error */
119        if (EC_KEY_generate_key(eckey) == 0)
120            /* error */
121
122       Second step: compute the ECDSA signature of a SHA-256 hash value using
123       ECDSA_do_sign():
124
125        sig = ECDSA_do_sign(digest, 32, eckey);
126        if (sig == NULL)
127            /* error */
128
129       or using ECDSA_sign():
130
131        unsigned char *buffer, *pp;
132        int buf_len;
133
134        buf_len = ECDSA_size(eckey);
135        buffer = OPENSSL_malloc(buf_len);
136        pp = buffer;
137        if (ECDSA_sign(0, dgst, dgstlen, pp, &buf_len, eckey) == 0)
138            /* error */
139
140       Third step: verify the created ECDSA signature using ECDSA_do_verify():
141
142        ret = ECDSA_do_verify(digest, 32, sig, eckey);
143
144       or using ECDSA_verify():
145
146        ret = ECDSA_verify(0, digest, 32, buffer, buf_len, eckey);
147
148       and finally evaluate the return value:
149
150        if (ret == 1)
151            /* signature ok */
152        else if (ret == 0)
153            /* incorrect signature */
154        else
155            /* error */
156

CONFORMING TO

158       ANSI X9.62, US Federal Information Processing Standard FIPS186-2
159       (Digital Signature Standard, DSS)
160

SEE ALSO

162       EC_KEY_new(3), EVP_DigestSignInit(3), EVP_DigestVerifyInit(3),
163       EVP_PKEY_sign(3) i2d_ECDSA_SIG(3), d2i_ECDSA_SIG(3)
164

HISTORY

166       All functionality described here was deprecated in OpenSSL 3.0.
167
169       Copyright 2004-2022 The OpenSSL Project Authors. All Rights Reserved.
170
171       Licensed under the Apache License 2.0 (the "License").  You may not use
172       this file except in compliance with the License.  You can obtain a copy
173       in the file LICENSE in the source distribution or at
174       <https://www.openssl.org/source/license.html>.
175
176
177
1783.0.9                             2023-07-27                 ECDSA_SIGN(3ossl)
Impressum