crypto.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /***************************************************************************
  2. Copyright (C) Mindtree Consulting Ltd.
  3. This module is a confidential and proprietary property of Mindtree and
  4. a possession or use of this module requires written permission of Mindtree.
  5. ***************************************************************************/
  6. /**
  7. * \file crypto.h
  8. * Contains the Interface definition of Cryptographic functions required by
  9. * the Host Controller Firmware.
  10. *
  11. * \date 2007-05-09
  12. */
  13. #ifndef _CRYPTO_H_
  14. #define _CRYPTO_H_
  15. /* ========================= Include File Section ========================= */
  16. #include "btypes.h"
  17. #ifdef ENABLE_LE_ECDH
  18. /* #define FILE_INPUT */
  19. #define ECPD_ALT_ALG1
  20. #define ECPA_ALT_ALG1
  21. #include "mpal.h"
  22. /* ====================== Macro Declaration Section ======================= */
  23. /* ==================== Data Types Declaration Section ==================== */
  24. /**
  25. * SSP Private Key type. The private key is represented in binary format with
  26. * MSB byte ordering.
  27. */
  28. typedef u8 ssp_prkey_t[DHKEY_LEN];
  29. /**
  30. * SSP Publick Key type. Each coordinate of the public key is represented in
  31. * binary format with MSB byte ordering.
  32. */
  33. typedef struct
  34. {
  35. u8 x[DHKEY_LEN]; /**< X coordinate (Format(MSB): 23..0) */
  36. u8 y[DHKEY_LEN]; /**< Y coordinate (Format(MSB): 47..DHKEY_LEN) */
  37. } ssp_pukey_t;
  38. /**
  39. * SSP Diffie-Hellman Key (generated shared key) type. The dhkey is
  40. * represented in binary format with MSB byte ordering.
  41. */
  42. typedef u8 ssp_dhkey_t[DHKEY_LEN];
  43. /* ================ Exported Variables Declaration Section ================ */
  44. /* ============================= Macros Section ============================== */
  45. #ifdef CRYPTO_STANDALONE_ECDH
  46. /**
  47. * The ECDH algorithm will be used in standalone configuration (in Windows
  48. * builds) . So, there should be no references to /platform/<platform_name>
  49. * APIs.
  50. * This define should be enabled for Windows builds, and should not be enabled
  51. * for other platforms.
  52. */
  53. /* Return 32-bit value here. */
  54. #define CRYPTO_GET_RNG_SEED() 0xDEADC0DE
  55. #else /* CRYPTO_STANDALONE_ECDH */
  56. #define CRYPTO_GET_RNG_SEED pf_get_rng_seed
  57. #endif /* CRYPTO_STANDALONE_ECDH */
  58. /* ============================= API Section ============================== */
  59. void ssp_init(void);
  60. void ssp_shutdown(void);
  61. #ifdef ECDH_TIME_SLICE
  62. #ifdef CRYPTO_TEST_FRAMEWORK
  63. u8 ssp_get_ecdh_keypair(const ssp_prkey_t* priv, OUT ssp_pukey_t* pub);
  64. #else
  65. u8 ssp_get_ecdh_keypair(OUT ssp_prkey_t* priv, OUT ssp_pukey_t* pub);
  66. #endif
  67. u8 ssp_get_dhkey(ssp_prkey_t* priv, ssp_pukey_t* pub,
  68. OUT ssp_dhkey_t* dhkey);
  69. #else
  70. #ifdef CRYPTO_TEST_FRAMEWORK
  71. u8 ssp_get_ecdh_keypair(const ssp_prkey_t* priv, OUT ssp_pukey_t* pub);
  72. #else
  73. u8 ssp_get_ecdh_keypair(OUT ssp_prkey_t* priv, OUT ssp_pukey_t* pub);
  74. #endif
  75. u8 ssp_get_dhkey(ssp_prkey_t* priv, ssp_pukey_t* pub,
  76. OUT ssp_dhkey_t* dhkey);
  77. #endif
  78. #endif /* ENABLE_LE_ECDH */
  79. #endif /* _CRYPTO_H_ */