ssh lib

Dependents:   OS

Committer:
sPymbed
Date:
Mon Nov 25 14:23:49 2019 +0000
Revision:
1:e4ea39eba2fb
Parent:
0:1387ff3eed4a
improved

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sPymbed 0:1387ff3eed4a 1 /* sha3.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 #ifndef WOLF_CRYPT_SHA3_H
sPymbed 0:1387ff3eed4a 24 #define WOLF_CRYPT_SHA3_H
sPymbed 0:1387ff3eed4a 25
sPymbed 0:1387ff3eed4a 26 #include <wolfcrypt/types.h>
sPymbed 0:1387ff3eed4a 27
sPymbed 0:1387ff3eed4a 28 #ifdef WOLFSSL_SHA3
sPymbed 0:1387ff3eed4a 29
sPymbed 0:1387ff3eed4a 30 #ifdef HAVE_FIPS
sPymbed 0:1387ff3eed4a 31 /* for fips @wc_fips */
sPymbed 0:1387ff3eed4a 32 #include <wolfcrypt/fips.h>
sPymbed 0:1387ff3eed4a 33 #endif
sPymbed 0:1387ff3eed4a 34
sPymbed 0:1387ff3eed4a 35 #ifdef __cplusplus
sPymbed 0:1387ff3eed4a 36 extern "C" {
sPymbed 0:1387ff3eed4a 37 #endif
sPymbed 0:1387ff3eed4a 38
sPymbed 0:1387ff3eed4a 39 #ifdef WOLFSSL_ASYNC_CRYPT
sPymbed 0:1387ff3eed4a 40 #include <wolfcrypt/async.h>
sPymbed 0:1387ff3eed4a 41 #endif
sPymbed 0:1387ff3eed4a 42
sPymbed 0:1387ff3eed4a 43 /* in bytes */
sPymbed 0:1387ff3eed4a 44 enum {
sPymbed 0:1387ff3eed4a 45 WC_SHA3_224 = WC_HASH_TYPE_SHA3_224,
sPymbed 0:1387ff3eed4a 46 WC_SHA3_224_DIGEST_SIZE = 28,
sPymbed 0:1387ff3eed4a 47 WC_SHA3_224_COUNT = 18,
sPymbed 0:1387ff3eed4a 48
sPymbed 0:1387ff3eed4a 49 WC_SHA3_256 = WC_HASH_TYPE_SHA3_256,
sPymbed 0:1387ff3eed4a 50 WC_SHA3_256_DIGEST_SIZE = 32,
sPymbed 0:1387ff3eed4a 51 WC_SHA3_256_COUNT = 17,
sPymbed 0:1387ff3eed4a 52
sPymbed 0:1387ff3eed4a 53 WC_SHA3_384 = WC_HASH_TYPE_SHA3_384,
sPymbed 0:1387ff3eed4a 54 WC_SHA3_384_DIGEST_SIZE = 48,
sPymbed 0:1387ff3eed4a 55 WC_SHA3_384_COUNT = 13,
sPymbed 0:1387ff3eed4a 56
sPymbed 0:1387ff3eed4a 57 WC_SHA3_512 = WC_HASH_TYPE_SHA3_512,
sPymbed 0:1387ff3eed4a 58 WC_SHA3_512_DIGEST_SIZE = 64,
sPymbed 0:1387ff3eed4a 59 WC_SHA3_512_COUNT = 9,
sPymbed 0:1387ff3eed4a 60
sPymbed 0:1387ff3eed4a 61 #ifndef HAVE_SELFTEST
sPymbed 0:1387ff3eed4a 62 /* These values are used for HMAC, not SHA-3 directly.
sPymbed 0:1387ff3eed4a 63 * They come from from FIPS PUB 202. */
sPymbed 0:1387ff3eed4a 64 WC_SHA3_224_BLOCK_SIZE = 144,
sPymbed 0:1387ff3eed4a 65 WC_SHA3_256_BLOCK_SIZE = 136,
sPymbed 0:1387ff3eed4a 66 WC_SHA3_384_BLOCK_SIZE = 104,
sPymbed 0:1387ff3eed4a 67 WC_SHA3_512_BLOCK_SIZE = 72,
sPymbed 0:1387ff3eed4a 68 #endif
sPymbed 0:1387ff3eed4a 69 };
sPymbed 0:1387ff3eed4a 70
sPymbed 0:1387ff3eed4a 71 #ifndef NO_OLD_WC_NAMES
sPymbed 0:1387ff3eed4a 72 #define SHA3_224 WC_SHA3_224
sPymbed 0:1387ff3eed4a 73 #define SHA3_224_DIGEST_SIZE WC_SHA3_224_DIGEST_SIZE
sPymbed 0:1387ff3eed4a 74 #define SHA3_256 WC_SHA3_256
sPymbed 0:1387ff3eed4a 75 #define SHA3_256_DIGEST_SIZE WC_SHA3_256_DIGEST_SIZE
sPymbed 0:1387ff3eed4a 76 #define SHA3_384 WC_SHA3_384
sPymbed 0:1387ff3eed4a 77 #define SHA3_384_DIGEST_SIZE WC_SHA3_384_DIGEST_SIZE
sPymbed 0:1387ff3eed4a 78 #define SHA3_512 WC_SHA3_512
sPymbed 0:1387ff3eed4a 79 #define SHA3_512_DIGEST_SIZE WC_SHA3_512_DIGEST_SIZE
sPymbed 0:1387ff3eed4a 80 #define Sha3 wc_Sha3
sPymbed 0:1387ff3eed4a 81 #endif
sPymbed 0:1387ff3eed4a 82
sPymbed 0:1387ff3eed4a 83
sPymbed 0:1387ff3eed4a 84 #ifdef WOLFSSL_XILINX_CRYPT
sPymbed 0:1387ff3eed4a 85 #include "wolfcrypt/port/xilinx/xil-sha3.h"
sPymbed 0:1387ff3eed4a 86 #else
sPymbed 0:1387ff3eed4a 87 /* Sha3 digest */
sPymbed 0:1387ff3eed4a 88 typedef struct Sha3 {
sPymbed 0:1387ff3eed4a 89 /* State data that is processed for each block. */
sPymbed 0:1387ff3eed4a 90 word64 s[25];
sPymbed 0:1387ff3eed4a 91 /* Unprocessed message data. */
sPymbed 0:1387ff3eed4a 92 byte t[200];
sPymbed 0:1387ff3eed4a 93 /* Index into unprocessed data to place next message byte. */
sPymbed 0:1387ff3eed4a 94 byte i;
sPymbed 0:1387ff3eed4a 95
sPymbed 0:1387ff3eed4a 96 void* heap;
sPymbed 0:1387ff3eed4a 97
sPymbed 0:1387ff3eed4a 98 #ifdef WOLFSSL_ASYNC_CRYPT
sPymbed 0:1387ff3eed4a 99 WC_ASYNC_DEV asyncDev;
sPymbed 0:1387ff3eed4a 100 #endif /* WOLFSSL_ASYNC_CRYPT */
sPymbed 0:1387ff3eed4a 101 } wc_Sha3;
sPymbed 0:1387ff3eed4a 102 #endif
sPymbed 0:1387ff3eed4a 103
sPymbed 0:1387ff3eed4a 104
sPymbed 0:1387ff3eed4a 105 WOLFSSL_API int wc_InitSha3_224(wc_Sha3*, void*, int);
sPymbed 0:1387ff3eed4a 106 WOLFSSL_API int wc_Sha3_224_Update(wc_Sha3*, const byte*, word32);
sPymbed 0:1387ff3eed4a 107 WOLFSSL_API int wc_Sha3_224_Final(wc_Sha3*, byte*);
sPymbed 0:1387ff3eed4a 108 WOLFSSL_API void wc_Sha3_224_Free(wc_Sha3*);
sPymbed 0:1387ff3eed4a 109 WOLFSSL_API int wc_Sha3_224_GetHash(wc_Sha3*, byte*);
sPymbed 0:1387ff3eed4a 110 WOLFSSL_API int wc_Sha3_224_Copy(wc_Sha3* src, wc_Sha3* dst);
sPymbed 0:1387ff3eed4a 111
sPymbed 0:1387ff3eed4a 112 WOLFSSL_API int wc_InitSha3_256(wc_Sha3*, void*, int);
sPymbed 0:1387ff3eed4a 113 WOLFSSL_API int wc_Sha3_256_Update(wc_Sha3*, const byte*, word32);
sPymbed 0:1387ff3eed4a 114 WOLFSSL_API int wc_Sha3_256_Final(wc_Sha3*, byte*);
sPymbed 0:1387ff3eed4a 115 WOLFSSL_API void wc_Sha3_256_Free(wc_Sha3*);
sPymbed 0:1387ff3eed4a 116 WOLFSSL_API int wc_Sha3_256_GetHash(wc_Sha3*, byte*);
sPymbed 0:1387ff3eed4a 117 WOLFSSL_API int wc_Sha3_256_Copy(wc_Sha3* src, wc_Sha3* dst);
sPymbed 0:1387ff3eed4a 118
sPymbed 0:1387ff3eed4a 119 WOLFSSL_API int wc_InitSha3_384(wc_Sha3*, void*, int);
sPymbed 0:1387ff3eed4a 120 WOLFSSL_API int wc_Sha3_384_Update(wc_Sha3*, const byte*, word32);
sPymbed 0:1387ff3eed4a 121 WOLFSSL_API int wc_Sha3_384_Final(wc_Sha3*, byte*);
sPymbed 0:1387ff3eed4a 122 WOLFSSL_API void wc_Sha3_384_Free(wc_Sha3*);
sPymbed 0:1387ff3eed4a 123 WOLFSSL_API int wc_Sha3_384_GetHash(wc_Sha3*, byte*);
sPymbed 0:1387ff3eed4a 124 WOLFSSL_API int wc_Sha3_384_Copy(wc_Sha3* src, wc_Sha3* dst);
sPymbed 0:1387ff3eed4a 125
sPymbed 0:1387ff3eed4a 126 WOLFSSL_API int wc_InitSha3_512(wc_Sha3*, void*, int);
sPymbed 0:1387ff3eed4a 127 WOLFSSL_API int wc_Sha3_512_Update(wc_Sha3*, const byte*, word32);
sPymbed 0:1387ff3eed4a 128 WOLFSSL_API int wc_Sha3_512_Final(wc_Sha3*, byte*);
sPymbed 0:1387ff3eed4a 129 WOLFSSL_API void wc_Sha3_512_Free(wc_Sha3*);
sPymbed 0:1387ff3eed4a 130 WOLFSSL_API int wc_Sha3_512_GetHash(wc_Sha3*, byte*);
sPymbed 0:1387ff3eed4a 131 WOLFSSL_API int wc_Sha3_512_Copy(wc_Sha3* src, wc_Sha3* dst);
sPymbed 0:1387ff3eed4a 132
sPymbed 0:1387ff3eed4a 133 #ifdef __cplusplus
sPymbed 0:1387ff3eed4a 134 } /* extern "C" */
sPymbed 0:1387ff3eed4a 135 #endif
sPymbed 0:1387ff3eed4a 136
sPymbed 0:1387ff3eed4a 137 #endif /* WOLFSSL_SHA3 */
sPymbed 0:1387ff3eed4a 138 #endif /* WOLF_CRYPT_SHA3_H */
sPymbed 0:1387ff3eed4a 139
sPymbed 0:1387ff3eed4a 140