source: azure_iot_hub_f767zi/trunk/wolfssl-4.7.0/wolfssl/wolfcrypt/misc.h@ 464

Last change on this file since 464 was 464, checked in by coas-nagasima, 3 years ago

WolfSSLとAzure IoT SDKを更新

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr;charset=UTF-8
File size: 3.6 KB
Line 
1/* misc.h
2 *
3 * Copyright (C) 2006-2020 wolfSSL Inc.
4 *
5 * This file is part of wolfSSL.
6 *
7 * wolfSSL is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * wolfSSL is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 */
21/*
22
23DESCRIPTION
24This module implements the arithmetic-shift right, left, byte swapping, XOR,
25masking and clearing memory logic.
26
27*/
28#ifndef WOLF_CRYPT_MISC_H
29#define WOLF_CRYPT_MISC_H
30
31
32#include <wolfssl/wolfcrypt/types.h>
33
34
35#ifdef __cplusplus
36 extern "C" {
37#endif
38
39
40#ifdef NO_INLINE
41WOLFSSL_LOCAL
42word32 rotlFixed(word32, word32);
43WOLFSSL_LOCAL
44word32 rotrFixed(word32, word32);
45
46#ifdef WC_RC2
47WOLFSSL_LOCAL
48word16 rotlFixed16(word16, word16);
49WOLFSSL_LOCAL
50word16 rotrFixed16(word16, word16);
51#endif
52
53WOLFSSL_LOCAL
54word32 ByteReverseWord32(word32);
55WOLFSSL_LOCAL
56void ByteReverseWords(word32*, const word32*, word32);
57
58WOLFSSL_LOCAL
59void XorWordsOut(wolfssl_word* r, const wolfssl_word* a, const wolfssl_word* b,
60 word32 n);
61WOLFSSL_LOCAL
62void xorbufout(void*, const void*, const void*, word32);
63WOLFSSL_LOCAL
64void XorWords(wolfssl_word*, const wolfssl_word*, word32);
65WOLFSSL_LOCAL
66void xorbuf(void*, const void*, word32);
67
68WOLFSSL_LOCAL
69void ForceZero(const void*, word32);
70
71WOLFSSL_LOCAL
72int ConstantCompare(const byte*, const byte*, int);
73
74#ifdef WORD64_AVAILABLE
75WOLFSSL_LOCAL
76word64 rotlFixed64(word64, word64);
77WOLFSSL_LOCAL
78word64 rotrFixed64(word64, word64);
79
80WOLFSSL_LOCAL
81word64 ByteReverseWord64(word64);
82WOLFSSL_LOCAL
83void ByteReverseWords64(word64*, const word64*, word32);
84#endif /* WORD64_AVAILABLE */
85
86#ifndef WOLFSSL_HAVE_MIN
87 #if defined(HAVE_FIPS) && !defined(min) /* so ifdef check passes */
88 #define min min
89 #endif
90 WOLFSSL_LOCAL word32 min(word32 a, word32 b);
91#endif
92
93#ifndef WOLFSSL_HAVE_MAX
94 #if defined(HAVE_FIPS) && !defined(max) /* so ifdef check passes */
95 #define max max
96 #endif
97 WOLFSSL_LOCAL word32 max(word32 a, word32 b);
98#endif /* WOLFSSL_HAVE_MAX */
99
100
101void c32to24(word32 in, word24 out);
102void c16toa(word16 u16, byte* c);
103void c32toa(word32 u32, byte* c);
104void c24to32(const word24 u24, word32* u32);
105void ato16(const byte* c, word16* u16);
106void ato24(const byte* c, word32* u24);
107void ato32(const byte* c, word32* u32);
108word32 btoi(byte b);
109
110
111WOLFSSL_LOCAL byte ctMaskGT(int a, int b);
112WOLFSSL_LOCAL byte ctMaskGTE(int a, int b);
113WOLFSSL_LOCAL int ctMaskIntGTE(int a, int b);
114WOLFSSL_LOCAL byte ctMaskLT(int a, int b);
115WOLFSSL_LOCAL byte ctMaskLTE(int a, int b);
116WOLFSSL_LOCAL byte ctMaskEq(int a, int b);
117WOLFSSL_LOCAL word16 ctMask16GT(int a, int b);
118WOLFSSL_LOCAL word16 ctMask16GTE(int a, int b);
119WOLFSSL_LOCAL word16 ctMask16LT(int a, int b);
120WOLFSSL_LOCAL word16 ctMask16LTE(int a, int b);
121WOLFSSL_LOCAL word16 ctMask16Eq(int a, int b);
122WOLFSSL_LOCAL byte ctMaskNotEq(int a, int b);
123WOLFSSL_LOCAL byte ctMaskSel(byte m, byte a, byte b);
124WOLFSSL_LOCAL int ctMaskSelInt(byte m, int a, int b);
125WOLFSSL_LOCAL byte ctSetLTE(int a, int b);
126
127#endif /* NO_INLINE */
128
129
130#ifdef __cplusplus
131 } /* extern "C" */
132#endif
133
134
135#endif /* WOLF_CRYPT_MISC_H */
136
Note: See TracBrowser for help on using the repository browser.