openssl/RSA - Using a Public key to decrypt

后端 未结 1 1057
眼角桃花
眼角桃花 2021-02-14 21:06

I\'m looking to secure the software update procedure for a little device I\'m maintaining that runs Linux. I want to generate an md5sum of the update package\'s contents and the

1条回答
  •  北海茫月
    2021-02-14 22:03

    Let's assume you have generated a public and private RSA key using openssl genrsa:

    $ openssl genrsa -out mykey
    Generating RSA private key, 512 bit long modulus
    ...++++++++++++
    ..........++++++++++++
    e is 65537 (0x10001)
    $ openssl rsa -in mykey -pubout -out mykey.pub
    writing RSA key
    

    You can sign something with the private key like this:

    $ md5sum myfile | openssl rsautl -inkey mykey -sign > checksum.signed
    

    You can verify this data using the public key:

    $ openssl rsautl -inkey mykey.pub -pubin -in checksum.signed
    df713741d8e92b15977ccd6e019730a5  myfile
    

    Is this what you're looking for?

    0 讨论(0)
提交回复
热议问题