MCPcopy Create free account
hub / github.com/F-Stack/f-stack / buffer_shift_right

Function buffer_shift_right

dpdk/app/test/test_cryptodev.c:4572–4589  ·  view source on GitHub ↗

Shift right a buffer by "offset" bits, "offset" < 8 */

Source from the content-addressed store, hash-verified

4570
4571/* Shift right a buffer by "offset" bits, "offset" < 8 */
4572static void
4573buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4574{
4575 uint8_t curr_byte, prev_byte;
4576 uint32_t length_in_bytes = ceil_byte_length(length + offset);
4577 uint8_t lower_byte_mask = (1 << offset) - 1;
4578 unsigned i;
4579
4580 prev_byte = buffer[0];
4581 buffer[0] >>= offset;
4582
4583 for (i = 1; i < length_in_bytes; i++) {
4584 curr_byte = buffer[i];
4585 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4586 (curr_byte >> offset);
4587 prev_byte = curr_byte;
4588 }
4589}
4590
4591static int
4592test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)

Callers 1

Calls 1

ceil_byte_lengthFunction · 0.85

Tested by

no test coverage detected