summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ecdsa/ecdsa.h
diff options
context:
space:
mode:
authordjm <>2010-10-01 22:54:21 +0000
committerdjm <>2010-10-01 22:54:21 +0000
commit829fd51d4f8dde4a7f3bf54754f3c1d1a502f5e2 (patch)
treee03b9f1bd051e844b971936729e9df549a209130 /src/lib/libcrypto/ecdsa/ecdsa.h
parente6b755d2a53d3cac7a344dfdd6bf7c951cac754c (diff)
downloadopenbsd-829fd51d4f8dde4a7f3bf54754f3c1d1a502f5e2.tar.gz
openbsd-829fd51d4f8dde4a7f3bf54754f3c1d1a502f5e2.tar.bz2
openbsd-829fd51d4f8dde4a7f3bf54754f3c1d1a502f5e2.zip
import OpenSSL-1.0.0a
Diffstat (limited to 'src/lib/libcrypto/ecdsa/ecdsa.h')
-rw-r--r--src/lib/libcrypto/ecdsa/ecdsa.h193
1 files changed, 90 insertions, 103 deletions
diff --git a/src/lib/libcrypto/ecdsa/ecdsa.h b/src/lib/libcrypto/ecdsa/ecdsa.h
index f20c8ee738..e61c539812 100644
--- a/src/lib/libcrypto/ecdsa/ecdsa.h
+++ b/src/lib/libcrypto/ecdsa/ecdsa.h
@@ -4,7 +4,7 @@
4 * \author Written by Nils Larsch for the OpenSSL project 4 * \author Written by Nils Larsch for the OpenSSL project
5 */ 5 */
6/* ==================================================================== 6/* ====================================================================
7 * Copyright (c) 2000-2003 The OpenSSL Project. All rights reserved. 7 * Copyright (c) 2000-2005 The OpenSSL Project. All rights reserved.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
@@ -81,156 +81,143 @@ typedef struct ECDSA_SIG_st
81 BIGNUM *s; 81 BIGNUM *s;
82 } ECDSA_SIG; 82 } ECDSA_SIG;
83 83
84/** ECDSA_SIG *ECDSA_SIG_new(void) 84/** Allocates and initialize a ECDSA_SIG structure
85 * allocates and initialize a ECDSA_SIG structure 85 * \return pointer to a ECDSA_SIG structure or NULL if an error occurred
86 * \return pointer to a ECDSA_SIG structure or NULL if an error occurred
87 */ 86 */
88ECDSA_SIG *ECDSA_SIG_new(void); 87ECDSA_SIG *ECDSA_SIG_new(void);
89 88
90/** ECDSA_SIG_free 89/** frees a ECDSA_SIG structure
91 * frees a ECDSA_SIG structure 90 * \param sig pointer to the ECDSA_SIG structure
92 * \param a pointer to the ECDSA_SIG structure
93 */ 91 */
94void ECDSA_SIG_free(ECDSA_SIG *a); 92void ECDSA_SIG_free(ECDSA_SIG *sig);
95 93
96/** i2d_ECDSA_SIG 94/** DER encode content of ECDSA_SIG object (note: this function modifies *pp
97 * DER encode content of ECDSA_SIG object (note: this function modifies *pp 95 * (*pp += length of the DER encoded signature)).
98 * (*pp += length of the DER encoded signature)). 96 * \param sig pointer to the ECDSA_SIG object
99 * \param a pointer to the ECDSA_SIG object 97 * \param pp pointer to a unsigned char pointer for the output or NULL
100 * \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
101 * \return the length of the DER encoded ECDSA_SIG object or 0
102 */ 99 */
103int i2d_ECDSA_SIG(const ECDSA_SIG *a, unsigned char **pp); 100int i2d_ECDSA_SIG(const ECDSA_SIG *sig, unsigned char **pp);
104 101
105/** d2i_ECDSA_SIG 102/** Decodes a DER encoded ECDSA signature (note: this function changes *pp
106 * decodes a DER encoded ECDSA signature (note: this function changes *pp 103 * (*pp += len)).
107 * (*pp += len)). 104 * \param sig pointer to ECDSA_SIG pointer (may be NULL)
108 * \param v pointer to ECDSA_SIG pointer (may be NULL) 105 * \param pp memory buffer with the DER encoded signature
109 * \param pp buffer with the DER encoded signature 106 * \param len length of the buffer
110 * \param len bufferlength 107 * \return pointer to the decoded ECDSA_SIG structure (or NULL)
111 * \return pointer to the decoded ECDSA_SIG structure (or NULL)
112 */ 108 */
113ECDSA_SIG *d2i_ECDSA_SIG(ECDSA_SIG **v, const unsigned char **pp, long len); 109ECDSA_SIG *d2i_ECDSA_SIG(ECDSA_SIG **sig, const unsigned char **pp, long len);
114 110
115/** ECDSA_do_sign 111/** Computes the ECDSA signature of the given hash value using
116 * computes the ECDSA signature of the given hash value using 112 * the supplied private key and returns the created signature.
117 * the supplied private key and returns the created signature. 113 * \param dgst pointer to the hash value
118 * \param dgst pointer to the hash value 114 * \param dgst_len length of the hash value
119 * \param dgst_len length of the hash value 115 * \param eckey EC_KEY object containing a private EC key
120 * \param eckey pointer to the EC_KEY object containing a private EC key 116 * \return pointer to a ECDSA_SIG structure or NULL if an error occurred
121 * \return pointer to a ECDSA_SIG structure or NULL
122 */ 117 */
123ECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst,int dgst_len,EC_KEY *eckey); 118ECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst,int dgst_len,EC_KEY *eckey);
124 119
125/** ECDSA_do_sign_ex 120/** Computes ECDSA signature of a given hash value using the supplied
126 * 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).
127 * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). 122 * \param dgst pointer to the hash value to sign
128 * \param dgst pointer to the hash value to sign 123 * \param dgstlen length of the hash value
129 * \param dgstlen length of the hash value 124 * \param kinv BIGNUM with a pre-computed inverse k (optional)
130 * \param kinv optional pointer to a pre-computed inverse k 125 * \param rp BIGNUM with a pre-computed rp value (optioanl),
131 * \param rp optional pointer to the pre-computed rp value (see 126 * see ECDSA_sign_setup
132 * ECDSA_sign_setup 127 * \param eckey EC_KEY object containing a private EC key
133 * \param eckey pointer to the EC_KEY object containing a private EC key 128 * \return pointer to a ECDSA_SIG structure or NULL if an error occurred
134 * \return pointer to a ECDSA_SIG structure or NULL
135 */ 129 */
136ECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, int dgstlen, 130ECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, int dgstlen,
137 const BIGNUM *kinv, const BIGNUM *rp, EC_KEY *eckey); 131 const BIGNUM *kinv, const BIGNUM *rp, EC_KEY *eckey);
138 132
139/** ECDSA_do_verify 133/** Verifies that the supplied signature is a valid ECDSA
140 * verifies that the supplied signature is a valid ECDSA 134 * signature of the supplied hash value using the supplied public key.
141 * signature of the supplied hash value using the supplied public key. 135 * \param dgst pointer to the hash value
142 * \param dgst pointer to the hash value 136 * \param dgst_len length of the hash value
143 * \param dgst_len length of the hash value 137 * \param sig ECDSA_SIG structure
144 * \param sig pointer to the ECDSA_SIG structure 138 * \param eckey EC_KEY object containing a public EC key
145 * \param eckey pointer to the EC_KEY object containing a public EC key 139 * \return 1 if the signature is valid, 0 if the signature is invalid
146 * \return 1 if the signature is valid, 0 if the signature is invalid and -1 on error 140 * and -1 on error
147 */ 141 */
148int ECDSA_do_verify(const unsigned char *dgst, int dgst_len, 142int ECDSA_do_verify(const unsigned char *dgst, int dgst_len,
149 const ECDSA_SIG *sig, EC_KEY* eckey); 143 const ECDSA_SIG *sig, EC_KEY* eckey);
150 144
151const ECDSA_METHOD *ECDSA_OpenSSL(void); 145const ECDSA_METHOD *ECDSA_OpenSSL(void);
152 146
153/** ECDSA_set_default_method 147/** Sets the default ECDSA method
154 * sets the default ECDSA method 148 * \param meth new default ECDSA_METHOD
155 * \param meth the new default ECDSA_METHOD
156 */ 149 */
157void ECDSA_set_default_method(const ECDSA_METHOD *meth); 150void ECDSA_set_default_method(const ECDSA_METHOD *meth);
158 151
159/** ECDSA_get_default_method 152/** Returns the default ECDSA method
160 * returns the default ECDSA method 153 * \return pointer to ECDSA_METHOD structure containing the default method
161 * \return pointer to ECDSA_METHOD structure containing the default method
162 */ 154 */
163const ECDSA_METHOD *ECDSA_get_default_method(void); 155const ECDSA_METHOD *ECDSA_get_default_method(void);
164 156
165/** ECDSA_set_method 157/** Sets method to be used for the ECDSA operations
166 * sets method to be used for the ECDSA operations 158 * \param eckey EC_KEY object
167 * \param eckey pointer to the EC_KEY object 159 * \param meth new method
168 * \param meth pointer to the new method 160 * \return 1 on success and 0 otherwise
169 * \return 1 on success and 0 otherwise
170 */ 161 */
171int ECDSA_set_method(EC_KEY *eckey, const ECDSA_METHOD *meth); 162int ECDSA_set_method(EC_KEY *eckey, const ECDSA_METHOD *meth);
172 163
173/** ECDSA_size 164/** Returns the maximum length of the DER encoded signature
174 * returns the maximum length of the DER encoded signature 165 * \param eckey EC_KEY object
175 * \param eckey pointer to a EC_KEY object 166 * \return numbers of bytes required for the DER encoded signature
176 * \return numbers of bytes required for the DER encoded signature
177 */ 167 */
178int ECDSA_size(const EC_KEY *eckey); 168int ECDSA_size(const EC_KEY *eckey);
179 169
180/** ECDSA_sign_setup 170/** Precompute parts of the signing operation
181 * precompute parts of the signing operation. 171 * \param eckey EC_KEY object containing a private EC key
182 * \param eckey pointer to the EC_KEY object containing a private EC key 172 * \param ctx BN_CTX object (optional)
183 * \param ctx pointer to a BN_CTX object (may be NULL) 173 * \param kinv BIGNUM pointer for the inverse of k
184 * \param kinv pointer to a BIGNUM pointer for the inverse of k 174 * \param rp BIGNUM pointer for x coordinate of k * generator
185 * \param rp pointer to a BIGNUM pointer for x coordinate of k * generator 175 * \return 1 on success and 0 otherwise
186 * \return 1 on success and 0 otherwise
187 */ 176 */
188int ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinv, 177int ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinv,
189 BIGNUM **rp); 178 BIGNUM **rp);
190 179
191/** ECDSA_sign 180/** Computes ECDSA signature of a given hash value using the supplied
192 * 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).
193 * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). 182 * \param type this parameter is ignored
194 * \param type this parameter is ignored 183 * \param dgst pointer to the hash value to sign
195 * \param dgst pointer to the hash value to sign 184 * \param dgstlen length of the hash value
196 * \param dgstlen length of the hash value 185 * \param sig memory for the DER encoded created signature
197 * \param sig buffer to hold the DER encoded signature 186 * \param siglen pointer to the length of the returned signature
198 * \param siglen pointer to the length of the returned signature 187 * \param eckey EC_KEY object containing a private EC key
199 * \param eckey pointer to the EC_KEY object containing a private EC key 188 * \return 1 on success and 0 otherwise
200 * \return 1 on success and 0 otherwise
201 */ 189 */
202int ECDSA_sign(int type, const unsigned char *dgst, int dgstlen, 190int ECDSA_sign(int type, const unsigned char *dgst, int dgstlen,
203 unsigned char *sig, unsigned int *siglen, EC_KEY *eckey); 191 unsigned char *sig, unsigned int *siglen, EC_KEY *eckey);
204 192
205 193
206/** ECDSA_sign_ex 194/** Computes ECDSA signature of a given hash value using the supplied
207 * 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).
208 * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). 196 * \param type this parameter is ignored
209 * \param type this parameter is ignored 197 * \param dgst pointer to the hash value to sign
210 * \param dgst pointer to the hash value to sign 198 * \param dgstlen length of the hash value
211 * \param dgstlen length of the hash value 199 * \param sig buffer to hold the DER encoded signature
212 * \param sig buffer to hold the DER encoded signature 200 * \param siglen pointer to the length of the returned signature
213 * \param siglen pointer to the length of the returned signature 201 * \param kinv BIGNUM with a pre-computed inverse k (optional)
214 * \param kinv optional pointer to a pre-computed inverse k 202 * \param rp BIGNUM with a pre-computed rp value (optioanl),
215 * \param rp optional pointer to the pre-computed rp value (see 203 * see ECDSA_sign_setup
216 * ECDSA_sign_setup 204 * \param eckey EC_KEY object containing a private EC key
217 * \param eckey pointer to the EC_KEY object containing a private EC key 205 * \return 1 on success and 0 otherwise
218 * \return 1 on success and 0 otherwise
219 */ 206 */
220int ECDSA_sign_ex(int type, const unsigned char *dgst, int dgstlen, 207int ECDSA_sign_ex(int type, const unsigned char *dgst, int dgstlen,
221 unsigned char *sig, unsigned int *siglen, const BIGNUM *kinv, 208 unsigned char *sig, unsigned int *siglen, const BIGNUM *kinv,
222 const BIGNUM *rp, EC_KEY *eckey); 209 const BIGNUM *rp, EC_KEY *eckey);
223 210
224/** ECDSA_verify 211/** Verifies that the given signature is valid ECDSA signature
225 * verifies that the given signature is valid ECDSA signature 212 * of the supplied hash value using the specified public key.
226 * of the supplied hash value using the specified public key. 213 * \param type this parameter is ignored
227 * \param type this parameter is ignored 214 * \param dgst pointer to the hash value
228 * \param dgst pointer to the hash value 215 * \param dgstlen length of the hash value
229 * \param dgstlen length of the hash value 216 * \param sig pointer to the DER encoded signature
230 * \param sig pointer to the DER encoded signature 217 * \param siglen length of the DER encoded signature
231 * \param siglen length of the DER encoded signature 218 * \param eckey EC_KEY object containing a public EC key
232 * \param eckey pointer to the EC_KEY object containing a public EC key 219 * \return 1 if the signature is valid, 0 if the signature is invalid
233 * \return 1 if the signature is valid, 0 if the signature is invalid and -1 on error 220 * and -1 on error
234 */ 221 */
235int ECDSA_verify(int type, const unsigned char *dgst, int dgstlen, 222int ECDSA_verify(int type, const unsigned char *dgst, int dgstlen,
236 const unsigned char *sig, int siglen, EC_KEY *eckey); 223 const unsigned char *sig, int siglen, EC_KEY *eckey);