I'm writing reliable UDP implementation and I want it to be secure. Also, I want to make use of elliptic curve cryptography. I don't have the proper education to really understand the math behind this kind of cryptography, but I understand how to use it (at least in general).
Given the next preconditions, is this algorithm secure? What steps can be skipped without compromising security?
(opt.) Is it ok for parties to use a single ECDSA key pair for all interactions in a long period of time? I mean do not change this key pair at all and use it to sign any messages.
Preconditions
- Interaction is going between two parties
A
andB
- Both
A
andB
have predefined ECDSA key pair - Digital signature also works like a hash
Algorithm
A
computes and sends toB
her epheremal ECDH public keyB
computes the shared epheremal ECDH secret and hashes it with SHA-256, using the keyA
sent her in step 1B
randomly generates 256-bit static encryption keyB
encrypts her ECDSA public key and the static encryption key from step 3 using the epheremal secret from step 2 with AES-256 algorithmB
signs the result from step 4 with her ECDSA private keyB
sends toA
the result from step 4 alongside with the signature from step 5 and her epheremal ECDH public keyA
also computes the shared epheremal ECDH secret and hashes it with SHA-256, using the keyB
sent her in step 6A
decrypts the result from step 4 using epheremal key from step 7 with AES-256 algorithmA
checks the signatureB
sent her in step 6 usingB
's ECDSA public key she received in step 8- If something goes wrong (the signature is invalid or step 8 lead to corrupted data),
A
gives up - At this point,
A
has everything she needs to send messages securely
- If something goes wrong (the signature is invalid or step 8 lead to corrupted data),
A
signs and encrypts her ECDSA public key using AES-256 algorithm with the static encryption key she received in step 8A
can also sign and encrypt some payload in this step
A
sends toB
the result from step 11 with the signatureB
decrypts the ciphertextA
sent her using AES-256 algorithm and checks the signature- If here something goes wrong,
B
gives up
- If here something goes wrong,
- Now both
A
andB
know ECDSA public keys of each other and the shared encryption key, so they can interact securely and be sure nobody can modify their messages