1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
| #include "rtw_crypto_wrap.h"
|
| #ifndef DEBUG_CRYPTO
| #define DEBUG_CRYPTO 0
| #endif /* DEBUG_CRYTO */
|
| int os_memcmp(const void *s1, const void *s2, size_t n)
| {
| return _rtw_memcmp2(s1, s2, n);
| }
|
| int os_memcmp_const(const void *a, const void *b, size_t len)
| {
| const u8 *aa = a;
| const u8 *bb = b;
| size_t i;
| u8 res;
|
| for (res = 0, i = 0; i < len; i++)
| res |= aa[i] ^ bb[i];
|
| return res;
| }
|
| void* os_memdup(const void *src, u32 sz)
| {
| void *r = rtw_malloc(sz);
|
| if (r && src)
| _rtw_memcpy(r, src, sz);
| return r;
| }
|
| size_t os_strlen(const char *s)
| {
| const char *p = s;
| while (*p)
| p++;
| return p - s;
| }
|
|
| void forced_memzero(void *ptr, size_t len)
| {
| _rtw_memset(ptr, 0, len);
| }
|
| void bin_clear_free(void *bin, size_t len)
| {
| if (bin) {
| forced_memzero(bin, len);
| rtw_mfree(bin, len);
| }
| }
|
| void wpa_printf(int level, const char *fmt, ...)
| {
| #if DEBUG_CRYPTO
| #define MSG_LEN 100
| va_list args;
| u8 buf[MSG_LEN] = { 0 };
| int err;
|
| va_start(args, fmt);
| err = vsnprintf(buf, MSG_LEN, fmt, args);
| va_end(args);
|
| RTW_INFO("%s", buf);
| #undef MSG_LEN
| #endif /* DEBUG_CRYPTO */
| }
|
| void wpa_hexdump(int level, const char *title, const void *buf, size_t len)
| {
| #if DEBUG_CRYPTO
| RTW_INFO_DUMP((u8 *)title, buf, len);
| #endif /* DEBUG_CRYPTO */
| }
|
| void wpa_hexdump_key(int level, const char *title, const void *buf, size_t len)
| {
| #if DEBUG_CRYPTO
| RTW_INFO_DUMP((u8 *)title, buf, len);
| #endif /* DEBUG_CRYPTO */
| }
|
|