Automatically generated by Pod::Man 2.25 (Pod::Simple 3.20)
Standard preamble:
========================================================================
..
.... Set up some character translations and predefined strings. \*(-- will
give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
double quote, and \*(R" will give a right double quote. \*(C+ will
give a nicer C++. Capital omega is used to do unbreakable dashes and
therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
nothing in troff, for use with C<>.
.tr \(*W- . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\}
Escape single quotes in literal strings from groff's Unicode transform.
If the F register is turned on, we'll generate index entries on stderr for
titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
entries marked with X<> in POD. Of course, you'll have to process the
output yourself in some meaningful fashion.
. de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} . de IX .. .\}
Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] .\} . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents . \" corrections for vroff . \" for low resolution devices (crt and lpr) \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} ========================================================================
Title "ecdsa 3"
way too many mistakes in technical documents.
.Vb 5 struct { BIGNUM *r; BIGNUM *s; } ECDSA_SIG; .Ve
\fIECDSA_SIG_new() allocates a new \s-1ECDSA_SIG\s0 structure (note: this function also allocates the BIGNUMs) and initialize it.
\fIECDSA_SIG_free() frees the \s-1ECDSA_SIG\s0 structure sig.
\fIi2d_ECDSA_SIG() creates the \s-1DER\s0 encoding of the \s-1ECDSA\s0 signature \fBsig and writes the encoded signature to *pp (note: if pp is \s-1NULL\s0 i2d_ECDSA_SIG returns the expected length in bytes of the \s-1DER\s0 encoded signature). i2d_ECDSA_SIG returns the length of the \s-1DER\s0 encoded signature (or 0 on error).
\fId2i_ECDSA_SIG() decodes a \s-1DER\s0 encoded \s-1ECDSA\s0 signature and returns the decoded signature in a newly allocated \s-1ECDSA_SIG\s0 structure. \fB*sig points to the buffer containing the \s-1DER\s0 encoded signature of size len.
\fIECDSA_size() returns the maximum length of a \s-1DER\s0 encoded \s-1ECDSA\s0 signature created with the private \s-1EC\s0 key eckey.
\fIECDSA_sign_setup() may be used to precompute parts of the signing operation. eckey is the private \s-1EC\s0 key and ctx is a pointer to \s-1BN_CTX\s0 structure (or \s-1NULL\s0). The precomputed values or returned in kinv and rp and can be used in a later call to ECDSA_sign_ex or ECDSA_do_sign_ex.
\fIECDSA_sign() is wrapper function for ECDSA_sign_ex with kinv and rp set to \s-1NULL\s0.
\fIECDSA_sign_ex() computes a digital signature of the dgstlen bytes hash value dgst using the private \s-1EC\s0 key eckey and the optional pre-computed values kinv and rp. The \s-1DER\s0 encoded signatures is stored in sig and it's length is returned in sig_len. Note: sig must point to ECDSA_size bytes of memory. The parameter type is ignored.
\fIECDSA_verify() verifies that the signature in sig of size \fBsiglen is a valid \s-1ECDSA\s0 signature of the hash value value dgst of size dgstlen using the public key eckey. The parameter type is ignored.
\fIECDSA_do_sign() is wrapper function for ECDSA_do_sign_ex with kinv and rp set to \s-1NULL\s0.
\fIECDSA_do_sign_ex() computes a digital signature of the dgst_len bytes hash value dgst using the private key eckey and the optional pre-computed values kinv and rp. The signature is returned in a newly allocated \s-1ECDSA_SIG\s0 structure (or \s-1NULL\s0 on error).
\fIECDSA_do_verify() verifies that the signature sig is a valid \s-1ECDSA\s0 signature of the hash value dgst of size dgst_len using the public key eckey.
\fIECDSA_sign_setup() and ECDSA_sign() return 1 if successful or 0 on error.
\fIECDSA_verify() and ECDSA_do_verify() return 1 for a valid signature, 0 for an invalid signature and -1 on error. The error codes can be obtained by ERR_get_error\|(3).
First step: create a \s-1EC_KEY\s0 object (note: this part is not \s-1ECDSA\s0 specific)
.Vb 10 int ret; ECDSA_SIG *sig; EC_KEY *eckey = EC_KEY_new(); if (eckey == NULL) { /* error */ } key->group = EC_GROUP_new_by_nid(NID_secp192k1); if (key->group == NULL) { /* error */ } if (!EC_KEY_generate_key(eckey)) { /* error */ } .Ve
Second step: compute the \s-1ECDSA\s0 signature of a \s-1SHA-1\s0 hash value using ECDSA_do_sign
.Vb 5 sig = ECDSA_do_sign(digest, 20, eckey); if (sig == NULL) { /* error */ } .Ve
or using ECDSA_sign
.Vb 9 unsigned char *buffer, *pp; int buf_len; buf_len = ECDSA_size(eckey); buffer = OPENSSL_malloc(buf_len); pp = buffer; if (!ECDSA_sign(0, dgst, dgstlen, pp, &buf_len, eckey); { /* error */ } .Ve
Third step: verify the created \s-1ECDSA\s0 signature using ECDSA_do_verify
.Vb 1 ret = ECDSA_do_verify(digest, 20, sig, eckey); .Ve
or using ECDSA_verify
.Vb 1 ret = ECDSA_verify(0, digest, 20, buffer, buf_len, eckey); .Ve
and finally evaluate the return value:
.Vb 12 if (ret == -1) { /* error */ } else if (ret == 0) { /* incorrect signature */ } else /* ret == 1 */ { /* signature ok */ } .Ve