ssh lib
wolfcrypt/misc.h@1:e4ea39eba2fb, 2019-11-25 (annotated)
- Committer:
- sPymbed
- Date:
- Mon Nov 25 14:23:49 2019 +0000
- Revision:
- 1:e4ea39eba2fb
- Parent:
- 0:1387ff3eed4a
improved
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sPymbed | 0:1387ff3eed4a | 1 | /* misc.h |
sPymbed | 0:1387ff3eed4a | 2 | * |
sPymbed | 0:1387ff3eed4a | 3 | * Copyright (C) 2006-2017 wolfSSL Inc. |
sPymbed | 0:1387ff3eed4a | 4 | * |
sPymbed | 0:1387ff3eed4a | 5 | * This file is part of wolfSSL. |
sPymbed | 0:1387ff3eed4a | 6 | * |
sPymbed | 0:1387ff3eed4a | 7 | * wolfSSL is free software; you can redistribute it and/or modify |
sPymbed | 0:1387ff3eed4a | 8 | * it under the terms of the GNU General Public License as published by |
sPymbed | 0:1387ff3eed4a | 9 | * the Free Software Foundation; either version 2 of the License, or |
sPymbed | 0:1387ff3eed4a | 10 | * (at your option) any later version. |
sPymbed | 0:1387ff3eed4a | 11 | * |
sPymbed | 0:1387ff3eed4a | 12 | * wolfSSL is distributed in the hope that it will be useful, |
sPymbed | 0:1387ff3eed4a | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
sPymbed | 0:1387ff3eed4a | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
sPymbed | 0:1387ff3eed4a | 15 | * GNU General Public License for more details. |
sPymbed | 0:1387ff3eed4a | 16 | * |
sPymbed | 0:1387ff3eed4a | 17 | * You should have received a copy of the GNU General Public License |
sPymbed | 0:1387ff3eed4a | 18 | * along with this program; if not, write to the Free Software |
sPymbed | 0:1387ff3eed4a | 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA |
sPymbed | 0:1387ff3eed4a | 20 | */ |
sPymbed | 0:1387ff3eed4a | 21 | |
sPymbed | 0:1387ff3eed4a | 22 | |
sPymbed | 0:1387ff3eed4a | 23 | |
sPymbed | 0:1387ff3eed4a | 24 | #ifndef WOLF_CRYPT_MISC_H |
sPymbed | 0:1387ff3eed4a | 25 | #define WOLF_CRYPT_MISC_H |
sPymbed | 0:1387ff3eed4a | 26 | |
sPymbed | 0:1387ff3eed4a | 27 | |
sPymbed | 0:1387ff3eed4a | 28 | #include <wolfcrypt/types.h> |
sPymbed | 0:1387ff3eed4a | 29 | |
sPymbed | 0:1387ff3eed4a | 30 | |
sPymbed | 0:1387ff3eed4a | 31 | #ifdef __cplusplus |
sPymbed | 0:1387ff3eed4a | 32 | extern "C" { |
sPymbed | 0:1387ff3eed4a | 33 | #endif |
sPymbed | 0:1387ff3eed4a | 34 | |
sPymbed | 0:1387ff3eed4a | 35 | |
sPymbed | 0:1387ff3eed4a | 36 | #ifdef NO_INLINE |
sPymbed | 0:1387ff3eed4a | 37 | WOLFSSL_LOCAL |
sPymbed | 0:1387ff3eed4a | 38 | word32 rotlFixed(word32, word32); |
sPymbed | 0:1387ff3eed4a | 39 | WOLFSSL_LOCAL |
sPymbed | 0:1387ff3eed4a | 40 | word32 rotrFixed(word32, word32); |
sPymbed | 0:1387ff3eed4a | 41 | |
sPymbed | 0:1387ff3eed4a | 42 | WOLFSSL_LOCAL |
sPymbed | 0:1387ff3eed4a | 43 | word32 ByteReverseWord32(word32); |
sPymbed | 0:1387ff3eed4a | 44 | WOLFSSL_LOCAL |
sPymbed | 0:1387ff3eed4a | 45 | void ByteReverseWords(word32*, const word32*, word32); |
sPymbed | 0:1387ff3eed4a | 46 | |
sPymbed | 0:1387ff3eed4a | 47 | WOLFSSL_LOCAL |
sPymbed | 0:1387ff3eed4a | 48 | void XorWords(wolfssl_word*, const wolfssl_word*, word32); |
sPymbed | 0:1387ff3eed4a | 49 | WOLFSSL_LOCAL |
sPymbed | 0:1387ff3eed4a | 50 | void xorbuf(void*, const void*, word32); |
sPymbed | 0:1387ff3eed4a | 51 | |
sPymbed | 0:1387ff3eed4a | 52 | WOLFSSL_LOCAL |
sPymbed | 0:1387ff3eed4a | 53 | void ForceZero(const void*, word32); |
sPymbed | 0:1387ff3eed4a | 54 | |
sPymbed | 0:1387ff3eed4a | 55 | WOLFSSL_LOCAL |
sPymbed | 0:1387ff3eed4a | 56 | int ConstantCompare(const byte*, const byte*, int); |
sPymbed | 0:1387ff3eed4a | 57 | |
sPymbed | 0:1387ff3eed4a | 58 | #ifdef WORD64_AVAILABLE |
sPymbed | 0:1387ff3eed4a | 59 | WOLFSSL_LOCAL |
sPymbed | 0:1387ff3eed4a | 60 | word64 rotlFixed64(word64, word64); |
sPymbed | 0:1387ff3eed4a | 61 | WOLFSSL_LOCAL |
sPymbed | 0:1387ff3eed4a | 62 | word64 rotrFixed64(word64, word64); |
sPymbed | 0:1387ff3eed4a | 63 | |
sPymbed | 0:1387ff3eed4a | 64 | WOLFSSL_LOCAL |
sPymbed | 0:1387ff3eed4a | 65 | word64 ByteReverseWord64(word64); |
sPymbed | 0:1387ff3eed4a | 66 | WOLFSSL_LOCAL |
sPymbed | 0:1387ff3eed4a | 67 | void ByteReverseWords64(word64*, const word64*, word32); |
sPymbed | 0:1387ff3eed4a | 68 | #endif /* WORD64_AVAILABLE */ |
sPymbed | 0:1387ff3eed4a | 69 | |
sPymbed | 0:1387ff3eed4a | 70 | #ifndef WOLFSSL_HAVE_MIN |
sPymbed | 0:1387ff3eed4a | 71 | #if defined(HAVE_FIPS) && !defined(min) /* so ifdef check passes */ |
sPymbed | 0:1387ff3eed4a | 72 | #define min min |
sPymbed | 0:1387ff3eed4a | 73 | #endif |
sPymbed | 0:1387ff3eed4a | 74 | WOLFSSL_LOCAL word32 min(word32 a, word32 b); |
sPymbed | 0:1387ff3eed4a | 75 | #endif |
sPymbed | 0:1387ff3eed4a | 76 | |
sPymbed | 0:1387ff3eed4a | 77 | #ifndef WOLFSSL_HAVE_MAX |
sPymbed | 0:1387ff3eed4a | 78 | #if defined(HAVE_FIPS) && !defined(max) /* so ifdef check passes */ |
sPymbed | 0:1387ff3eed4a | 79 | #define max max |
sPymbed | 0:1387ff3eed4a | 80 | #endif |
sPymbed | 0:1387ff3eed4a | 81 | WOLFSSL_LOCAL word32 max(word32 a, word32 b); |
sPymbed | 0:1387ff3eed4a | 82 | #endif /* WOLFSSL_HAVE_MAX */ |
sPymbed | 0:1387ff3eed4a | 83 | |
sPymbed | 0:1387ff3eed4a | 84 | |
sPymbed | 0:1387ff3eed4a | 85 | void c32to24(word32 in, word24 out); |
sPymbed | 0:1387ff3eed4a | 86 | void c16toa(word16 u16, byte* c); |
sPymbed | 0:1387ff3eed4a | 87 | void c32toa(word32 u32, byte* c); |
sPymbed | 0:1387ff3eed4a | 88 | void c24to32(const word24 u24, word32* u32); |
sPymbed | 0:1387ff3eed4a | 89 | void ato16(const byte* c, word16* u16); |
sPymbed | 0:1387ff3eed4a | 90 | void ato24(const byte* c, word32* u24); |
sPymbed | 0:1387ff3eed4a | 91 | void ato32(const byte* c, word32* u32); |
sPymbed | 0:1387ff3eed4a | 92 | word32 btoi(byte b); |
sPymbed | 0:1387ff3eed4a | 93 | |
sPymbed | 0:1387ff3eed4a | 94 | |
sPymbed | 0:1387ff3eed4a | 95 | WOLFSSL_LOCAL byte ctMaskGT(int a, int b); |
sPymbed | 0:1387ff3eed4a | 96 | WOLFSSL_LOCAL byte ctMaskGTE(int a, int b); |
sPymbed | 0:1387ff3eed4a | 97 | WOLFSSL_LOCAL byte ctMaskLT(int a, int b); |
sPymbed | 0:1387ff3eed4a | 98 | WOLFSSL_LOCAL byte ctMaskLTE(int a, int b); |
sPymbed | 0:1387ff3eed4a | 99 | WOLFSSL_LOCAL byte ctMaskEq(int a, int b); |
sPymbed | 0:1387ff3eed4a | 100 | WOLFSSL_LOCAL byte ctMaskSel(byte m, byte a, byte b); |
sPymbed | 0:1387ff3eed4a | 101 | WOLFSSL_LOCAL byte ctSetLTE(int a, int b); |
sPymbed | 0:1387ff3eed4a | 102 | |
sPymbed | 0:1387ff3eed4a | 103 | #endif /* NO_INLINE */ |
sPymbed | 0:1387ff3eed4a | 104 | |
sPymbed | 0:1387ff3eed4a | 105 | |
sPymbed | 0:1387ff3eed4a | 106 | #ifdef __cplusplus |
sPymbed | 0:1387ff3eed4a | 107 | } /* extern "C" */ |
sPymbed | 0:1387ff3eed4a | 108 | #endif |
sPymbed | 0:1387ff3eed4a | 109 | |
sPymbed | 0:1387ff3eed4a | 110 | |
sPymbed | 0:1387ff3eed4a | 111 | #endif /* WOLF_CRYPT_MISC_H */ |
sPymbed | 0:1387ff3eed4a | 112 | |
sPymbed | 0:1387ff3eed4a | 113 |