OpenSSL  1.0.1c
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
Classes | Macros | Typedefs | Functions
ecdsa.h File Reference
#include <openssl/opensslconf.h>
#include <openssl/ec.h>
#include <openssl/ossl_typ.h>
#include <openssl/bn.h>

Go to the source code of this file.

Classes

struct  ECDSA_SIG_st
 

Macros

#define ECDSA_F_ECDSA_CHECK   104
 
#define ECDSA_F_ECDSA_DATA_NEW_METHOD   100
 
#define ECDSA_F_ECDSA_DO_SIGN   101
 
#define ECDSA_F_ECDSA_DO_VERIFY   102
 
#define ECDSA_F_ECDSA_SIGN_SETUP   103
 
#define ECDSA_R_BAD_SIGNATURE   100
 
#define ECDSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE   101
 
#define ECDSA_R_ERR_EC_LIB   102
 
#define ECDSA_R_MISSING_PARAMETERS   103
 
#define ECDSA_R_NEED_NEW_SETUP_VALUES   106
 
#define ECDSA_R_NON_FIPS_METHOD   107
 
#define ECDSA_R_RANDOM_NUMBER_GENERATION_FAILED   104
 
#define ECDSA_R_SIGNATURE_MALLOC_FAILED   105
 

Typedefs

typedef struct ECDSA_SIG_st ECDSA_SIG
 

Functions

ECDSA_SIGECDSA_SIG_new (void)
 
void ECDSA_SIG_free (ECDSA_SIG *sig)
 
int i2d_ECDSA_SIG (const ECDSA_SIG *sig, unsigned char **pp)
 
ECDSA_SIGd2i_ECDSA_SIG (ECDSA_SIG **sig, const unsigned char **pp, long len)
 
ECDSA_SIGECDSA_do_sign (const unsigned char *dgst, int dgst_len, EC_KEY *eckey)
 
ECDSA_SIGECDSA_do_sign_ex (const unsigned char *dgst, int dgstlen, const BIGNUM *kinv, const BIGNUM *rp, EC_KEY *eckey)
 
int ECDSA_do_verify (const unsigned char *dgst, int dgst_len, const ECDSA_SIG *sig, EC_KEY *eckey)
 
const ECDSA_METHODECDSA_OpenSSL (void)
 
void ECDSA_set_default_method (const ECDSA_METHOD *meth)
 
const ECDSA_METHODECDSA_get_default_method (void)
 
int ECDSA_set_method (EC_KEY *eckey, const ECDSA_METHOD *meth)
 
int ECDSA_size (const EC_KEY *eckey)
 
int ECDSA_sign_setup (EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinv, BIGNUM **rp)
 
int ECDSA_sign (int type, const unsigned char *dgst, int dgstlen, unsigned char *sig, unsigned int *siglen, EC_KEY *eckey)
 
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)
 
int ECDSA_verify (int type, const unsigned char *dgst, int dgstlen, const unsigned char *sig, int siglen, EC_KEY *eckey)
 
int ECDSA_get_ex_new_index (long argl, void *argp, CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
 
int ECDSA_set_ex_data (EC_KEY *d, int idx, void *arg)
 
voidECDSA_get_ex_data (EC_KEY *d, int idx)
 
void ERR_load_ECDSA_strings (void)
 

Detailed Description

Include file for the OpenSSL ECDSA functions

Author
Written by Nils Larsch for the OpenSSL project

Definition in file ecdsa.h.

Macro Definition Documentation

#define ECDSA_F_ECDSA_CHECK   104

Definition at line 241 of file ecdsa.h.

#define ECDSA_F_ECDSA_DATA_NEW_METHOD   100

Definition at line 242 of file ecdsa.h.

#define ECDSA_F_ECDSA_DO_SIGN   101

Definition at line 243 of file ecdsa.h.

#define ECDSA_F_ECDSA_DO_VERIFY   102

Definition at line 244 of file ecdsa.h.

#define ECDSA_F_ECDSA_SIGN_SETUP   103

Definition at line 245 of file ecdsa.h.

#define ECDSA_R_BAD_SIGNATURE   100

Definition at line 248 of file ecdsa.h.

#define ECDSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE   101

Definition at line 249 of file ecdsa.h.

#define ECDSA_R_ERR_EC_LIB   102

Definition at line 250 of file ecdsa.h.

#define ECDSA_R_MISSING_PARAMETERS   103

Definition at line 251 of file ecdsa.h.

#define ECDSA_R_NEED_NEW_SETUP_VALUES   106

Definition at line 252 of file ecdsa.h.

#define ECDSA_R_NON_FIPS_METHOD   107

Definition at line 253 of file ecdsa.h.

#define ECDSA_R_RANDOM_NUMBER_GENERATION_FAILED   104

Definition at line 254 of file ecdsa.h.

#define ECDSA_R_SIGNATURE_MALLOC_FAILED   105

Definition at line 255 of file ecdsa.h.

Typedef Documentation

typedef struct ECDSA_SIG_st ECDSA_SIG

Function Documentation

ECDSA_SIG* d2i_ECDSA_SIG ( ECDSA_SIG **  sig,
const unsigned char **  pp,
long  len 
)

Decodes a DER encoded ECDSA signature (note: this function changes *pp (*pp += len)).

Parameters
sigpointer to ECDSA_SIG pointer (may be NULL)
ppmemory buffer with the DER encoded signature
lenlength of the buffer
Returns
pointer to the decoded ECDSA_SIG structure (or NULL)
ECDSA_SIG* ECDSA_do_sign ( const unsigned char *  dgst,
int  dgst_len,
EC_KEY eckey 
)

Computes the ECDSA signature of the given hash value using the supplied private key and returns the created signature.

Parameters
dgstpointer to the hash value
dgst_lenlength of the hash value
eckeyEC_KEY object containing a private EC key
Returns
pointer to a ECDSA_SIG structure or NULL if an error occurred

Definition at line 62 of file ecs_sign.c.

ECDSA_SIG* ECDSA_do_sign_ex ( const unsigned char *  dgst,
int  dgstlen,
const BIGNUM kinv,
const BIGNUM rp,
EC_KEY eckey 
)

Computes ECDSA signature of a given hash value using the supplied private key (note: sig must point to ECDSA_size(eckey) bytes of memory).

Parameters
dgstpointer to the hash value to sign
dgstlenlength of the hash value
kinvBIGNUM with a pre-computed inverse k (optional)
rpBIGNUM with a pre-computed rp value (optioanl), see ECDSA_sign_setup
eckeyEC_KEY object containing a private EC key
Returns
pointer to a ECDSA_SIG structure or NULL if an error occurred

Definition at line 67 of file ecs_sign.c.

int ECDSA_do_verify ( const unsigned char *  dgst,
int  dgst_len,
const ECDSA_SIG sig,
EC_KEY eckey 
)

Verifies that the supplied signature is a valid ECDSA signature of the supplied hash value using the supplied public key.

Parameters
dgstpointer to the hash value
dgst_lenlength of the hash value
sigECDSA_SIG structure
eckeyEC_KEY object containing a public EC key
Returns
1 if the signature is valid, 0 if the signature is invalid and -1 on error

Definition at line 69 of file ecs_vrf.c.

const ECDSA_METHOD* ECDSA_get_default_method ( void  )

Returns the default ECDSA method

Returns
pointer to ECDSA_METHOD structure containing the default method

Definition at line 80 of file ecs_lib.c.

void* ECDSA_get_ex_data ( EC_KEY d,
int  idx 
)

Definition at line 271 of file ecs_lib.c.

int ECDSA_get_ex_new_index ( long  argl,
void argp,
CRYPTO_EX_new new_func,
CRYPTO_EX_dup dup_func,
CRYPTO_EX_free free_func 
)

Definition at line 255 of file ecs_lib.c.

const ECDSA_METHOD* ECDSA_OpenSSL ( void  )

Definition at line 84 of file ecs_ossl.c.

void ECDSA_set_default_method ( const ECDSA_METHOD meth)

Sets the default ECDSA method

Parameters
methnew default ECDSA_METHOD

Definition at line 75 of file ecs_lib.c.

int ECDSA_set_ex_data ( EC_KEY d,
int  idx,
void arg 
)

Definition at line 262 of file ecs_lib.c.

int ECDSA_set_method ( EC_KEY eckey,
const ECDSA_METHOD meth 
)

Sets method to be used for the ECDSA operations

Parameters
eckeyEC_KEY object
methnew method
Returns
1 on success and 0 otherwise

Definition at line 96 of file ecs_lib.c.

void ECDSA_SIG_free ( ECDSA_SIG sig)

frees a ECDSA_SIG structure

Parameters
sigpointer to the ECDSA_SIG structure
ECDSA_SIG* ECDSA_SIG_new ( void  )

Allocates and initialize a ECDSA_SIG structure

Returns
pointer to a ECDSA_SIG structure or NULL if an error occurred
int ECDSA_sign ( int  type,
const unsigned char *  dgst,
int  dgstlen,
unsigned char *  sig,
unsigned int *  siglen,
EC_KEY eckey 
)

Computes ECDSA signature of a given hash value using the supplied private key (note: sig must point to ECDSA_size(eckey) bytes of memory).

Parameters
typethis parameter is ignored
dgstpointer to the hash value to sign
dgstlenlength of the hash value
sigmemory for the DER encoded created signature
siglenpointer to the length of the returned signature
eckeyEC_KEY object containing a private EC key
Returns
1 on success and 0 otherwise

Definition at line 76 of file ecs_sign.c.

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 
)

Computes ECDSA signature of a given hash value using the supplied private key (note: sig must point to ECDSA_size(eckey) bytes of memory).

Parameters
typethis parameter is ignored
dgstpointer to the hash value to sign
dgstlenlength of the hash value
sigbuffer to hold the DER encoded signature
siglenpointer to the length of the returned signature
kinvBIGNUM with a pre-computed inverse k (optional)
rpBIGNUM with a pre-computed rp value (optioanl), see ECDSA_sign_setup
eckeyEC_KEY object containing a private EC key
Returns
1 on success and 0 otherwise

Definition at line 82 of file ecs_sign.c.

int ECDSA_sign_setup ( EC_KEY eckey,
BN_CTX ctx,
BIGNUM **  kinv,
BIGNUM **  rp 
)

Precompute parts of the signing operation

Parameters
eckeyEC_KEY object containing a private EC key
ctxBN_CTX object (optional)
kinvBIGNUM pointer for the inverse of k
rpBIGNUM pointer for x coordinate of k * generator
Returns
1 on success and 0 otherwise

Definition at line 99 of file ecs_sign.c.

int ECDSA_size ( const EC_KEY eckey)

Returns the maximum length of the DER encoded signature

Parameters
eckeyEC_KEY object
Returns
numbers of bytes required for the DER encoded signature

Definition at line 220 of file ecs_lib.c.

int ECDSA_verify ( int  type,
const unsigned char *  dgst,
int  dgstlen,
const unsigned char *  sig,
int  siglen,
EC_KEY eckey 
)

Verifies that the given signature is valid ECDSA signature of the supplied hash value using the specified public key.

Parameters
typethis parameter is ignored
dgstpointer to the hash value
dgstlenlength of the hash value
sigpointer to the DER encoded signature
siglenlength of the DER encoded signature
eckeyEC_KEY object containing a public EC key
Returns
1 if the signature is valid, 0 if the signature is invalid and -1 on error

Definition at line 83 of file ecs_vrf.c.

void ERR_load_ECDSA_strings ( void  )

Definition at line 96 of file ecs_err.c.

int i2d_ECDSA_SIG ( const ECDSA_SIG sig,
unsigned char **  pp 
)

DER encode content of ECDSA_SIG object (note: this function modifies *pp (*pp += length of the DER encoded signature)).

Parameters
sigpointer to the ECDSA_SIG object
pppointer to a unsigned char pointer for the output or NULL
Returns
the length of the DER encoded ECDSA_SIG object or 0