HybridEncryptionBox.cpp 706 B

12345678910111213141516
  1. #include <stdint.h>
  2. #include "HybridEncryptionBox.h"
  3. unsigned int long HybridEncryptionBox::initialize_symmetric_key(uint8_t* given_public_key)
  4. {
  5. uint8_t symmetric_key[32]; // underlying crypto was set to return 32 bytes. just trimming it to return 16 instead (so that the same symmetricencryptiobox primitive works for both encryption between enclaves and between decryptor and client
  6. uint8_t private_key[32];
  7. get_private_key(private_key);
  8. unsigned long ret_value= compute_ecdh_shared_key(given_public_key, given_public_key + ECDH_PUBLIC_KEY_SIZE/2, private_key, symmetric_key);
  9. if(ret_value==0)
  10. {
  11. set_symmetric_key(symmetric_key); // JUST SETS 1ST 16 BYTES.
  12. }
  13. return ret_value;
  14. }