1 /*
2    Copyright (c) 2021 Fraunhofer AISEC. See the COPYRIGHT
3    file at the top-level directory of this distribution.
4 
5    Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6    http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7    <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8    option. This file may not be copied, modified, or distributed
9    except according to those terms.
10 */
11 #ifndef MEMCPY_S_H
12 #define MEMCPY_S_H
13 
14 #include <stdint.h>
15 
16 #include "oscore_edhoc_error.h"
17 
18 /**
19  * @brief			Checks if a buffer has sufficient size.
20  *
21  * @param is_size 		The actual size of the buffer in bytes.
22  * @param required_size 	The required size in bytes.
23  * @return 			Ok or error code.
24  */
25 enum err check_buffer_size(uint32_t is_size, uint32_t required_size);
26 
27 /**
28  * @brief			A save memcpy function equivalent to memcpy_s
29  * 				(see [1]). memcpy_s may not be available in some
30  * 				environments thus we provide our own
31  * 				implementation.
32  *
33  * @param[out] dest 		Destination buffer.
34  * @param dest_len 		Length of the destination buffer.
35  * @param[in] source 		Source buffer.
36  * @param source_len 		Length of the source buffer.
37  * @return 			Ok or error code.
38  *
39  * [1]: https://docs.microsoft.com/de-de/cpp/c-runtime-library/reference/memcpy-s-wmemcpy-s?view=msvc-160
40  */
41 enum err _memcpy_s(uint8_t *dest, uint32_t dest_len, const uint8_t *source,
42 		   uint32_t source_len);
43 
44 #endif
45