2
$\begingroup$

I am using FIPS based OpenSSL module for encryption of sensitive data for my desktop socket server and client applications. I am using ECDH for key agreement.The keys public and private pair is generated for server and client on same curve NID_secp521r1. Now I want to exchange the public key between client and server and has following questions.

The generated private key is same for both client and server is it true? Client send its public key first or Server? The public key should be send plain or it should be signed? If signed then what will be the mechanism? I want to reuse my public/private key on server where I store that keys in application exe? PEM file? Any other options?

$\endgroup$
2
  • 2
    $\begingroup$ "generated private key" - does this mean the agreed key (by successful execution of Diffie-Hellman) or does this mean the private key-part of the DH exchange? And is the question about TLS? (especially the second and third one) $\endgroup$
    – SEJPM
    Commented Sep 2, 2015 at 12:07
  • 1
    $\begingroup$ You don't want to implement this yourself. You should rather check how to establish a TLS connection using OpenSSL. $\endgroup$
    – mephisto
    Commented Sep 2, 2015 at 13:39

1 Answer 1

1
$\begingroup$

The generated private key is same for both client and server is it true?

No, that's not true. The key pairs and thus the private keys will be different. They will only be the same if the random number generator creates 521 identical bits for both the server and the client when the key pairs are generated.

Client send its public key first or Server?

That doesn't matter, whatever is more efficient.

The public key should be send plain or it should be signed?

Plain will do, if you perform authentication afterwards. TLS signs and verifies all the packets send, after the key agreement. You do need to check if the public key represents a valid point on the curve though.

If signed then what will be the mechanism?

Depends on the protocol. Anything that can perform signing or MAC authentication really.

I want to reuse my public/private key on server where I store that keys in application exe?

Whereever they are most secure. If you use them in software then for OpenSSL the PKCS#12 format probably makes the most sense. It doesn't matter if the PKCS#12 key store is stored as PEM or DER format.


Unless you need an ultra lightweight protocol using TLS itself makes an awful lot of sense. If you really must design your own protocol, then first learn and understand TLS.

$\endgroup$
1
  • 1
    $\begingroup$ Caveat: OpenSSL provides both DER and PEM I/O routines for many of its data structures, but only DER for PKCS#12. It's not very hard to do PEM yourself, just base64 with (linebreaks and) flag lines, but it is some work. $\endgroup$ Commented Sep 6, 2015 at 16:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.