84
/** ECDSA_SIG *ECDSA_SIG_new(void)
85
* allocates and initialize a ECDSA_SIG structure
86
* \return pointer to a ECDSA_SIG structure or NULL if an error occurred
84
/** Allocates and initialize a ECDSA_SIG structure
85
* \return pointer to a ECDSA_SIG structure or NULL if an error occurred
88
87
ECDSA_SIG *ECDSA_SIG_new(void);
91
* frees a ECDSA_SIG structure
92
* \param a pointer to the ECDSA_SIG structure
94
void ECDSA_SIG_free(ECDSA_SIG *a);
97
* DER encode content of ECDSA_SIG object (note: this function modifies *pp
98
* (*pp += length of the DER encoded signature)).
99
* \param a pointer to the ECDSA_SIG object
100
* \param pp pointer to a unsigned char pointer for the output or NULL
101
* \return the length of the DER encoded ECDSA_SIG object or 0
103
int i2d_ECDSA_SIG(const ECDSA_SIG *a, unsigned char **pp);
106
* decodes a DER encoded ECDSA signature (note: this function changes *pp
108
* \param v pointer to ECDSA_SIG pointer (may be NULL)
109
* \param pp buffer with the DER encoded signature
110
* \param len bufferlength
111
* \return pointer to the decoded ECDSA_SIG structure (or NULL)
113
ECDSA_SIG *d2i_ECDSA_SIG(ECDSA_SIG **v, const unsigned char **pp, long len);
116
* computes the ECDSA signature of the given hash value using
117
* the supplied private key and returns the created signature.
118
* \param dgst pointer to the hash value
119
* \param dgst_len length of the hash value
120
* \param eckey pointer to the EC_KEY object containing a private EC key
121
* \return pointer to a ECDSA_SIG structure or NULL
89
/** frees a ECDSA_SIG structure
90
* \param sig pointer to the ECDSA_SIG structure
92
void ECDSA_SIG_free(ECDSA_SIG *sig);
94
/** DER encode content of ECDSA_SIG object (note: this function modifies *pp
95
* (*pp += length of the DER encoded signature)).
96
* \param sig pointer to the ECDSA_SIG object
97
* \param pp pointer to a unsigned char pointer for the output or NULL
98
* \return the length of the DER encoded ECDSA_SIG object or 0
100
int i2d_ECDSA_SIG(const ECDSA_SIG *sig, unsigned char **pp);
102
/** Decodes a DER encoded ECDSA signature (note: this function changes *pp
104
* \param sig pointer to ECDSA_SIG pointer (may be NULL)
105
* \param pp memory buffer with the DER encoded signature
106
* \param len length of the buffer
107
* \return pointer to the decoded ECDSA_SIG structure (or NULL)
109
ECDSA_SIG *d2i_ECDSA_SIG(ECDSA_SIG **sig, const unsigned char **pp, long len);
111
/** Computes the ECDSA signature of the given hash value using
112
* the supplied private key and returns the created signature.
113
* \param dgst pointer to the hash value
114
* \param dgst_len length of the hash value
115
* \param eckey EC_KEY object containing a private EC key
116
* \return pointer to a ECDSA_SIG structure or NULL if an error occurred
123
118
ECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst,int dgst_len,EC_KEY *eckey);
126
* computes ECDSA signature of a given hash value using the supplied
127
* private key (note: sig must point to ECDSA_size(eckey) bytes of memory).
128
* \param dgst pointer to the hash value to sign
129
* \param dgstlen length of the hash value
130
* \param kinv optional pointer to a pre-computed inverse k
131
* \param rp optional pointer to the pre-computed rp value (see
133
* \param eckey pointer to the EC_KEY object containing a private EC key
134
* \return pointer to a ECDSA_SIG structure or NULL
120
/** Computes ECDSA signature of a given hash value using the supplied
121
* private key (note: sig must point to ECDSA_size(eckey) bytes of memory).
122
* \param dgst pointer to the hash value to sign
123
* \param dgstlen length of the hash value
124
* \param kinv BIGNUM with a pre-computed inverse k (optional)
125
* \param rp BIGNUM with a pre-computed rp value (optioanl),
126
* see ECDSA_sign_setup
127
* \param eckey EC_KEY object containing a private EC key
128
* \return pointer to a ECDSA_SIG structure or NULL if an error occurred
136
130
ECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, int dgstlen,
137
131
const BIGNUM *kinv, const BIGNUM *rp, EC_KEY *eckey);
140
* verifies that the supplied signature is a valid ECDSA
141
* signature of the supplied hash value using the supplied public key.
142
* \param dgst pointer to the hash value
143
* \param dgst_len length of the hash value
144
* \param sig pointer to the ECDSA_SIG structure
145
* \param eckey pointer to the EC_KEY object containing a public EC key
146
* \return 1 if the signature is valid, 0 if the signature is invalid and -1 on error
133
/** Verifies that the supplied signature is a valid ECDSA
134
* signature of the supplied hash value using the supplied public key.
135
* \param dgst pointer to the hash value
136
* \param dgst_len length of the hash value
137
* \param sig ECDSA_SIG structure
138
* \param eckey EC_KEY object containing a public EC key
139
* \return 1 if the signature is valid, 0 if the signature is invalid
148
142
int ECDSA_do_verify(const unsigned char *dgst, int dgst_len,
149
143
const ECDSA_SIG *sig, EC_KEY* eckey);
151
145
const ECDSA_METHOD *ECDSA_OpenSSL(void);
153
/** ECDSA_set_default_method
154
* sets the default ECDSA method
155
* \param meth the new default ECDSA_METHOD
147
/** Sets the default ECDSA method
148
* \param meth new default ECDSA_METHOD
157
150
void ECDSA_set_default_method(const ECDSA_METHOD *meth);
159
/** ECDSA_get_default_method
160
* returns the default ECDSA method
161
* \return pointer to ECDSA_METHOD structure containing the default method
152
/** Returns the default ECDSA method
153
* \return pointer to ECDSA_METHOD structure containing the default method
163
155
const ECDSA_METHOD *ECDSA_get_default_method(void);
166
* sets method to be used for the ECDSA operations
167
* \param eckey pointer to the EC_KEY object
168
* \param meth pointer to the new method
169
* \return 1 on success and 0 otherwise
157
/** Sets method to be used for the ECDSA operations
158
* \param eckey EC_KEY object
159
* \param meth new method
160
* \return 1 on success and 0 otherwise
171
162
int ECDSA_set_method(EC_KEY *eckey, const ECDSA_METHOD *meth);
174
* returns the maximum length of the DER encoded signature
175
* \param eckey pointer to a EC_KEY object
176
* \return numbers of bytes required for the DER encoded signature
164
/** Returns the maximum length of the DER encoded signature
165
* \param eckey EC_KEY object
166
* \return numbers of bytes required for the DER encoded signature
178
168
int ECDSA_size(const EC_KEY *eckey);
181
* precompute parts of the signing operation.
182
* \param eckey pointer to the EC_KEY object containing a private EC key
183
* \param ctx pointer to a BN_CTX object (may be NULL)
184
* \param kinv pointer to a BIGNUM pointer for the inverse of k
185
* \param rp pointer to a BIGNUM pointer for x coordinate of k * generator
186
* \return 1 on success and 0 otherwise
170
/** Precompute parts of the signing operation
171
* \param eckey EC_KEY object containing a private EC key
172
* \param ctx BN_CTX object (optional)
173
* \param kinv BIGNUM pointer for the inverse of k
174
* \param rp BIGNUM pointer for x coordinate of k * generator
175
* \return 1 on success and 0 otherwise
188
177
int ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinv,
192
* computes ECDSA signature of a given hash value using the supplied
193
* private key (note: sig must point to ECDSA_size(eckey) bytes of memory).
194
* \param type this parameter is ignored
195
* \param dgst pointer to the hash value to sign
196
* \param dgstlen length of the hash value
197
* \param sig buffer to hold the DER encoded signature
198
* \param siglen pointer to the length of the returned signature
199
* \param eckey pointer to the EC_KEY object containing a private EC key
200
* \return 1 on success and 0 otherwise
180
/** Computes ECDSA signature of a given hash value using the supplied
181
* private key (note: sig must point to ECDSA_size(eckey) bytes of memory).
182
* \param type this parameter is ignored
183
* \param dgst pointer to the hash value to sign
184
* \param dgstlen length of the hash value
185
* \param sig memory for the DER encoded created signature
186
* \param siglen pointer to the length of the returned signature
187
* \param eckey EC_KEY object containing a private EC key
188
* \return 1 on success and 0 otherwise
202
190
int ECDSA_sign(int type, const unsigned char *dgst, int dgstlen,
203
191
unsigned char *sig, unsigned int *siglen, EC_KEY *eckey);
207
* computes ECDSA signature of a given hash value using the supplied
208
* private key (note: sig must point to ECDSA_size(eckey) bytes of memory).
209
* \param type this parameter is ignored
210
* \param dgst pointer to the hash value to sign
211
* \param dgstlen length of the hash value
212
* \param sig buffer to hold the DER encoded signature
213
* \param siglen pointer to the length of the returned signature
214
* \param kinv optional pointer to a pre-computed inverse k
215
* \param rp optional pointer to the pre-computed rp value (see
217
* \param eckey pointer to the EC_KEY object containing a private EC key
218
* \return 1 on success and 0 otherwise
194
/** Computes ECDSA signature of a given hash value using the supplied
195
* private key (note: sig must point to ECDSA_size(eckey) bytes of memory).
196
* \param type this parameter is ignored
197
* \param dgst pointer to the hash value to sign
198
* \param dgstlen length of the hash value
199
* \param sig buffer to hold the DER encoded signature
200
* \param siglen pointer to the length of the returned signature
201
* \param kinv BIGNUM with a pre-computed inverse k (optional)
202
* \param rp BIGNUM with a pre-computed rp value (optioanl),
203
* see ECDSA_sign_setup
204
* \param eckey EC_KEY object containing a private EC key
205
* \return 1 on success and 0 otherwise
220
207
int ECDSA_sign_ex(int type, const unsigned char *dgst, int dgstlen,
221
208
unsigned char *sig, unsigned int *siglen, const BIGNUM *kinv,
222
209
const BIGNUM *rp, EC_KEY *eckey);
225
* verifies that the given signature is valid ECDSA signature
226
* of the supplied hash value using the specified public key.
227
* \param type this parameter is ignored
228
* \param dgst pointer to the hash value
229
* \param dgstlen length of the hash value
230
* \param sig pointer to the DER encoded signature
231
* \param siglen length of the DER encoded signature
232
* \param eckey pointer to the EC_KEY object containing a public EC key
233
* \return 1 if the signature is valid, 0 if the signature is invalid and -1 on error
211
/** Verifies that the given signature is valid ECDSA signature
212
* of the supplied hash value using the specified public key.
213
* \param type this parameter is ignored
214
* \param dgst pointer to the hash value
215
* \param dgstlen length of the hash value
216
* \param sig pointer to the DER encoded signature
217
* \param siglen length of the DER encoded signature
218
* \param eckey EC_KEY object containing a public EC key
219
* \return 1 if the signature is valid, 0 if the signature is invalid
235
222
int ECDSA_verify(int type, const unsigned char *dgst, int dgstlen,
236
223
const unsigned char *sig, int siglen, EC_KEY *eckey);