wolfSSL 3.11.1 for TLS1.3 beta

Fork of wolfSSL by wolf SSL

Committer:
wolfSSL
Date:
Tue May 30 06:16:19 2017 +0000
Revision:
13:80fb167dafdf
Parent:
11:cee25a834751
wolfSSL 3.11.1: TLS1.3 Beta

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wolfSSL 11:cee25a834751 1 /* sha.h
wolfSSL 11:cee25a834751 2 *
wolfSSL 11:cee25a834751 3 * Copyright (C) 2006-2016 wolfSSL Inc.
wolfSSL 11:cee25a834751 4 *
wolfSSL 11:cee25a834751 5 * This file is part of wolfSSL.
wolfSSL 11:cee25a834751 6 *
wolfSSL 11:cee25a834751 7 * wolfSSL is free software; you can redistribute it and/or modify
wolfSSL 11:cee25a834751 8 * it under the terms of the GNU General Public License as published by
wolfSSL 11:cee25a834751 9 * the Free Software Foundation; either version 2 of the License, or
wolfSSL 11:cee25a834751 10 * (at your option) any later version.
wolfSSL 11:cee25a834751 11 *
wolfSSL 11:cee25a834751 12 * wolfSSL is distributed in the hope that it will be useful,
wolfSSL 11:cee25a834751 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
wolfSSL 11:cee25a834751 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
wolfSSL 11:cee25a834751 15 * GNU General Public License for more details.
wolfSSL 11:cee25a834751 16 *
wolfSSL 11:cee25a834751 17 * You should have received a copy of the GNU General Public License
wolfSSL 11:cee25a834751 18 * along with this program; if not, write to the Free Software
wolfSSL 11:cee25a834751 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
wolfSSL 11:cee25a834751 20 */
wolfSSL 11:cee25a834751 21
wolfSSL 11:cee25a834751 22
wolfSSL 11:cee25a834751 23 #ifndef WOLF_CRYPT_SHA_H
wolfSSL 11:cee25a834751 24 #define WOLF_CRYPT_SHA_H
wolfSSL 11:cee25a834751 25
wolfSSL 11:cee25a834751 26 #include <wolfssl/wolfcrypt/types.h>
wolfSSL 11:cee25a834751 27
wolfSSL 11:cee25a834751 28 #ifndef NO_SHA
wolfSSL 11:cee25a834751 29
wolfSSL 11:cee25a834751 30 #ifdef HAVE_FIPS
wolfSSL 11:cee25a834751 31 /* for fips @wc_fips */
wolfSSL 11:cee25a834751 32 #include <cyassl/ctaocrypt/sha.h>
wolfSSL 11:cee25a834751 33 #endif
wolfSSL 11:cee25a834751 34
wolfSSL 11:cee25a834751 35 #ifdef FREESCALE_LTC_SHA
wolfSSL 11:cee25a834751 36 #include "fsl_ltc.h"
wolfSSL 11:cee25a834751 37 #endif
wolfSSL 11:cee25a834751 38
wolfSSL 11:cee25a834751 39 #ifdef __cplusplus
wolfSSL 11:cee25a834751 40 extern "C" {
wolfSSL 11:cee25a834751 41 #endif
wolfSSL 11:cee25a834751 42
wolfSSL 11:cee25a834751 43 #ifndef HAVE_FIPS /* avoid redefining structs */
wolfSSL 11:cee25a834751 44
wolfSSL 11:cee25a834751 45 #ifdef WOLFSSL_PIC32MZ_HASH
wolfSSL 11:cee25a834751 46 #include "port/pic32/pic32mz-crypt.h"
wolfSSL 11:cee25a834751 47 #endif
wolfSSL 11:cee25a834751 48 #ifdef WOLFSSL_ASYNC_CRYPT
wolfSSL 11:cee25a834751 49 #include <wolfssl/wolfcrypt/async.h>
wolfSSL 11:cee25a834751 50 #endif
wolfSSL 11:cee25a834751 51
wolfSSL 11:cee25a834751 52 /* in bytes */
wolfSSL 11:cee25a834751 53 enum {
wolfSSL 11:cee25a834751 54 #if defined(STM32F2_HASH) || defined(STM32F4_HASH)
wolfSSL 11:cee25a834751 55 SHA_REG_SIZE = 4, /* STM32 register size, bytes */
wolfSSL 11:cee25a834751 56 #endif
wolfSSL 11:cee25a834751 57 SHA = 1, /* hash type unique */
wolfSSL 11:cee25a834751 58 SHA_BLOCK_SIZE = 64,
wolfSSL 11:cee25a834751 59 SHA_DIGEST_SIZE = 20,
wolfSSL 11:cee25a834751 60 SHA_PAD_SIZE = 56
wolfSSL 11:cee25a834751 61 };
wolfSSL 11:cee25a834751 62
wolfSSL 11:cee25a834751 63
wolfSSL 11:cee25a834751 64 #ifndef WOLFSSL_TI_HASH
wolfSSL 11:cee25a834751 65 /* Sha digest */
wolfSSL 11:cee25a834751 66 typedef struct Sha {
wolfSSL 11:cee25a834751 67 #ifdef FREESCALE_LTC_SHA
wolfSSL 11:cee25a834751 68 ltc_hash_ctx_t ctx;
wolfSSL 11:cee25a834751 69 #else
wolfSSL 11:cee25a834751 70 word32 buffLen; /* in bytes */
wolfSSL 11:cee25a834751 71 word32 loLen; /* length in bytes */
wolfSSL 11:cee25a834751 72 word32 hiLen; /* length in bytes */
wolfSSL 11:cee25a834751 73 word32 buffer[SHA_BLOCK_SIZE / sizeof(word32)];
wolfSSL 11:cee25a834751 74 #ifndef WOLFSSL_PIC32MZ_HASH
wolfSSL 11:cee25a834751 75 word32 digest[SHA_DIGEST_SIZE / sizeof(word32)];
wolfSSL 11:cee25a834751 76 #else
wolfSSL 11:cee25a834751 77 word32 digest[PIC32_HASH_SIZE / sizeof(word32)];
wolfSSL 11:cee25a834751 78 #endif
wolfSSL 11:cee25a834751 79 void* heap;
wolfSSL 11:cee25a834751 80 #ifdef WOLFSSL_PIC32MZ_HASH
wolfSSL 11:cee25a834751 81 pic32mz_desc desc; /* Crypt Engine descriptor */
wolfSSL 11:cee25a834751 82 #endif
wolfSSL 11:cee25a834751 83 #ifdef WOLFSSL_ASYNC_CRYPT
wolfSSL 11:cee25a834751 84 WC_ASYNC_DEV asyncDev;
wolfSSL 11:cee25a834751 85 #endif /* WOLFSSL_ASYNC_CRYPT */
wolfSSL 11:cee25a834751 86 #endif /* FREESCALE_LTC_SHA */
wolfSSL 11:cee25a834751 87 } Sha;
wolfSSL 11:cee25a834751 88
wolfSSL 11:cee25a834751 89 #else
wolfSSL 11:cee25a834751 90 #include "wolfssl/wolfcrypt/port/ti/ti-hash.h"
wolfSSL 11:cee25a834751 91 #endif /* WOLFSSL_TI_HASH */
wolfSSL 11:cee25a834751 92
wolfSSL 11:cee25a834751 93
wolfSSL 11:cee25a834751 94 #endif /* HAVE_FIPS */
wolfSSL 11:cee25a834751 95
wolfSSL 11:cee25a834751 96 WOLFSSL_API int wc_InitSha(Sha*);
wolfSSL 11:cee25a834751 97 WOLFSSL_API int wc_InitSha_ex(Sha* sha, void* heap, int devId);
wolfSSL 11:cee25a834751 98 WOLFSSL_API int wc_ShaUpdate(Sha*, const byte*, word32);
wolfSSL 11:cee25a834751 99 WOLFSSL_API int wc_ShaFinal(Sha*, byte*);
wolfSSL 11:cee25a834751 100 WOLFSSL_API void wc_ShaFree(Sha*);
wolfSSL 11:cee25a834751 101
wolfSSL 11:cee25a834751 102 WOLFSSL_API int wc_ShaGetHash(Sha*, byte*);
wolfSSL 11:cee25a834751 103 WOLFSSL_API int wc_ShaCopy(Sha*, Sha*);
wolfSSL 11:cee25a834751 104
wolfSSL 11:cee25a834751 105 #ifdef __cplusplus
wolfSSL 11:cee25a834751 106 } /* extern "C" */
wolfSSL 11:cee25a834751 107 #endif
wolfSSL 11:cee25a834751 108
wolfSSL 11:cee25a834751 109 #endif /* NO_SHA */
wolfSSL 11:cee25a834751 110 #endif /* WOLF_CRYPT_SHA_H */
wolfSSL 11:cee25a834751 111
wolfSSL 11:cee25a834751 112