Fix typo in CONTRIBUTING.md
[openssl.git] / doc / man3 / d2i_RSAPrivateKey.pod
index e7cf3989abe4e740d607bbc05fc88e1036fb7189..08cd2c85e5bd79d50dc757f7e9d5ff4c60e835d7 100644 (file)
@@ -2,12 +2,20 @@
 
 =begin comment
 
-Any deprecated keypair function from d2i_X509.pod are collected in this file.
+Any deprecated keypair/params d2i or i2d functions are collected on this page.
 
 =end comment
 
 =head1 NAME
 
+d2i_DSAPrivateKey,
+d2i_DSAPrivateKey_bio,
+d2i_DSAPrivateKey_fp,
+d2i_DSAPublicKey,
+d2i_DSA_PUBKEY,
+d2i_DSA_PUBKEY_bio,
+d2i_DSA_PUBKEY_fp,
+d2i_DSAparams,
 d2i_RSAPrivateKey,
 d2i_RSAPrivateKey_bio,
 d2i_RSAPrivateKey_fp,
@@ -17,6 +25,16 @@ d2i_RSAPublicKey_fp,
 d2i_RSA_PUBKEY,
 d2i_RSA_PUBKEY_bio,
 d2i_RSA_PUBKEY_fp,
+d2i_DHparams,
+d2i_DHparams_bio,
+d2i_DHparams_fp,
+d2i_ECParameters,
+d2i_ECPrivateKey,
+d2i_ECPrivateKey_bio,
+d2i_ECPrivateKey_fp,
+d2i_EC_PUBKEY,
+d2i_EC_PUBKEY_bio,
+d2i_EC_PUBKEY_fp,
 i2d_RSAPrivateKey,
 i2d_RSAPrivateKey_bio,
 i2d_RSAPrivateKey_fp,
@@ -25,16 +43,34 @@ i2d_RSAPublicKey_bio,
 i2d_RSAPublicKey_fp,
 i2d_RSA_PUBKEY,
 i2d_RSA_PUBKEY_bio,
-i2d_RSA_PUBKEY_fp
+i2d_RSA_PUBKEY_fp,
+i2d_DHparams,
+i2d_DHparams_bio,
+i2d_DHparams_fp,
+i2d_DSAPrivateKey,
+i2d_DSAPrivateKey_bio,
+i2d_DSAPrivateKey_fp,
+i2d_DSAPublicKey,
+i2d_DSA_PUBKEY,
+i2d_DSA_PUBKEY_bio,
+i2d_DSA_PUBKEY_fp,
+i2d_DSAparams,
+i2d_ECParameters,
+i2d_ECPrivateKey,
+i2d_ECPrivateKey_bio,
+i2d_ECPrivateKey_fp,
+i2d_EC_PUBKEY,
+i2d_EC_PUBKEY_bio,
+i2d_EC_PUBKEY_fp
 - DEPRECATED
 
 =head1 SYNOPSIS
 
 =for openssl generic
 
-Deprecated since OpenSSL 3.0, can be hidden entirely by defining
-B<OPENSSL_API_COMPAT> with a suitable version value, see
-L<openssl_user_macros(7)>:
+The following functions have been deprecated since OpenSSL 3.0, and can be
+hidden entirely by defining B<OPENSSL_API_COMPAT> with a suitable version value,
+see L<openssl_user_macros(7)>:
 
  TYPE *d2i_TYPEPrivateKey(TYPE **a, const unsigned char **ppin, long length);
  TYPE *d2i_TYPEPrivateKey_bio(BIO *bp, TYPE **a);
@@ -134,13 +170,13 @@ There are two migration paths:
 =item *
 
 Replace
-b<d2i_I<TYPE>PrivateKey()> with L<d2i_PrivateKey(3)>, 
-b<d2i_I<TYPE>PublicKey()> with L<d2i_PublicKey(3)>, 
-b<d2i_I<TYPE>params()> with L<d2i_KeyParams(3)>, 
-b<d2i_I<TYPE>_PUBKEY()> with L<d2i_PUBKEY(3)>, 
-b<i2d_I<TYPE>PrivateKey()> with L<i2d_PrivateKey(3)>, 
-b<i2d_I<TYPE>PublicKey()> with L<i2d_PublicKey(3)>, 
-b<i2d_I<TYPE>params()> with L<i2d_KeyParams(3)>, 
+b<d2i_I<TYPE>PrivateKey()> with L<d2i_PrivateKey(3)>,
+b<d2i_I<TYPE>PublicKey()> with L<d2i_PublicKey(3)>,
+b<d2i_I<TYPE>params()> with L<d2i_KeyParams(3)>,
+b<d2i_I<TYPE>_PUBKEY()> with L<d2i_PUBKEY(3)>,
+b<i2d_I<TYPE>PrivateKey()> with L<i2d_PrivateKey(3)>,
+b<i2d_I<TYPE>PublicKey()> with L<i2d_PublicKey(3)>,
+b<i2d_I<TYPE>params()> with L<i2d_KeyParams(3)>,
 b<i2d_I<TYPE>_PUBKEY()> with L<i2d_PUBKEY(3)>.
 A caveat is that L<i2d_PrivateKey(3)> may output a DER encoded PKCS#8
 outermost structure instead of the type specific structure, and that
@@ -167,7 +203,7 @@ I<selection> and I<structure> as follows:
 
 =item B<i2d_I<TYPE>PrivateKey>() translates into:
 
- int selection = EVP_PKEY_PRIVATE_KEY;
+ int selection = EVP_PKEY_KEYPAIR;
  const char *structure = "type-specific";
 
 =item B<i2d_I<TYPE>PublicKey>() translates into:
@@ -192,8 +228,8 @@ The following sample code does the rest of the work:
  unsigned char *p = buffer;     /* |buffer| is supplied by the caller */
  size_t len = buffer_size;      /* assumed be the size of |buffer| */
  OSSL_ENCODER_CTX *ctx =
-     OSSL_ENCODER_CTX_new_by_EVP_PKEY(pkey, selection, "DER", structure,
-                                      NULL, NULL);
+     OSSL_ENCODER_CTX_new_for_pkey(pkey, selection, "DER", structure,
+                                   NULL, NULL);
  if (ctx == NULL) {
      /* fatal error handling */
  }
@@ -209,6 +245,45 @@ The following sample code does the rest of the work:
 
 =for comment TODO: a similar section on OSSL_DECODER is to be added
 
+=head1 NOTES
+
+The letters B<i> and B<d> in B<i2d_I<TYPE>>() stand for
+"internal" (that is, an internal C structure) and "DER" respectively.
+So B<i2d_I<TYPE>>() converts from internal to DER.
+
+The functions can also understand B<BER> forms.
+
+The actual TYPE structure passed to B<i2d_I<TYPE>>() must be a valid
+populated B<I<TYPE>> structure -- it B<cannot> simply be fed with an
+empty structure such as that returned by TYPE_new().
+
+The encoded data is in binary form and may contain embedded zeros.
+Therefore, any FILE pointers or BIOs should be opened in binary mode.
+Functions such as strlen() will B<not> return the correct length
+of the encoded structure.
+
+The ways that I<*ppin> and I<*ppout> are incremented after the operation
+can trap the unwary. See the B<WARNINGS> section in L<d2i_X509(3)> for some
+common errors.
+The reason for this-auto increment behaviour is to reflect a typical
+usage of ASN1 functions: after one structure is encoded or decoded
+another will be processed after it.
+
+The following points about the data types might be useful:
+
+=over 4
+
+=item B<DSA_PUBKEY>
+
+Represents a DSA public key using a B<SubjectPublicKeyInfo> structure.
+
+=item B<DSAPublicKey>, B<DSAPrivateKey>
+
+Use a non-standard OpenSSL format and should be avoided; use B<DSA_PUBKEY>,
+L<PEM_write_PrivateKey(3)>, or similar instead.
+
+=back
+
 =head1 RETURN VALUES
 
 B<d2i_I<TYPE>>(), B<d2i_I<TYPE>_bio>() and B<d2i_I<TYPE>_fp>() return a valid
@@ -232,7 +307,7 @@ L<i2d_PUBKEY(3)>
 
 =head1 COPYRIGHT
 
-Copyright 2020 The OpenSSL Project Authors. All Rights Reserved.
+Copyright 2020-2023 The OpenSSL Project Authors. All Rights Reserved.
 
 Licensed under the Apache License 2.0 (the "License").  You may not use
 this file except in compliance with the License.  You can obtain a copy