diff options
Diffstat (limited to 'src/lib/libcrypto/ecdsa/ecdsa.h')
| -rw-r--r-- | src/lib/libcrypto/ecdsa/ecdsa.h | 69 |
1 files changed, 35 insertions, 34 deletions
diff --git a/src/lib/libcrypto/ecdsa/ecdsa.h b/src/lib/libcrypto/ecdsa/ecdsa.h index ad716c24a5..530ab265bb 100644 --- a/src/lib/libcrypto/ecdsa/ecdsa.h +++ b/src/lib/libcrypto/ecdsa/ecdsa.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ecdsa.h,v 1.3 2014/11/17 20:25:50 miod Exp $ */ | 1 | /* $OpenBSD: ecdsa.h,v 1.4 2015/02/08 13:35:06 jsing Exp $ */ |
| 2 | /** | 2 | /** |
| 3 | * \file crypto/ecdsa/ecdsa.h Include file for the OpenSSL ECDSA functions | 3 | * \file crypto/ecdsa/ecdsa.h Include file for the OpenSSL ECDSA functions |
| 4 | * \author Written by Nils Larsch for the OpenSSL project | 4 | * \author Written by Nils Larsch for the OpenSSL project |
| @@ -11,7 +11,7 @@ | |||
| 11 | * are met: | 11 | * are met: |
| 12 | * | 12 | * |
| 13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright |
| 14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. |
| 15 | * | 15 | * |
| 16 | * 2. Redistributions in binary form must reproduce the above copyright | 16 | * 2. Redistributions in binary form must reproduce the above copyright |
| 17 | * notice, this list of conditions and the following disclaimer in | 17 | * notice, this list of conditions and the following disclaimer in |
| @@ -79,11 +79,11 @@ typedef struct ECDSA_SIG_st ECDSA_SIG; | |||
| 79 | 79 | ||
| 80 | struct ecdsa_method { | 80 | struct ecdsa_method { |
| 81 | const char *name; | 81 | const char *name; |
| 82 | ECDSA_SIG *(*ecdsa_do_sign)(const unsigned char *dgst, int dgst_len, | 82 | ECDSA_SIG *(*ecdsa_do_sign)(const unsigned char *dgst, int dgst_len, |
| 83 | const BIGNUM *inv, const BIGNUM *rp, EC_KEY *eckey); | 83 | const BIGNUM *inv, const BIGNUM *rp, EC_KEY *eckey); |
| 84 | int (*ecdsa_sign_setup)(EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinv, | 84 | int (*ecdsa_sign_setup)(EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinv, |
| 85 | BIGNUM **r); | 85 | BIGNUM **r); |
| 86 | int (*ecdsa_do_verify)(const unsigned char *dgst, int dgst_len, | 86 | int (*ecdsa_do_verify)(const unsigned char *dgst, int dgst_len, |
| 87 | const ECDSA_SIG *sig, EC_KEY *eckey); | 87 | const ECDSA_SIG *sig, EC_KEY *eckey); |
| 88 | #if 0 | 88 | #if 0 |
| 89 | int (*init)(EC_KEY *eckey); | 89 | int (*init)(EC_KEY *eckey); |
| @@ -114,18 +114,18 @@ ECDSA_SIG *ECDSA_SIG_new(void); | |||
| 114 | /** frees a ECDSA_SIG structure | 114 | /** frees a ECDSA_SIG structure |
| 115 | * \param sig pointer to the ECDSA_SIG structure | 115 | * \param sig pointer to the ECDSA_SIG structure |
| 116 | */ | 116 | */ |
| 117 | void ECDSA_SIG_free(ECDSA_SIG *sig); | 117 | void ECDSA_SIG_free(ECDSA_SIG *sig); |
| 118 | 118 | ||
| 119 | /** DER encode content of ECDSA_SIG object (note: this function modifies *pp | 119 | /** DER encode content of ECDSA_SIG object (note: this function modifies *pp |
| 120 | * (*pp += length of the DER encoded signature)). | 120 | * (*pp += length of the DER encoded signature)). |
| 121 | * \param sig pointer to the ECDSA_SIG object | 121 | * \param sig pointer to the ECDSA_SIG object |
| 122 | * \param pp pointer to a unsigned char pointer for the output or NULL | 122 | * \param pp pointer to a unsigned char pointer for the output or NULL |
| 123 | * \return the length of the DER encoded ECDSA_SIG object or 0 | 123 | * \return the length of the DER encoded ECDSA_SIG object or 0 |
| 124 | */ | 124 | */ |
| 125 | int i2d_ECDSA_SIG(const ECDSA_SIG *sig, unsigned char **pp); | 125 | int i2d_ECDSA_SIG(const ECDSA_SIG *sig, unsigned char **pp); |
| 126 | 126 | ||
| 127 | /** Decodes a DER encoded ECDSA signature (note: this function changes *pp | 127 | /** Decodes a DER encoded ECDSA signature (note: this function changes *pp |
| 128 | * (*pp += len)). | 128 | * (*pp += len)). |
| 129 | * \param sig pointer to ECDSA_SIG pointer (may be NULL) | 129 | * \param sig pointer to ECDSA_SIG pointer (may be NULL) |
| 130 | * \param pp memory buffer with the DER encoded signature | 130 | * \param pp memory buffer with the DER encoded signature |
| 131 | * \param len length of the buffer | 131 | * \param len length of the buffer |
| @@ -140,20 +140,21 @@ ECDSA_SIG *d2i_ECDSA_SIG(ECDSA_SIG **sig, const unsigned char **pp, long len); | |||
| 140 | * \param eckey EC_KEY object containing a private EC key | 140 | * \param eckey EC_KEY object containing a private EC key |
| 141 | * \return pointer to a ECDSA_SIG structure or NULL if an error occurred | 141 | * \return pointer to a ECDSA_SIG structure or NULL if an error occurred |
| 142 | */ | 142 | */ |
| 143 | ECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst,int dgst_len,EC_KEY *eckey); | 143 | ECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst, int dgst_len, |
| 144 | EC_KEY *eckey); | ||
| 144 | 145 | ||
| 145 | /** Computes ECDSA signature of a given hash value using the supplied | 146 | /** Computes ECDSA signature of a given hash value using the supplied |
| 146 | * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). | 147 | * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). |
| 147 | * \param dgst pointer to the hash value to sign | 148 | * \param dgst pointer to the hash value to sign |
| 148 | * \param dgstlen length of the hash value | 149 | * \param dgstlen length of the hash value |
| 149 | * \param kinv BIGNUM with a pre-computed inverse k (optional) | 150 | * \param kinv BIGNUM with a pre-computed inverse k (optional) |
| 150 | * \param rp BIGNUM with a pre-computed rp value (optioanl), | 151 | * \param rp BIGNUM with a pre-computed rp value (optioanl), |
| 151 | * see ECDSA_sign_setup | 152 | * see ECDSA_sign_setup |
| 152 | * \param eckey EC_KEY object containing a private EC key | 153 | * \param eckey EC_KEY object containing a private EC key |
| 153 | * \return pointer to a ECDSA_SIG structure or NULL if an error occurred | 154 | * \return pointer to a ECDSA_SIG structure or NULL if an error occurred |
| 154 | */ | 155 | */ |
| 155 | ECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, int dgstlen, | 156 | ECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, int dgstlen, |
| 156 | const BIGNUM *kinv, const BIGNUM *rp, EC_KEY *eckey); | 157 | const BIGNUM *kinv, const BIGNUM *rp, EC_KEY *eckey); |
| 157 | 158 | ||
| 158 | /** Verifies that the supplied signature is a valid ECDSA | 159 | /** Verifies that the supplied signature is a valid ECDSA |
| 159 | * signature of the supplied hash value using the supplied public key. | 160 | * signature of the supplied hash value using the supplied public key. |
| @@ -164,15 +165,15 @@ ECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, int dgstlen, | |||
| 164 | * \return 1 if the signature is valid, 0 if the signature is invalid | 165 | * \return 1 if the signature is valid, 0 if the signature is invalid |
| 165 | * and -1 on error | 166 | * and -1 on error |
| 166 | */ | 167 | */ |
| 167 | int ECDSA_do_verify(const unsigned char *dgst, int dgst_len, | 168 | int ECDSA_do_verify(const unsigned char *dgst, int dgst_len, |
| 168 | const ECDSA_SIG *sig, EC_KEY* eckey); | 169 | const ECDSA_SIG *sig, EC_KEY* eckey); |
| 169 | 170 | ||
| 170 | const ECDSA_METHOD *ECDSA_OpenSSL(void); | 171 | const ECDSA_METHOD *ECDSA_OpenSSL(void); |
| 171 | 172 | ||
| 172 | /** Sets the default ECDSA method | 173 | /** Sets the default ECDSA method |
| 173 | * \param meth new default ECDSA_METHOD | 174 | * \param meth new default ECDSA_METHOD |
| 174 | */ | 175 | */ |
| 175 | void ECDSA_set_default_method(const ECDSA_METHOD *meth); | 176 | void ECDSA_set_default_method(const ECDSA_METHOD *meth); |
| 176 | 177 | ||
| 177 | /** Returns the default ECDSA method | 178 | /** Returns the default ECDSA method |
| 178 | * \return pointer to ECDSA_METHOD structure containing the default method | 179 | * \return pointer to ECDSA_METHOD structure containing the default method |
| @@ -182,15 +183,15 @@ const ECDSA_METHOD *ECDSA_get_default_method(void); | |||
| 182 | /** Sets method to be used for the ECDSA operations | 183 | /** Sets method to be used for the ECDSA operations |
| 183 | * \param eckey EC_KEY object | 184 | * \param eckey EC_KEY object |
| 184 | * \param meth new method | 185 | * \param meth new method |
| 185 | * \return 1 on success and 0 otherwise | 186 | * \return 1 on success and 0 otherwise |
| 186 | */ | 187 | */ |
| 187 | int ECDSA_set_method(EC_KEY *eckey, const ECDSA_METHOD *meth); | 188 | int ECDSA_set_method(EC_KEY *eckey, const ECDSA_METHOD *meth); |
| 188 | 189 | ||
| 189 | /** Returns the maximum length of the DER encoded signature | 190 | /** Returns the maximum length of the DER encoded signature |
| 190 | * \param eckey EC_KEY object | 191 | * \param eckey EC_KEY object |
| 191 | * \return numbers of bytes required for the DER encoded signature | 192 | * \return numbers of bytes required for the DER encoded signature |
| 192 | */ | 193 | */ |
| 193 | int ECDSA_size(const EC_KEY *eckey); | 194 | int ECDSA_size(const EC_KEY *eckey); |
| 194 | 195 | ||
| 195 | /** Precompute parts of the signing operation | 196 | /** Precompute parts of the signing operation |
| 196 | * \param eckey EC_KEY object containing a private EC key | 197 | * \param eckey EC_KEY object containing a private EC key |
| @@ -199,8 +200,8 @@ int ECDSA_size(const EC_KEY *eckey); | |||
| 199 | * \param rp BIGNUM pointer for x coordinate of k * generator | 200 | * \param rp BIGNUM pointer for x coordinate of k * generator |
| 200 | * \return 1 on success and 0 otherwise | 201 | * \return 1 on success and 0 otherwise |
| 201 | */ | 202 | */ |
| 202 | int ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinv, | 203 | int ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinv, |
| 203 | BIGNUM **rp); | 204 | BIGNUM **rp); |
| 204 | 205 | ||
| 205 | /** Computes ECDSA signature of a given hash value using the supplied | 206 | /** Computes ECDSA signature of a given hash value using the supplied |
| 206 | * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). | 207 | * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). |
| @@ -212,8 +213,8 @@ int ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinv, | |||
| 212 | * \param eckey EC_KEY object containing a private EC key | 213 | * \param eckey EC_KEY object containing a private EC key |
| 213 | * \return 1 on success and 0 otherwise | 214 | * \return 1 on success and 0 otherwise |
| 214 | */ | 215 | */ |
| 215 | int ECDSA_sign(int type, const unsigned char *dgst, int dgstlen, | 216 | int ECDSA_sign(int type, const unsigned char *dgst, int dgstlen, |
| 216 | unsigned char *sig, unsigned int *siglen, EC_KEY *eckey); | 217 | unsigned char *sig, unsigned int *siglen, EC_KEY *eckey); |
| 217 | 218 | ||
| 218 | 219 | ||
| 219 | /** Computes ECDSA signature of a given hash value using the supplied | 220 | /** Computes ECDSA signature of a given hash value using the supplied |
| @@ -224,19 +225,19 @@ int ECDSA_sign(int type, const unsigned char *dgst, int dgstlen, | |||
| 224 | * \param sig buffer to hold the DER encoded signature | 225 | * \param sig buffer to hold the DER encoded signature |
| 225 | * \param siglen pointer to the length of the returned signature | 226 | * \param siglen pointer to the length of the returned signature |
| 226 | * \param kinv BIGNUM with a pre-computed inverse k (optional) | 227 | * \param kinv BIGNUM with a pre-computed inverse k (optional) |
| 227 | * \param rp BIGNUM with a pre-computed rp value (optioanl), | 228 | * \param rp BIGNUM with a pre-computed rp value (optioanl), |
| 228 | * see ECDSA_sign_setup | 229 | * see ECDSA_sign_setup |
| 229 | * \param eckey EC_KEY object containing a private EC key | 230 | * \param eckey EC_KEY object containing a private EC key |
| 230 | * \return 1 on success and 0 otherwise | 231 | * \return 1 on success and 0 otherwise |
| 231 | */ | 232 | */ |
| 232 | int ECDSA_sign_ex(int type, const unsigned char *dgst, int dgstlen, | 233 | int ECDSA_sign_ex(int type, const unsigned char *dgst, int dgstlen, |
| 233 | unsigned char *sig, unsigned int *siglen, const BIGNUM *kinv, | 234 | unsigned char *sig, unsigned int *siglen, const BIGNUM *kinv, |
| 234 | const BIGNUM *rp, EC_KEY *eckey); | 235 | const BIGNUM *rp, EC_KEY *eckey); |
| 235 | 236 | ||
| 236 | /** Verifies that the given signature is valid ECDSA signature | 237 | /** Verifies that the given signature is valid ECDSA signature |
| 237 | * of the supplied hash value using the specified public key. | 238 | * of the supplied hash value using the specified public key. |
| 238 | * \param type this parameter is ignored | 239 | * \param type this parameter is ignored |
| 239 | * \param dgst pointer to the hash value | 240 | * \param dgst pointer to the hash value |
| 240 | * \param dgstlen length of the hash value | 241 | * \param dgstlen length of the hash value |
| 241 | * \param sig pointer to the DER encoded signature | 242 | * \param sig pointer to the DER encoded signature |
| 242 | * \param siglen length of the DER encoded signature | 243 | * \param siglen length of the DER encoded signature |
| @@ -244,14 +245,14 @@ int ECDSA_sign_ex(int type, const unsigned char *dgst, int dgstlen, | |||
| 244 | * \return 1 if the signature is valid, 0 if the signature is invalid | 245 | * \return 1 if the signature is valid, 0 if the signature is invalid |
| 245 | * and -1 on error | 246 | * and -1 on error |
| 246 | */ | 247 | */ |
| 247 | int ECDSA_verify(int type, const unsigned char *dgst, int dgstlen, | 248 | int ECDSA_verify(int type, const unsigned char *dgst, int dgstlen, |
| 248 | const unsigned char *sig, int siglen, EC_KEY *eckey); | 249 | const unsigned char *sig, int siglen, EC_KEY *eckey); |
| 249 | 250 | ||
| 250 | /* the standard ex_data functions */ | 251 | /* the standard ex_data functions */ |
| 251 | int ECDSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new | 252 | int ECDSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, |
| 252 | *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); | 253 | CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); |
| 253 | int ECDSA_set_ex_data(EC_KEY *d, int idx, void *arg); | 254 | int ECDSA_set_ex_data(EC_KEY *d, int idx, void *arg); |
| 254 | void *ECDSA_get_ex_data(EC_KEY *d, int idx); | 255 | void *ECDSA_get_ex_data(EC_KEY *d, int idx); |
| 255 | 256 | ||
| 256 | 257 | ||
| 257 | /* BEGIN ERROR CODES */ | 258 | /* BEGIN ERROR CODES */ |
