ECDSA sign using OpenSSL without ASN1 encoding the hash

自闭症网瘾萝莉.ら 提交于 2019-12-06 07:47:33

You can do it with openssl pkeyutl which is a replacement for openssl rsautl that supports ECDSA.

Suppose you want to hash and sign a 'data.txt' file with openssl. At first you need to hash the file:

openssl dgst -sha256 -binary -out data.sha256 data.txt

after you can sign it:

openssl pkeyutl -sign -inkey private.pem -in data.sha256 -out data.sig

However the signature is still in ASN.1 format. To receive r and s values of signature use openssl asn1parse:

openssl asn1parse -inform DER -in data.sig
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!