123456789101112131415161718192021222324252627282930313233 |
- #include <stdint.h>
- #include "ECDHKeypair.h"
- #include"Openssl_crypto.h"
- uint32_t ECDHKeypair::generate_keypair()
- {
- return ecdh_key_gen(public_key, public_key+SGX_ECP256_KEY_SIZE, private_key);
- }
- void ECDHKeypair::get_public_key(uint8_t* op_public_key)
- {
- uint32_t counter;
- for(counter=0 ; counter<ECDH_PUBLIC_KEY_SIZE; counter++)
- op_public_key[counter] = public_key[counter];
- }
- void ECDHKeypair::get_private_key(uint8_t* op_private_key)
- {
- uint32_t counter;
- for(counter=0; counter<ECDH_PRIVATE_KEY_SIZE; counter++)
- op_private_key[counter] = private_key[counter];
- }
- void ECDHKeypair::set_private_public_key(uint8_t* ip_private_key, uint8_t* ip_public_key)
- {
- // TODO: DO SOME CHECKS HERE - TO MAKE SURE THAT IT IS A VALID KEYPAIR
- // IT SHOULD BE AS IT WOULD HAVE BEEN GENERATED BY THIS MODULE AND IF IT HAD BEEN TAMPERED (WHILE BEING SEALED), THEN THE MAC WOULD NOT HAVE WORKED OUT.
- // BUT STILL...
- uint32_t counter;
- for(counter=0; counter<ECDH_PRIVATE_KEY_SIZE; counter++)
- private_key[counter] = ip_private_key[counter];
- for(counter=0 ; counter<ECDH_PUBLIC_KEY_SIZE; counter++)
- public_key[counter] = ip_public_key[counter];
- }
|