ua_securitypolicy_mbedtls_common.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
  2. * See http://creativecommons.org/publicdomain/zero/1.0/ for more information.
  3. *
  4. * Copyright 2019 (c) Fraunhofer IOSB (Author: Julius Pfrommer)
  5. */
  6. #ifndef UA_SECURITYPOLICY_MBEDTLS_COMMON_H_
  7. #define UA_SECURITYPOLICY_MBEDTLS_COMMON_H_
  8. #include <open62541/plugin/securitypolicy.h>
  9. #ifdef UA_ENABLE_ENCRYPTION
  10. #include <mbedtls/md.h>
  11. #include <mbedtls/x509_crt.h>
  12. #include <mbedtls/ctr_drbg.h>
  13. #define UA_SHA1_LENGTH 20
  14. _UA_BEGIN_DECLS
  15. void
  16. swapBuffers(UA_ByteString *const bufA, UA_ByteString *const bufB);
  17. void
  18. mbedtls_hmac(mbedtls_md_context_t *context, const UA_ByteString *key,
  19. const UA_ByteString *in, unsigned char *out);
  20. UA_StatusCode
  21. mbedtls_generateKey(mbedtls_md_context_t *context,
  22. const UA_ByteString *secret, const UA_ByteString *seed,
  23. UA_ByteString *out);
  24. UA_StatusCode
  25. mbedtls_verifySig_sha1(mbedtls_x509_crt *certificate, const UA_ByteString *message,
  26. const UA_ByteString *signature);
  27. UA_StatusCode
  28. mbedtls_sign_sha1(mbedtls_pk_context *localPrivateKey,
  29. mbedtls_ctr_drbg_context *drbgContext,
  30. const UA_ByteString *message,
  31. UA_ByteString *signature);
  32. UA_StatusCode
  33. mbedtls_thumbprint_sha1(const UA_ByteString *certificate,
  34. UA_ByteString *thumbprint);
  35. /* Set the hashing scheme before calling
  36. * E.g. mbedtls_rsa_set_padding(context, MBEDTLS_RSA_PKCS_V21, MBEDTLS_MD_SHA1); */
  37. UA_StatusCode
  38. mbedtls_encrypt_rsaOaep(mbedtls_rsa_context *context,
  39. mbedtls_ctr_drbg_context *drbgContext,
  40. UA_ByteString *data, const size_t plainTextBlockSize);
  41. UA_StatusCode
  42. mbedtls_decrypt_rsaOaep(mbedtls_pk_context *localPrivateKey,
  43. mbedtls_ctr_drbg_context *drbgContext,
  44. UA_ByteString *data);
  45. _UA_END_DECLS
  46. #endif
  47. #endif /* UA_SECURITYPOLICY_MBEDTLS_COMMON_H_ */