diff options
author | tb <> | 2024-11-15 20:14:58 +0000 |
---|---|---|
committer | tb <> | 2024-11-15 20:14:58 +0000 |
commit | 6a22cb2662a65fcc708c1076799aebd0596f3747 (patch) | |
tree | bcfb004137eb4851446a14a446c868ca86661cdd /src/lib | |
parent | 00d406aeea0b66f7f4205870c7cef172c459660d (diff) | |
download | openbsd-6a22cb2662a65fcc708c1076799aebd0596f3747.tar.gz openbsd-6a22cb2662a65fcc708c1076799aebd0596f3747.tar.bz2 openbsd-6a22cb2662a65fcc708c1076799aebd0596f3747.zip |
Use a better curve and a better hash for the ECDSA_do_sign() example
(Many examples in this directory are really bad. This is no exception.)
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libcrypto/man/ECDSA_SIG_new.3 | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/lib/libcrypto/man/ECDSA_SIG_new.3 b/src/lib/libcrypto/man/ECDSA_SIG_new.3 index c9ef8e8143..2b72e6f1b9 100644 --- a/src/lib/libcrypto/man/ECDSA_SIG_new.3 +++ b/src/lib/libcrypto/man/ECDSA_SIG_new.3 | |||
@@ -1,4 +1,4 @@ | |||
1 | .\" $OpenBSD: ECDSA_SIG_new.3,v 1.20 2023/08/29 10:07:42 tb Exp $ | 1 | .\" $OpenBSD: ECDSA_SIG_new.3,v 1.21 2024/11/15 20:14:58 tb Exp $ |
2 | .\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100 | 2 | .\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100 |
3 | .\" selective merge up to: OpenSSL da4ea0cf Aug 5 16:13:24 2019 +0100 | 3 | .\" selective merge up to: OpenSSL da4ea0cf Aug 5 16:13:24 2019 +0100 |
4 | .\" | 4 | .\" |
@@ -50,7 +50,7 @@ | |||
50 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 50 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
51 | .\" OF THE POSSIBILITY OF SUCH DAMAGE. | 51 | .\" OF THE POSSIBILITY OF SUCH DAMAGE. |
52 | .\" | 52 | .\" |
53 | .Dd $Mdocdate: August 29 2023 $ | 53 | .Dd $Mdocdate: November 15 2024 $ |
54 | .Dt ECDSA_SIG_NEW 3 | 54 | .Dt ECDSA_SIG_NEW 3 |
55 | .Os | 55 | .Os |
56 | .Sh NAME | 56 | .Sh NAME |
@@ -342,8 +342,8 @@ error. | |||
342 | The error codes can be obtained by | 342 | The error codes can be obtained by |
343 | .Xr ERR_get_error 3 . | 343 | .Xr ERR_get_error 3 . |
344 | .Sh EXAMPLES | 344 | .Sh EXAMPLES |
345 | Creating an ECDSA signature of given SHA-1 hash value using the named | 345 | Creating an ECDSA signature of given SHA-384 hash value using the named |
346 | curve secp192k1. | 346 | curve secp384r1. |
347 | .Pp | 347 | .Pp |
348 | First step: create an | 348 | First step: create an |
349 | .Vt EC_KEY | 349 | .Vt EC_KEY |
@@ -356,7 +356,7 @@ int ret; | |||
356 | ECDSA_SIG *sig; | 356 | ECDSA_SIG *sig; |
357 | EC_KEY *eckey; | 357 | EC_KEY *eckey; |
358 | 358 | ||
359 | eckey = EC_KEY_new_by_curve_name(NID_secp192k1); | 359 | eckey = EC_KEY_new_by_curve_name(NID_secp384r1); |
360 | if (eckey == NULL) { | 360 | if (eckey == NULL) { |
361 | /* error */ | 361 | /* error */ |
362 | } | 362 | } |
@@ -365,10 +365,10 @@ if (!EC_KEY_generate_key(eckey)) { | |||
365 | } | 365 | } |
366 | .Ed | 366 | .Ed |
367 | .Pp | 367 | .Pp |
368 | Second step: compute the ECDSA signature of a SHA-1 hash value using | 368 | Second step: compute the ECDSA signature of a SHA-384 hash value using |
369 | .Fn ECDSA_do_sign | 369 | .Fn ECDSA_do_sign |
370 | .Bd -literal -offset indent | 370 | .Bd -literal -offset indent |
371 | sig = ECDSA_do_sign(digest, 20, eckey); | 371 | sig = ECDSA_do_sign(digest, SHA384_DIGEST_LENGTH, eckey); |
372 | if (sig == NULL) { | 372 | if (sig == NULL) { |
373 | /* error */ | 373 | /* error */ |
374 | } | 374 | } |
@@ -391,12 +391,12 @@ if (!ECDSA_sign(0, dgst, dgstlen, pp, &buf_len, eckey) { | |||
391 | Third step: verify the created ECDSA signature using | 391 | Third step: verify the created ECDSA signature using |
392 | .Fn ECDSA_do_verify | 392 | .Fn ECDSA_do_verify |
393 | .Pp | 393 | .Pp |
394 | .Dl ret = ECDSA_do_verify(digest, 20, sig, eckey); | 394 | .Dl ret = ECDSA_do_verify(digest, SHA384_DIGEST_LENGTH, sig, eckey); |
395 | .Pp | 395 | .Pp |
396 | or using | 396 | or using |
397 | .Fn ECDSA_verify | 397 | .Fn ECDSA_verify |
398 | .Pp | 398 | .Pp |
399 | .Dl ret = ECDSA_verify(0, digest, 20, buffer, buf_len, eckey); | 399 | .Dl ret = ECDSA_verify(0, digest, SHA384_DIGEST_LENGTH, buffer, buf_len, eckey); |
400 | .Pp | 400 | .Pp |
401 | and finally evaluate the return value: | 401 | and finally evaluate the return value: |
402 | .Bd -literal -offset indent | 402 | .Bd -literal -offset indent |