[openssl-commits] [openssl] master update

Dr. Stephen Henson steve at openssl.org
Sat Feb 21 01:18:51 UTC 2015


The branch master has been updated
       via  146ca72cca3ab668d6bcb45b2a7f71bd9a8d06bb (commit)
       via  86f300d38540ead85543aee0cb30c32145931744 (commit)
      from  f37879d07783a78cda66fd80eaae687dadc7269f (commit)


- Log -----------------------------------------------------------------
commit 146ca72cca3ab668d6bcb45b2a7f71bd9a8d06bb
Author: Dr. Stephen Henson <steve at openssl.org>
Date:   Thu Feb 19 14:35:43 2015 +0000

    Add additional EC documentation.
    
    Reviewed-by: Matt Caswell <matt at openssl.org>

commit 86f300d38540ead85543aee0cb30c32145931744
Author: Dr. Stephen Henson <steve at openssl.org>
Date:   Thu Feb 19 14:32:44 2015 +0000

    Use named curve parameter encoding by default.
    
    Many applications require named curve parameter encoding instead of explicit
    parameter encoding (including the TLS library in OpenSSL itself). Set this
    encoding by default instead of requiring an explicit call to set it.
    
    Add OPENSSL_EC_EXPLICT_CURVE define.
    Reviewed-by: Matt Caswell <matt at openssl.org>

-----------------------------------------------------------------------

Summary of changes:
 crypto/ec/ec.h                   |    3 ++-
 crypto/ec/ec_lib.c               |    2 +-
 doc/apps/genpkey.pod             |   35 ++++++++++++++++++++++++++++++-----
 doc/crypto/EC_GROUP_copy.pod     |   16 ++++++++++++----
 doc/crypto/EVP_PKEY_CTX_ctrl.pod |   24 ++++++++++++++++++------
 5 files changed, 63 insertions(+), 17 deletions(-)

diff --git a/crypto/ec/ec.h b/crypto/ec/ec.h
index b89add6..2d36dd5 100644
--- a/crypto/ec/ec.h
+++ b/crypto/ec/ec.h
@@ -715,7 +715,8 @@ int EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1,
                                    unsigned int *k2, unsigned int *k3);
 # endif
 
-# define OPENSSL_EC_NAMED_CURVE  0x001
+# define OPENSSL_EC_EXPLICIT_CURVE  0x000
+# define OPENSSL_EC_NAMED_CURVE     0x001
 
 typedef struct ecpk_parameters_st ECPKPARAMETERS;
 
diff --git a/crypto/ec/ec_lib.c b/crypto/ec/ec_lib.c
index cc3dd35..2dcdb40 100644
--- a/crypto/ec/ec_lib.c
+++ b/crypto/ec/ec_lib.c
@@ -106,7 +106,7 @@ EC_GROUP *EC_GROUP_new(const EC_METHOD *meth)
         goto err;
 
     ret->curve_name = 0;
-    ret->asn1_flag = 0;
+    ret->asn1_flag = OPENSSL_EC_NAMED_CURVE;
     ret->asn1_form = POINT_CONVERSION_UNCOMPRESSED;
 
     ret->seed = NULL;
diff --git a/doc/apps/genpkey.pod b/doc/apps/genpkey.pod
index 929edcd..74faba5 100644
--- a/doc/apps/genpkey.pod
+++ b/doc/apps/genpkey.pod
@@ -29,7 +29,7 @@ The B<genpkey> command generates a private key.
 =item B<-out filename>
 
 the output filename. If this argument is not specified then standard output is
-used.  
+used.
 
 =item B<-outform DER|PEM>
 
@@ -141,11 +141,21 @@ and 2048 bit group with 256 bit subgroup as mentioned in RFC5114 sections
 
 =head1 EC PARAMETER GENERATION OPTIONS
 
+In OpenSSL 1.0.2 and later the EC parameter generation options below can also
+be supplied as EC key generation options. This can (for example) generate a
+key from a named curve without the need to use an explicit parameter file.
+
 =over 4
 
 =item B<ec_paramgen_curve:curve>
 
-the EC curve to use.
+the EC curve to use. OpenSSL 1.0.2 and later supports NIST curve names
+such as "P-256".
+
+=item B<ec_param_enc:encoding>
+
+the encoding to use for parameters. The "encoding" paramater must be either
+"named_curve" or "explicit".
 
 =back
 
@@ -190,7 +200,7 @@ can be used.
 
 Generate an RSA private key using default parameters:
 
- openssl genpkey -algorithm RSA -out key.pem 
+ openssl genpkey -algorithm RSA -out key.pem
 
 Encrypt output private key using 128 bit AES and the passphrase "hello":
 
@@ -208,7 +218,7 @@ Generate 1024 bit DSA parameters:
 
 Generate DSA key from parameters:
 
- openssl genpkey -paramfile dsap.pem -out dsakey.pem 
+ openssl genpkey -paramfile dsap.pem -out dsakey.pem
 
 Generate 1024 bit DH parameters:
 
@@ -221,8 +231,23 @@ Output RFC5114 2048 bit DH parameters with 224 bit subgroup:
 
 Generate DH key from parameters:
 
- openssl genpkey -paramfile dhp.pem -out dhkey.pem 
+ openssl genpkey -paramfile dhp.pem -out dhkey.pem
+
+Generate EC parameters:
+
+ openssl genpkey -genparam -algorithm EC -out ecp.pem \
+	-pkeyopt ec_paramgen_curve:secp384r1 \
+	-pkeyopt ec_param_enc:named_curve
+
+Generate EC key from parameters:
+
+ openssl genpkey -paramfile ecp.pem -out eckey.pem
+
+Generate EC key directly (OpenSSL 1.0.2+ only):
 
+ openssl genpkey -algorithm EC -out eckey.pem \
+	-pkeyopt ec_paramgen_curve:P-384 \
+	-pkeyopt ec_param_enc:named_curve
 
 =cut
 
diff --git a/doc/crypto/EC_GROUP_copy.pod b/doc/crypto/EC_GROUP_copy.pod
index 954af46..d8fb3dd 100644
--- a/doc/crypto/EC_GROUP_copy.pod
+++ b/doc/crypto/EC_GROUP_copy.pod
@@ -69,10 +69,18 @@ The functions EC_GROUP_set_curve_name and EC_GROUP_get_curve_name, set and get t
 (see L<EC_GROUP_new(3)|EC_GROUP_new(3)>). If a curve does not have a NID associated with it, then EC_GROUP_get_curve_name
 will return 0.
 
-The asn1_flag value on a curve is used to determine whether there is a specific ASN1 OID to describe the curve or not.
-If the asn1_flag is 1 then this is a named curve with an associated ASN1 OID. If not then asn1_flag is 0. The functions
-EC_GROUP_get_asn1_flag and EC_GROUP_set_asn1_flag get and set the status of the asn1_flag for the curve. If set then
-the curve_name must also be set.
+The asn1_flag value is used to determine whether the curve encoding uses
+explicit parameters or a named curve using an ASN1 OID: many applications only
+support the latter form. If asn1_flag is B<OPENSSL_EC_NAMED_CURVE> then the
+named curve form is used and the parameters must have a corresponding
+named curve NID set. If asn1_flags is B<OPENSSL_EC_EXPLICIT_CURVE> the
+parameters are explicitly encoded. The functions EC_GROUP_get_asn1_flag and
+EC_GROUP_set_asn1_flag get and set the status of the asn1_flag for the curve.
+Note: B<OPENSSL_EC_EXPLICIT_CURVE> was first added to OpenSSL 1.1.0, for
+previous versions of OpenSSL the value 0 must be used instead. Before OpenSSL
+1.1.0 the default form was to use explicit parameters (meaning that
+applications would have to explicitly set the named curve form) in OpenSSL
+1.1.0 and later the named curve form is the default.
 
 The point_coversion_form for a curve controls how EC_POINT data is encoded as ASN1 as defined in X9.62 (ECDSA).
 point_conversion_form_t is an enum defined as follows: 
diff --git a/doc/crypto/EVP_PKEY_CTX_ctrl.pod b/doc/crypto/EVP_PKEY_CTX_ctrl.pod
index 2367ae6..6866a6f 100644
--- a/doc/crypto/EVP_PKEY_CTX_ctrl.pod
+++ b/doc/crypto/EVP_PKEY_CTX_ctrl.pod
@@ -8,7 +8,8 @@ EVP_PKEY_CTX_set_rsa_pss_saltlen, EVP_PKEY_CTX_set_rsa_rsa_keygen_bits,
 EVP_PKEY_CTX_set_rsa_keygen_pubexp, EVP_PKEY_CTX_set_dsa_paramgen_bits,
 EVP_PKEY_CTX_set_dh_paramgen_prime_len,
 EVP_PKEY_CTX_set_dh_paramgen_generator,
-EVP_PKEY_CTX_set_ec_paramgen_curve_nid - algorithm specific control operations
+EVP_PKEY_CTX_set_ec_paramgen_curve_nid,
+EVP_PKEY_CTX_set_ec_param_enc - algorithm specific control operations
 
 =head1 SYNOPSIS
 
@@ -37,6 +38,7 @@ EVP_PKEY_CTX_set_ec_paramgen_curve_nid - algorithm specific control operations
 
  #include <openssl/ec.h>
  int EVP_PKEY_CTX_set_ec_paramgen_curve_nid(EVP_PKEY_CTX *ctx, int nid);
+ int EVP_PKEY_CTX_set_ec_param_enc(EVP_PKEY_CTX *ctx, int param_enc);
 
 =head1 DESCRIPTION
 
@@ -66,7 +68,7 @@ The macro EVP_PKEY_CTX_set_rsa_padding() sets the RSA padding mode for B<ctx>.
 The B<pad> parameter can take the value RSA_PKCS1_PADDING for PKCS#1 padding,
 RSA_SSLV23_PADDING for SSLv23 padding, RSA_NO_PADDING for no padding,
 RSA_PKCS1_OAEP_PADDING for OAEP padding (encrypt and decrypt only),
-RSA_X931_PADDING for X9.31 padding (signature operations only) and 
+RSA_X931_PADDING for X9.31 padding (signature operations only) and
 RSA_PKCS1_PSS_PADDING (sign and verify only).
 
 Two RSA padding modes behave differently if EVP_PKEY_CTX_set_signature_md()
@@ -91,7 +93,7 @@ RSA key genration to B<bits>. If not specified 1024 bits is used.
 
 The EVP_PKEY_CTX_set_rsa_keygen_pubexp() macro sets the public exponent value
 for RSA key generation to B<pubexp> currently it should be an odd integer. The
-B<pubexp> pointer is used internally by this function so it should not be 
+B<pubexp> pointer is used internally by this function so it should not be
 modified or free after the call. If this macro is not called then 65537 is used.
 
 The macro EVP_PKEY_CTX_set_dsa_paramgen_bits() sets the number of bits used
@@ -106,7 +108,17 @@ for DH parameter generation. If not specified 2 is used.
 
 The EVP_PKEY_CTX_set_ec_paramgen_curve_nid() sets the EC curve for EC parameter
 generation to B<nid>. For EC parameter generation this macro must be called
-or an error occurs because there is no default curve.
+or an error occurs because there is no default curve. In OpenSSL 1.0.2 and
+later this function can also be called to set the curve explicitly when
+generating an EC key.
+
+The EVP_PKEY_CTX_set_ec_param_enc() sets the EC parameter encoding to
+B<param_enc> when generating EC parameters or an EC key. The encoding can be
+B<OPENSSL_EC_EXPLICIT_CURVE> for explicit parameters (the default in versions
+of OpenSSL before 1.1.0) or B<OPENSSL_EC_NAMED_CURVE> to use named curve form.
+For maximum compatibility the named curve form should be used. Note: the
+B<OPENSSL_EC_NAMED_CURVE> value was only added to OpenSSL 1.1.0: previous
+versions should use 0 instead.
 
 =head1 RETURN VALUES
 
@@ -122,8 +134,8 @@ L<EVP_PKEY_decrypt(3)|EVP_PKEY_decrypt(3)>,
 L<EVP_PKEY_sign(3)|EVP_PKEY_sign(3)>,
 L<EVP_PKEY_verify(3)|EVP_PKEY_verify(3)>,
 L<EVP_PKEY_verify_recover(3)|EVP_PKEY_verify_recover(3)>,
-L<EVP_PKEY_derive(3)|EVP_PKEY_derive(3)> 
-L<EVP_PKEY_keygen(3)|EVP_PKEY_keygen(3)> 
+L<EVP_PKEY_derive(3)|EVP_PKEY_derive(3)>
+L<EVP_PKEY_keygen(3)|EVP_PKEY_keygen(3)>
 
 =head1 HISTORY
 


More information about the openssl-commits mailing list