Password protect EC private key

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Password protect EC private key

Robert Moskowitz
I am following:
https://jamielinux.com/docs/openssl-certificate-authority/create-the-root-pair.html

But modifying it to produce ECDSA certs.  So the first step is to make
the private key.  Jamie says:

openssl genrsa -aes256 -out private/ca.key.pem 4096

The -aes256 option supposedly password protects this private key. So
after some googling I created:

openssl ecparam -name secp256k1 -genkey -noout -out private/ca.key.pem

But openssl ecparam does not have any option equivalent (that I can
find) to -aes256

What am I missing.

And I successfully generated the root CA ECDSA cert with:

openssl req -config openssl.cnf -key private/ca.key.pem \
       -new -x509 -days 7300 -sha256 -extensions v3_ca -out
certs/ca.cert.pem

The config file is the one Jamie provides on his pages.

Also the following:

openssl ecparam -in private/ca.key.pem -text -noout

Gives me an error:

unable to load elliptic curve parameters
140598030526328:error:0906D06C:PEM routines:PEM_read_bio:no start
line:pem_lib.c:707:Expecting: EC PARAMETERS

Is this because I created the private key without including the
parameters?  I got my ECDSA tips from:

https://wiki.openssl.org/index.php/Command_Line_Elliptic_Curve_Operations

Meanwhile on to the sub-CA cert.

thanks

Bob

--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Password protect EC private key

Viktor Dukhovni
On Thu, Aug 10, 2017 at 12:03:31PM -0400, Robert Moskowitz wrote:

> openssl ecparam -name secp256k1 -genkey -noout -out private/ca.key.pem
>
> But openssl ecparam does not have any option equivalent (that I can find) to -aes256

Yes, this command does not currently support key encryption.

> What am I missing.

The command that does is:

   $  openssl genpkey -aes256 -algorithm ec \
        -pkeyopt ec_paramgen_curve:secp256k1 \
        -pkeyopt ec_param_enc:named_curve \
        -out private/ca.key.pem

Are you sure you want secp256k1?  By far the more common choice is
prime256r1 (aka P-256 or secp256r1).

> openssl ecparam -in private/ca.key.pem -text -noout

EC keys are read with "openssl ec" not "openssl ecparam".

--
        Viktor.
--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Password protect EC private key

Robert Moskowitz
Thank you, Viktor.

On 08/10/2017 02:27 PM, Viktor Dukhovni wrote:

> On Thu, Aug 10, 2017 at 12:03:31PM -0400, Robert Moskowitz wrote:
>
>> openssl ecparam -name secp256k1 -genkey -noout -out private/ca.key.pem
>>
>> But openssl ecparam does not have any option equivalent (that I can find) to -aes256
> Yes, this command does not currently support key encryption.
>
>> What am I missing.
> The command that does is:
>
>     $  openssl genpkey -aes256 -algorithm ec \
> -pkeyopt ec_paramgen_curve:secp256k1 \
> -pkeyopt ec_param_enc:named_curve \
> -out private/ca.key.pem

So I see that I use this for the CA(s) key generation, but what about a
Server or Client key pair to feed into a CSR?  I probably do not want
those keys encrypted (well I do, but we sacrifice protection for easy of
use, sigh).


> Are you sure you want secp256k1?  By far the more common choice is
> prime256r1 (aka P-256 or secp256r1).

Thanks, I read things wrong and selected the wrong curve.  Yes, I want
prime256r1.

>
>> openssl ecparam -in private/ca.key.pem -text -noout
> EC keys are read with "openssl ec" not "openssl ecparam".
>

Ah.  I will give this a try.

Bob

--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Password protect EC private key

Viktor Dukhovni
On Thu, Aug 10, 2017 at 02:49:02PM -0400, Robert Moskowitz wrote:

> > The command that does is:
> >
> >     $  openssl genpkey -aes256 -algorithm ec \
> > -pkeyopt ec_paramgen_curve:secp256k1 \
> > -pkeyopt ec_param_enc:named_curve \
> > -out private/ca.key.pem
>
> So I see that I use this for the CA(s) key generation, but what about a
> Server or Client key pair to feed into a CSR?  I probably do not want those
> keys encrypted (well I do, but we sacrifice protection for easy of use,
> sigh).

Just leave off the "-aes256" option.

> > Are you sure you want secp256k1?  By far the more common choice is
> > prime256r1 (aka P-256 or secp256r1).
>
> Thanks, I read things wrong and selected the wrong curve.  Yes, I want
> prime256r1.
>
> > > openssl ecparam -in private/ca.key.pem -text -noout
> > EC keys are read with "openssl ec" not "openssl ecparam".
>
> Ah.  I will give this a try.

Better yet, use "openssl pkey".

--
        Viktor.
--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Password protect EC private key

Robert Moskowitz
In reply to this post by Viktor Dukhovni


On 08/10/2017 02:27 PM, Viktor Dukhovni wrote:

> On Thu, Aug 10, 2017 at 12:03:31PM -0400, Robert Moskowitz wrote:
>
>> openssl ecparam -name secp256k1 -genkey -noout -out private/ca.key.pem
>>
>> But openssl ecparam does not have any option equivalent (that I can find) to -aes256
> Yes, this command does not currently support key encryption.
>
>> What am I missing.
> The command that does is:
>
>     $  openssl genpkey -aes256 -algorithm ec \
> -pkeyopt ec_paramgen_curve:secp256k1 \
> -pkeyopt ec_param_enc:named_curve \
> -out private/ca.key.pem
>
> Are you sure you want secp256k1?  By far the more common choice is
> prime256r1 (aka P-256 or secp256r1).

Do you mean prime256v1?

$ openssl ecparam -list_curves
   secp256k1 : SECG curve over a 256 bit prime field
   secp384r1 : NIST/SECG curve over a 384 bit prime field
   secp521r1 : NIST/SECG curve over a 521 bit prime field
   prime256v1: X9.62/SECG curve over a 256 bit prime field


>
>> openssl ecparam -in private/ca.key.pem -text -noout
> EC keys are read with "openssl ec" not "openssl ecparam".
>

--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Password protect EC private key

Viktor Dukhovni
On Thu, Aug 10, 2017 at 03:17:02PM -0400, Robert Moskowitz wrote:

> > Are you sure you want secp256k1?  By far the more common choice is
> > prime256r1 (aka P-256 or secp256r1).
>
> Do you mean prime256v1?

Yes, it is the primary name in OpenSSL for secp256r1 aka (NIST) P-256.

--
        Viktor.
--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Password protect EC private key

Robert Moskowitz


On 08/10/2017 04:26 PM, Viktor Dukhovni wrote:
> On Thu, Aug 10, 2017 at 03:17:02PM -0400, Robert Moskowitz wrote:
>
>>> Are you sure you want secp256k1?  By far the more common choice is
>>> prime256r1 (aka P-256 or secp256r1).
>> Do you mean prime256v1?
> Yes, it is the primary name in OpenSSL for secp256r1 aka (NIST) P-256.
>
Thank you for the help.  I now have a simple guide and a complement of
files to work on a new project.

Did not do CRL or OCSP, but I don't need them yet.


--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
Loading...