Shift right a buffer by "offset" bits, "offset" < 8 */
| 4570 | |
| 4571 | /* Shift right a buffer by "offset" bits, "offset" < 8 */ |
| 4572 | static void |
| 4573 | buffer_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 | |
| 4591 | static int |
| 4592 | test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata) |
no test coverage detected