Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Feature Forums
  3. - Uncategorised posts -
  4. ECDH using OpenSSL

ECDH using OpenSSL

Scheduled Pinned Locked Moved - Uncategorised posts -
help
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 12841021
    wrote on last edited by
    #1

    Can anyone help me with the Ecdh openssl command prompt code for generating shared secret. I have used this, but i got error message openssl pkeyutl -derive -inkey musicpriv.pem -peerkey pubeckey.pem -out sharedsecret.bin | openssl dgst -sha256

    J 1 Reply Last reply
    0
    • U User 12841021

      Can anyone help me with the Ecdh openssl command prompt code for generating shared secret. I have used this, but i got error message openssl pkeyutl -derive -inkey musicpriv.pem -peerkey pubeckey.pem -out sharedsecret.bin | openssl dgst -sha256

      J Offline
      J Offline
      Jochen Arndt
      wrote on last edited by
      #2

      When having such problems it is always helpful to show the error message. First step is reading the manual page for the commands and understand what they are doing: pkeyutl(1): public key algorithm utility - Linux man page[^] dgst(1): message digests - Linux man page[^]. You can read them also at a shell prompt by entering man pkeyutl resp. man dgst. You should also know about shell commands (piping in your case). The pipe operator | sends the standard output of the first command to the standard input of the second. So a first check might be executing the first command only to see if the error occurs there. You are writing the result of the first command to a file (option -out sharedsecret.bin). So the output on screen are just error or success messages. Passing these to another program using the pipe operator makes usually no sense. So a possible solution might be omitting the output to file for the first command (untested):

      openssl pkeyutl -derive -inkey musicpriv.pem -peerkey pubeckey.pem | openssl dgst -sha256

      Another solution might be using the created file as input for the second command:

      openssl pkeyutl -derive -inkey musicpriv.pem -peerkey pubeckey.pem -out sharedsecret.bin && openssl dgst -sha256 sharedsecret.bin

      Note the usage of the && operator here. It is a shell command concatenation where the second command is only executed when the first was successful.

      U 1 Reply Last reply
      0
      • J Jochen Arndt

        When having such problems it is always helpful to show the error message. First step is reading the manual page for the commands and understand what they are doing: pkeyutl(1): public key algorithm utility - Linux man page[^] dgst(1): message digests - Linux man page[^]. You can read them also at a shell prompt by entering man pkeyutl resp. man dgst. You should also know about shell commands (piping in your case). The pipe operator | sends the standard output of the first command to the standard input of the second. So a first check might be executing the first command only to see if the error occurs there. You are writing the result of the first command to a file (option -out sharedsecret.bin). So the output on screen are just error or success messages. Passing these to another program using the pipe operator makes usually no sense. So a possible solution might be omitting the output to file for the first command (untested):

        openssl pkeyutl -derive -inkey musicpriv.pem -peerkey pubeckey.pem | openssl dgst -sha256

        Another solution might be using the created file as input for the second command:

        openssl pkeyutl -derive -inkey musicpriv.pem -peerkey pubeckey.pem -out sharedsecret.bin && openssl dgst -sha256 sharedsecret.bin

        Note the usage of the && operator here. It is a shell command concatenation where the second command is only executed when the first was successful.

        U Offline
        U Offline
        User 12841021
        wrote on last edited by
        #3

        Hi Jochen for the response, I use windows (not linux) and I have read through the manual page on "www.openssl.org" but i dont quite understand the basic uses of the "pkeyutl command" This was command line used and the error message I got when I used it openssl pkeyutl -derive -inkey musicpriv.pem -peerkey pubeckey.pem -out sharedsecret.bin | openssl dgst -sha256 Error Message = openssl:Error: 'pkeyutl' is an invalid command. NB: Though an hash value was generated, but not as specified. Thank you again for your great help.

        J 1 Reply Last reply
        0
        • U User 12841021

          Hi Jochen for the response, I use windows (not linux) and I have read through the manual page on "www.openssl.org" but i dont quite understand the basic uses of the "pkeyutl command" This was command line used and the error message I got when I used it openssl pkeyutl -derive -inkey musicpriv.pem -peerkey pubeckey.pem -out sharedsecret.bin | openssl dgst -sha256 Error Message = openssl:Error: 'pkeyutl' is an invalid command. NB: Though an hash value was generated, but not as specified. Thank you again for your great help.

          J Offline
          J Offline
          Jochen Arndt
          wrote on last edited by
          #4

          What I have said about piping and command concatenation applies also to the Windows command interpreter. So you should follow my advice about using piping or files, but not mixing them. However, your actual problem is not related to that but occurs before. It looks like your openssl.exe does not support the pkeyutl command. To check this you can list the available commands:

          openssl list-standard-commands

          All I can suggest is to check your Windows OpenSSL installation and try to ask where you got it from. BTW: There is no -peerkey option for the pkeyutl command (OpenSSL 1.0.1f on Ubuntu 14.04):

          joe@raspi-cross:~$ openssl pkeyutl -help
          Usage: pkeyutl [options]
          -in file input file
          -out file output file
          -sigfile file signature file (verify operation only)
          -inkey file input key
          -keyform arg private key format - default PEM
          -pubin input is a public key
          -certin input is a certificate carrying a public key
          -pkeyopt X:Y public key options
          -sign sign with private key
          -verify verify with public key
          -verifyrecover verify with public key, recover original data
          -encrypt encrypt with public key
          -decrypt decrypt with private key
          -derive derive shared secret
          -hexdump hex dump output
          -engine e use engine e, possibly a hardware device.
          -passin arg pass phrase source

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups