2
0

EVP_SIGNATURE-ED25519.pod 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. =pod
  2. =head1 NAME
  3. EVP_SIGNATURE-ED25519,
  4. EVP_SIGNATURE-ED448,
  5. Ed25519,
  6. Ed448
  7. - EVP_PKEY Ed25519 and Ed448 support
  8. =head1 DESCRIPTION
  9. The B<Ed25519> and B<Ed448> EVP_PKEY implementation supports key generation,
  10. one-shot digest sign and digest verify using PureEdDSA and B<Ed25519> or B<Ed448>
  11. (see RFC8032). It has associated private and public key formats compatible with
  12. RFC 8410.
  13. =head2 ED25519 and ED448 Signature Parameters
  14. No additional parameters can be set during one-shot signing or verification.
  15. In particular, because PureEdDSA is used, a digest must B<NOT> be specified when
  16. signing or verifying.
  17. See L<EVP_PKEY-X25519(7)> for information related to B<X25519> and B<X448> keys.
  18. The following signature parameters can be retrieved using
  19. EVP_PKEY_CTX_get_params().
  20. =over 4
  21. =item "algorithm-id" (B<OSSL_SIGNATURE_PARAM_ALGORITHM_ID>) <octet string>
  22. The parameters are described in L<provider-signature(7)>.
  23. =back
  24. =head1 NOTES
  25. The PureEdDSA algorithm does not support the streaming mechanism
  26. of other signature algorithms using, for example, EVP_DigestUpdate().
  27. The message to sign or verify must be passed using the one-shot
  28. EVP_DigestSign() and EVP_DigestVerify() functions.
  29. When calling EVP_DigestSignInit() or EVP_DigestVerifyInit(), the
  30. digest I<type> parameter B<MUST> be set to NULL.
  31. Applications wishing to sign certificates (or other structures such as
  32. CRLs or certificate requests) using Ed25519 or Ed448 can either use X509_sign()
  33. or X509_sign_ctx() in the usual way.
  34. Ed25519 or Ed448 private keys can be set directly using
  35. L<EVP_PKEY_new_raw_private_key(3)> or loaded from a PKCS#8 private key file
  36. using L<PEM_read_bio_PrivateKey(3)> (or similar function). Completely new keys
  37. can also be generated (see the example below). Setting a private key also sets
  38. the associated public key.
  39. Ed25519 or Ed448 public keys can be set directly using
  40. L<EVP_PKEY_new_raw_public_key(3)> or loaded from a SubjectPublicKeyInfo
  41. structure in a PEM file using L<PEM_read_bio_PUBKEY(3)> (or similar function).
  42. Ed25519 and Ed448 can be tested with the L<openssl-speed(1)> application
  43. since version 1.1.1.
  44. Valid algorithm names are B<ed25519>, B<ed448> and B<eddsa>. If B<eddsa> is
  45. specified, then both Ed25519 and Ed448 are benchmarked.
  46. =head1 EXAMPLES
  47. To sign a message using a ED25519 or ED448 key:
  48. void do_sign(EVP_PKEY *ed_key, unsigned char *msg, size_t msg_len)
  49. {
  50. size_t sig_len;
  51. unsigned char *sig = NULL;
  52. EVP_MD_CTX *md_ctx = EVP_MD_CTX_new();
  53. EVP_DigestSignInit(md_ctx, NULL, NULL, NULL, ed_key);
  54. /* Calculate the requires size for the signature by passing a NULL buffer */
  55. EVP_DigestSign(md_ctx, NULL, &sig_len, msg, msg_len);
  56. sig = OPENSSL_zalloc(sig_len);
  57. EVP_DigestSign(md_ctx, sig, &sig_len, msg, msg_len);
  58. ...
  59. OPENSSL_free(sig);
  60. EVP_MD_CTX_free(md_ctx);
  61. }
  62. =head1 SEE ALSO
  63. L<EVP_PKEY-X25519(7)>
  64. L<provider-signature(7)>,
  65. L<EVP_DigestSignInit(3)>,
  66. L<EVP_DigestVerifyInit(3)>,
  67. =head1 COPYRIGHT
  68. Copyright 2017-2021 The OpenSSL Project Authors. All Rights Reserved.
  69. Licensed under the Apache License 2.0 (the "License"). You may not use
  70. this file except in compliance with the License. You can obtain a copy
  71. in the file LICENSE in the source distribution or at
  72. L<https://www.openssl.org/source/license.html>.
  73. =cut