Sortix cross-nightly manual
This manual documents Sortix cross-nightly. You can instead view this document in the latest official manual.
NAME
ECDSA_SIG_new, ECDSA_SIG_free, ECDSA_SIG_get0, ECDSA_SIG_get0_r, ECDSA_SIG_get0_s, ECDSA_SIG_set0, i2d_ECDSA_SIG, d2i_ECDSA_SIG, ECDSA_size, ECDSA_sign, ECDSA_verify, ECDSA_do_sign, ECDSA_do_verify — Elliptic Curve Digital Signature AlgorithmSYNOPSIS
#include <openssl/ec.h>ECDSA_SIG_new(void);
ECDSA_SIG_free(ECDSA_SIG *sig);
ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **r, const BIGNUM **s);
ECDSA_SIG_get0_r(const ECDSA_SIG *sig);
ECDSA_SIG_get0_s(const ECDSA_SIG *sig);
ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s);
i2d_ECDSA_SIG(const ECDSA_SIG *sig_in, unsigned char **der_out);
d2i_ECDSA_SIG(ECDSA_SIG **sig_out, const unsigned char **der_in, long len);
ECDSA_size(const EC_KEY *eckey);
ECDSA_sign(int type, const unsigned char *dgst, int dgstlen, unsigned char *sig, unsigned int *siglen, EC_KEY *eckey);
ECDSA_verify(int type, const unsigned char *dgst, int dgstlen, const unsigned char *sig, int siglen, EC_KEY *eckey);
ECDSA_do_sign(const unsigned char *dgst, int dgst_len, EC_KEY *eckey);
ECDSA_do_verify(const unsigned char *dgst, int dgst_len, const ECDSA_SIG *sig, EC_KEY* eckey);
DESCRIPTION
These functions provide a low level interface to ECDSA. Most applications should use the higher level EVP interface such as EVP_DigestSignInit(3) or EVP_DigestVerifyInit(3) instead. Creation of the required EC_KEY objects is described in EC_KEY_new(3).struct { BIGNUM *r; BIGNUM *s; } ECDSA_SIG;
RETURN VALUES
ECDSA_SIG_new() returns the new ECDSA_SIG object or NULL if an error occurs.EXAMPLES
Creating an ECDSA signature of given SHA-1 hash value using the named curve secp192k1.int ret; ECDSA_SIG *sig; EC_KEY *eckey; eckey = EC_KEY_new_by_curve_name(NID_secp192k1); if (eckey == NULL) { /* error */ } if (!EC_KEY_generate_key(eckey)) { /* error */ }
sig = ECDSA_do_sign(digest, 20, eckey); if (sig == NULL) { /* error */ }
unsigned char *buffer, *pp; int buf_len; buf_len = ECDSA_size(eckey); buffer = malloc(buf_len); pp = buffer; if (!ECDSA_sign(0, dgst, dgstlen, pp, &buf_len, eckey) { /* error */ }
ret = ECDSA_do_verify(digest, 20, sig, eckey);
ret = ECDSA_verify(0, digest, 20, buffer, buf_len, eckey);
if (ret == -1) { /* error */ } else if (ret == 0) { /* incorrect signature */ } else { /* ret == 1 */ /* signature ok */ }