ECDSASignatureBox.cpp 1.0 KB

1234567891011121314151617181920212223242526272829
  1. #include "Openssl_crypto.h"
  2. class ECDSASignatureBox : public ECDHKeypair {
  3. public:
  4. void get_keypair(uint8_t* output_keypair);
  5. uint32_t sign(uint8_t* signature_data, uint32_t signature_data_length, uint8_t* signature)
  6. {
  7. return compute_ecdsa_signature(signature_data, signature_data_length, private_key, signature);
  8. }
  9. void get_keypair(uint8_t* output_keypair)
  10. {
  11. // TODO: What happens if the ECDH keypair's generate keypair hasnt been set.
  12. uint32_t counter;
  13. for(counter=0; counter<ECDH_PRIVATE_KEY_SIZE; counter++)
  14. *(output_keypair + counter) = *(private_key + counter);
  15. for(counter=0; counter<ECDH_PUBLIC_KEY_SIZE; counter++)
  16. *(output_keypair + counter) = *(public_key + counter);
  17. }
  18. void set_keypair(uint8_t* input_keypair)
  19. {
  20. uint32_t counter;
  21. for(counter=0; counter<ECDH_PRIVATE_KEY_SIZE; counter++)
  22. *(private_key + counter) = *(input_keypair + counter);
  23. for(counter=0; counter<ECDH_PUBLIC_KEY_SIZE; counter++)
  24. *(public_key + counter) = *(input_keypair + counter);
  25. }
  26. }