简体   繁体   English

使用OpenSSL的EC私钥和域参数

[英]EC private key and domain parameters using OpenSSL

First of all, sorry for my ignorance, I'm new at cryptography. 首先,对我的无知感到抱歉,我是密码学的新手。 I'm trying to generate a public key for use with elliptic curves given the private key. 我试图生成给定私钥的椭圆曲线使用的公钥。

So, at the moment I have: 因此,目前我有:

  1. The curve I will be using y^2 = x^3 - ax + b (prime256v1) 曲线我将使用y^2 = x^3 - ax + b (prime256v1)

  2. A .pem file with a private key. 带有私钥的.pem文件。

The first question is, does the private key have to be random? 第一个问题是,私钥是否必须是随机的? I mean, can it be whatever I want? 我的意思是,这可以是我想要的吗?

When I use the OpenSSL command: 当我使用OpenSSL命令时:

openssl ecparam -in private.pem -name prime256v1 -out public.pem

If I do a cat of public.pem I get: 如果我做public.pem的猫,我会得到:

-----BEGIN EC PARAMETERS-----
BggqhkjOPQMBBw==
-----END EC PARAMETERS-----

But there is no public key. 但是没有公钥。

The second question is, does anyone know what I'm doing wrong? 第二个问题是,有人知道我在做什么错吗?

Thanks in advance. 提前致谢。

A .pem file with a private key. 带有私钥的.pem文件。 I have here the first question. 我在这里有第一个问题。 The private key can be random? 私钥可以是随机的吗? I mean, can it be whatever I want? 我的意思是,这可以是我想要的吗?

No. The parameter S of the private key can be random, but the ASN.1 -> DER -> PEM encoded private key - which includes the parameters - can't. 不可以。私钥的参数S可以是随机的,但是ASN.1-> DER-> PEM 编码的私钥(包括参数)不能。

openssl ecparam -in private.pem -name prime256v1 -out public.pem ... But there is no public key, anyone know what I'm doing wrong? openssl ecparam -in private.pem -name prime256v1 -out public.pem ...但是没有公钥,有人知道我在做什么吗?

You need to use the ec command instead, and use -pubout . 您需要改用ec命令,并使用-pubout The .pem that you are currently getting simply contains the name of the curve encoded as OID: 当前获取的.pem仅包含编码为OID的曲线的名称:

echo "BggqhkjOPQMBBw==" | openssl base64 -d | openssl asn1parse -inform DER

result: 结果:

0:d=0  hl=2 l=   8 prim: OBJECT            :prime256v1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM