Noise-C
|
Data Structures | |
struct | NoiseBuffer |
Type that defines a region of memory for a data buffer. More... | |
Macros | |
#define | noise_buffer_init(buffer) ((buffer).data = 0, (buffer).size = 0, (buffer).max_size = 0) |
Initializes all fields of a buffer to zero. More... | |
#define | noise_buffer_set_inout(buffer, ptr, len, max) ((buffer).data = (ptr), (buffer).size = (len), (buffer).max_size = (max)) |
Sets a NoiseBuffer object to point to an input-output memory region. More... | |
#define | noise_buffer_set_input(buffer, ptr, len) ((buffer).data = (ptr), (buffer).size = (buffer).max_size = (len)) |
Sets a NoiseBuffer object to point to an input memory region. More... | |
#define | noise_buffer_set_output(buffer, ptr, len) ((buffer).data = (ptr), (buffer).size = 0, (buffer).max_size = (len)) |
Sets a NoiseBuffer object to point to an output memory region. More... | |
This API defines types and macros to help with managing the passing of buffers to the Noise-C library. NoiseBuffer objects carry their current and maximum sizes around with them wherever they go. The intention is that applications that use NoiseBuffer are less likely to create a buffer overrun situation because the maximum size is always available for checking and never implicit.
struct NoiseBuffer |
#define noise_buffer_init | ( | buffer | ) | ((buffer).data = 0, (buffer).size = 0, (buffer).max_size = 0) |
Initializes all fields of a buffer to zero.
#define noise_buffer_set_inout | ( | buffer, | |
ptr, | |||
len, | |||
max | |||
) | ((buffer).data = (ptr), (buffer).size = (len), (buffer).max_size = (max)) |
Sets a NoiseBuffer object to point to an input-output memory region.
buffer | The NoiseBuffer object to set. |
ptr | Pointer to the start of the memory region for the buffer. |
len | Length of the memory region in bytes on input. |
max | Maximum length of the memory region in bytes. |
This function is intended for use when transforming a region of memory; for example to encrypt or decrypt it. The original size is len and during transformation the region can grow in size to no more than max.
#define noise_buffer_set_input | ( | buffer, | |
ptr, | |||
len | |||
) | ((buffer).data = (ptr), (buffer).size = (buffer).max_size = (len)) |
Sets a NoiseBuffer object to point to an input memory region.
buffer | The NoiseBuffer object to set. |
ptr | Pointer to the start of the memory region for the buffer. |
len | Length of the memory region in bytes. |
The buffer's current and maximum size are both set to len.
This macro is intended for passing an existing region of memory to a Noise-C function. It is typically used for input values.
#define noise_buffer_set_output | ( | buffer, | |
ptr, | |||
len | |||
) | ((buffer).data = (ptr), (buffer).size = 0, (buffer).max_size = (len)) |
Sets a NoiseBuffer object to point to an output memory region.
buffer | The NoiseBuffer object to set. |
ptr | Pointer to the start of the memory region for the buffer. |
len | Length of the memory region in bytes. |
The buffer's current size is set to zero and its maximum size is set to len.
This macro is intended for initializing a region of memory to receive data that was output by a Noise-C function. The maximum size indicates how many bytes can be output into the region before overflow occurs.