platform_util.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /**
  2. * \file platform_util.h
  3. *
  4. * \brief Common and shared functions used by multiple modules in the Mbed TLS
  5. * library.
  6. */
  7. /*
  8. * Copyright (C) 2018, Arm Limited, All Rights Reserved
  9. * SPDX-License-Identifier: Apache-2.0
  10. *
  11. * Licensed under the Apache License, Version 2.0 (the "License"); you may
  12. * not use this file except in compliance with the License.
  13. * You may obtain a copy of the License at
  14. *
  15. * http://www.apache.org/licenses/LICENSE-2.0
  16. *
  17. * Unless required by applicable law or agreed to in writing, software
  18. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  19. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  20. * See the License for the specific language governing permissions and
  21. * limitations under the License.
  22. *
  23. * This file is part of Mbed TLS (https://tls.mbed.org)
  24. */
  25. #ifndef MBEDTLS_PLATFORM_UTIL_H
  26. #define MBEDTLS_PLATFORM_UTIL_H
  27. #include <stddef.h>
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. /**
  32. * \brief Securely zeroize a buffer
  33. *
  34. * The function is meant to wipe the data contained in a buffer so
  35. * that it can no longer be recovered even if the program memory
  36. * is later compromised. Call this function on sensitive data
  37. * stored on the stack before returning from a function, and on
  38. * sensitive data stored on the heap before freeing the heap
  39. * object.
  40. *
  41. * It is extremely difficult to guarantee that calls to
  42. * mbedtls_platform_zeroize() are not removed by aggressive
  43. * compiler optimizations in a portable way. For this reason, Mbed
  44. * TLS provides the configuration option
  45. * MBEDTLS_PLATFORM_ZEROIZE_ALT, which allows users to configure
  46. * mbedtls_platform_zeroize() to use a suitable implementation for
  47. * their platform and needs
  48. *
  49. * \param buf Buffer to be zeroized
  50. * \param len Length of the buffer in bytes
  51. *
  52. */
  53. void mbedtls_platform_zeroize( void *buf, size_t len );
  54. #ifdef __cplusplus
  55. }
  56. #endif
  57. #endif /* MBEDTLS_PLATFORM_UTIL_H */