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
AandB - Both
AandBhave predefined ECDSA key pair - Digital signature also works like a hash
Algorithm
Acomputes and sends toBher epheremal ECDH public keyBcomputes the shared epheremal ECDH secret and hashes it with SHA-256, using the keyAsent her in step 1Brandomly generates 256-bit static encryption keyBencrypts her ECDSA public key and the static encryption key from step 3 using the epheremal secret from step 2 with AES-256 algorithmBsigns the result from step 4 with her ECDSA private keyBsends toAthe result from step 4 alongside with the signature from step 5 and her epheremal ECDH public keyAalso computes the shared epheremal ECDH secret and hashes it with SHA-256, using the keyBsent her in step 6Adecrypts the result from step 4 using epheremal key from step 7 with AES-256 algorithmAchecks the signatureBsent 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),
Agives up - At this point,
Ahas everything she needs to send messages securely
- If something goes wrong (the signature is invalid or step 8 lead to corrupted data),
Asigns and encrypts her ECDSA public key using AES-256 algorithm with the static encryption key she received in step 8Acan also sign and encrypt some payload in this step
Asends toBthe result from step 11 with the signatureBdecrypts the ciphertextAsent her using AES-256 algorithm and checks the signature- If here something goes wrong,
Bgives up
- If here something goes wrong,
- Now both
AandBknow ECDSA public keys of each other and the shared encryption key, so they can interact securely and be sure nobody can modify their messages