/src/libspdm/os_stub/memlib/compare_mem.c
Line | Count | Source |
1 | | /** |
2 | | * Copyright Notice: |
3 | | * Copyright 2021-2022 DMTF. All rights reserved. |
4 | | * License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md |
5 | | **/ |
6 | | |
7 | | #include "base.h" |
8 | | |
9 | | bool libspdm_consttime_is_mem_equal(const void *destination_buffer, |
10 | | const void *source_buffer, size_t length) |
11 | 472k | { |
12 | 472k | const volatile uint8_t *pointer_dst; |
13 | 472k | const volatile uint8_t *pointer_src; |
14 | 472k | uint8_t delta; |
15 | | |
16 | 472k | pointer_dst = (const uint8_t *)destination_buffer; |
17 | 472k | pointer_src = (const uint8_t *)source_buffer; |
18 | 472k | delta = 0; |
19 | 4.83M | while ((length-- != 0)) { |
20 | 4.35M | delta |= *(pointer_dst++) ^ *(pointer_src++); |
21 | 4.35M | } |
22 | | |
23 | 472k | return ((delta == 0) ? true : false); |
24 | 472k | } |