wolfcaam_seco.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /* wolfcaam_seco.h
  2. *
  3. * Copyright (C) 2006-2023 wolfSSL Inc.
  4. *
  5. * This file is part of wolfSSL.
  6. *
  7. * wolfSSL is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * wolfSSL 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
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
  20. */
  21. /* This file is for interacting with the driver code */
  22. #ifndef WOLFCAAM_SECO_H
  23. #define WOLFCAAM_SECO_H
  24. #include <wolfssl/wolfcrypt/types.h>
  25. #ifdef WOLFSSL_SECO_CAAM
  26. /* unique devId for SECO use on crypto callbacks */
  27. #ifndef WOLFSSL_SECO_DEVID
  28. #define WOLFSSL_SECO_DEVID 8
  29. #endif
  30. #define Error int
  31. #define Value int
  32. #define Boolean int
  33. #define Success 1
  34. #define Failure 0
  35. #define INTERRUPT_Panic() WC_DO_NOTHING
  36. #define MemoryMapMayNotBeEmpty -1
  37. #define CAAM_WAITING -2
  38. #define NoActivityReady -1
  39. #define MemoryOperationNotPerformed -1
  40. #include <stdint.h>
  41. #define CAAM_ADDRESS intptr_t
  42. #ifndef WOLFSSL_CAAM_BUFFER
  43. #define WOLFSSL_CAAM_BUFFER
  44. typedef struct CAAM_BUFFER {
  45. int BufferType;
  46. CAAM_ADDRESS TheAddress;
  47. int Length;
  48. } CAAM_BUFFER;
  49. #endif
  50. #define DataBuffer 0
  51. #define LastBuffer 0
  52. #define Success 1
  53. #include <wolfssl/wolfcrypt/port/caam/wolfcaam_x25519.h>
  54. #include <wolfssl/wolfcrypt/port/caam/wolfcaam_ecdsa.h>
  55. #include <wolfssl/wolfcrypt/port/caam/wolfcaam_cmac.h>
  56. #include <wolfssl/wolfcrypt/port/caam/wolfcaam_aes.h>
  57. #include <wolfssl/wolfcrypt/port/caam/wolfcaam_rsa.h>
  58. #include <wolfssl/wolfcrypt/port/caam/wolfcaam_hash.h>
  59. #include <wolfssl/wolfcrypt/cryptocb.h>
  60. #define ResourceNotAvailable -3
  61. #define CAAM_WAITING -2
  62. /* key stays after key store is closed */
  63. #define CAAM_KEY_PERSISTENT 0
  64. /* key is deleted when key store is closed */
  65. #define CAAM_KEY_TRANSIENT 1
  66. /* key is used as a key encryption key */
  67. #define CAAM_KEY_KEK 2
  68. /* list of key types available */
  69. #define CAAM_KEYTYPE_ECDSA_P256 0
  70. #define CAAM_KEYTYPE_ECDSA_P384 1
  71. #define CAAM_KEYTYPE_ECDSA_P521 2
  72. #define CAAM_KEYTYPE_AES128 3
  73. #define CAAM_KEYTYPE_AES192 4
  74. #define CAAM_KEYTYPE_AES256 5
  75. #define CAAM_KEYTYPE_HMAC224 6
  76. #define CAAM_KEYTYPE_HMAC256 7
  77. #define CAAM_KEYTYPE_HMAC384 8
  78. #define CAAM_KEYTYPE_HMAC512 9
  79. /* flags for key management */
  80. #define CAAM_UPDATE_KEY 1
  81. #define CAAM_GENERATE_KEY 2
  82. #define CAAM_DELETE_KEY 4
  83. /* flags for key store open */
  84. #define CAAM_KEYSTORE_CREATE 1
  85. #define CAAM_KEYSTORE_UPDATE 0
  86. #define MAX_GROUP 1023
  87. WOLFSSL_LOCAL int SynchronousSendRequest(int type, unsigned int args[4],
  88. CAAM_BUFFER *buf, int sz);
  89. WOLFSSL_LOCAL int wc_SECOInitInterface(void);
  90. WOLFSSL_LOCAL void wc_SECOFreeInterface(void);
  91. WOLFSSL_API int wc_SECO_OpenHSM(word32 keyId, word32 nonce, word16 maxUpdates,
  92. byte flag);
  93. WOLFSSL_API int wc_SECO_CloseHSM(void);
  94. WOLFSSL_API int wc_SECO_GenerateKey(int flags, int group, byte* out, int outSz,
  95. int keyType, int keyInfo, unsigned int* keyIdOut);
  96. WOLFSSL_API int wc_SECO_DeleteKey(unsigned int keyId, int group, int keyTypeIn);
  97. #if defined(WOLFSSL_CMAC)
  98. WOLFSSL_API void wc_SECO_CMACSetKeyID(Cmac* cmac, int keyId);
  99. WOLFSSL_API int wc_SECO_CMACGetKeyID(Cmac* cmac);
  100. #endif
  101. WOLFSSL_API void wc_SECO_AesSetKeyID(Aes* aes, int keyId);
  102. WOLFSSL_API int wc_SECO_AesGetKeyID(Aes* aes);
  103. WOLFSSL_LOCAL int wc_SECO_ExportKEK(byte* out, byte outSz, byte isCommon);
  104. WOLFSSL_API word32 wc_SECO_WrapKey(word32 keyID, byte* in, word32 inSz,
  105. byte* iv, word32 ivSz, int keyType, int keyInfo, int group);
  106. #define CAAM_SEND_REQUEST(type, sz, arg, buf) \
  107. SynchronousSendRequest((type), (arg), (buf), (sz))
  108. #define CAAM_INIT_INTERFACE wc_SECOInitInterface
  109. #define CAAM_FREE_INTERFACE wc_SECOFreeInterface
  110. #endif
  111. #endif /* WOLFCAAM_SECO_H */