ECC公钥eccpubkey的ASN.1编码规则

自己在工作中,需要用到ECC公钥的asn.1编码,ECC公钥的asn.1格式是bit string。

这次碰到了一个bit string的开头是这样的,03 4200 04c5 d21e ......

03是bit string的tag,42是bit string的length,00是bit string的unused bit。

我们知道ecc的公钥是64个字节长,也就是0x40,那么问题出来了,下面那个字节,04是什么呢?

在网上查询资料,没找到,因为pkcs13只是ecc的draft,而且是很简单的说了下,没有涉及到ecc的asn.1格式,

后来几经波折,终于找到了ECC的标准draft,网址是,ECC—draft

看了这个文档后的摘录如下,

ECC的公钥格式是,

SubjectPublicKeyInfo  ::=  SEQUENCE  {
       algorithm         AlgorithmIdentifier,
       subjectPublicKey  BIT STRING
 }

 The subjectPublicKey from SubjectPublicKeyInfo is the ECC public key.
 ECC public keys have the following syntax:
    ECPoint ::= OCTET STRING

这里的OCTET STRING的开头就是从04开始的,

The first octet of the OCTET STRING indicates whether the key
is compressed or uncompressed.  The uncompressed form is
indicated by 0x04 and the compressed form is indicated by
either 0x02 or 0x03。

这下就知道了,04说明是没有压缩的。剩下的0x40个字节就是ECC的公钥point了。

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值