ecdh.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. *
  3. * Embedded Linux library
  4. *
  5. * Copyright (C) 2018 Intel Corporation. All rights reserved.
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  20. *
  21. */
  22. #ifndef __ELL_ECDH_H
  23. #define __ELL_ECDH_H
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. struct l_ecc_curve;
  28. struct l_ecc_point;
  29. struct l_ecc_scalar;
  30. /*
  31. * Generate a private/public key pair. private/public are out parameters and
  32. * must be freed.
  33. */
  34. bool l_ecdh_generate_key_pair(const struct l_ecc_curve *curve,
  35. struct l_ecc_scalar **out_private,
  36. struct l_ecc_point **out_public);
  37. /*
  38. * Generate a shared secret from a private/public key. secret is an out
  39. * parameters and must be freed.
  40. */
  41. bool l_ecdh_generate_shared_secret(const struct l_ecc_scalar *private_key,
  42. const struct l_ecc_point *other_public,
  43. struct l_ecc_scalar **secret);
  44. #ifdef __cplusplus
  45. }
  46. #endif
  47. #endif /* __ELL_ECDH_H */