Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of wolfSSL by
sha.h
00001 /* sha.h 00002 * 00003 * Copyright (C) 2006-2016 wolfSSL Inc. 00004 * 00005 * This file is part of wolfSSL. 00006 * 00007 * wolfSSL is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * wolfSSL is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA 00020 */ 00021 00022 00023 #ifndef WOLF_CRYPT_SHA_H 00024 #define WOLF_CRYPT_SHA_H 00025 00026 #include <wolfssl/wolfcrypt/types.h> 00027 00028 #ifndef NO_SHA 00029 00030 #ifdef HAVE_FIPS 00031 /* for fips @wc_fips */ 00032 #include <cyassl/ctaocrypt/sha.h> 00033 #endif 00034 00035 #ifdef FREESCALE_LTC_SHA 00036 #include "fsl_ltc.h" 00037 #endif 00038 00039 #ifdef __cplusplus 00040 extern "C" { 00041 #endif 00042 00043 #ifndef HAVE_FIPS /* avoid redefining structs */ 00044 00045 #ifdef WOLFSSL_PIC32MZ_HASH 00046 #include "port/pic32/pic32mz-crypt.h" 00047 #endif 00048 #ifdef WOLFSSL_ASYNC_CRYPT 00049 #include <wolfssl/wolfcrypt/async.h> 00050 #endif 00051 00052 /* in bytes */ 00053 enum { 00054 #if defined(STM32F2_HASH) || defined(STM32F4_HASH) 00055 SHA_REG_SIZE = 4, /* STM32 register size, bytes */ 00056 #endif 00057 SHA = 1, /* hash type unique */ 00058 SHA_BLOCK_SIZE = 64, 00059 SHA_DIGEST_SIZE = 20, 00060 SHA_PAD_SIZE = 56 00061 }; 00062 00063 00064 #ifndef WOLFSSL_TI_HASH 00065 /* Sha digest */ 00066 typedef struct Sha { 00067 #ifdef FREESCALE_LTC_SHA 00068 ltc_hash_ctx_t ctx; 00069 #else 00070 word32 buffLen; /* in bytes */ 00071 word32 loLen; /* length in bytes */ 00072 word32 hiLen; /* length in bytes */ 00073 word32 buffer[SHA_BLOCK_SIZE / sizeof(word32)]; 00074 #ifndef WOLFSSL_PIC32MZ_HASH 00075 word32 digest[SHA_DIGEST_SIZE / sizeof(word32)]; 00076 #else 00077 word32 digest[PIC32_HASH_SIZE / sizeof(word32)]; 00078 #endif 00079 void* heap; 00080 #ifdef WOLFSSL_PIC32MZ_HASH 00081 pic32mz_desc desc; /* Crypt Engine descriptor */ 00082 #endif 00083 #ifdef WOLFSSL_ASYNC_CRYPT 00084 WC_ASYNC_DEV asyncDev; 00085 #endif /* WOLFSSL_ASYNC_CRYPT */ 00086 #endif /* FREESCALE_LTC_SHA */ 00087 } Sha; 00088 00089 #else 00090 #include "wolfssl/wolfcrypt/port/ti/ti-hash.h" 00091 #endif /* WOLFSSL_TI_HASH */ 00092 00093 00094 #endif /* HAVE_FIPS */ 00095 00096 WOLFSSL_API int wc_InitSha(Sha*); 00097 WOLFSSL_API int wc_InitSha_ex(Sha* sha, void* heap, int devId); 00098 WOLFSSL_API int wc_ShaUpdate(Sha*, const byte*, word32); 00099 WOLFSSL_API int wc_ShaFinal(Sha*, byte*); 00100 WOLFSSL_API void wc_ShaFree(Sha*); 00101 00102 WOLFSSL_API int wc_ShaGetHash(Sha*, byte*); 00103 WOLFSSL_API int wc_ShaCopy(Sha*, Sha*); 00104 00105 #ifdef __cplusplus 00106 } /* extern "C" */ 00107 #endif 00108 00109 #endif /* NO_SHA */ 00110 #endif /* WOLF_CRYPT_SHA_H */ 00111 00112
Generated on Tue Jul 12 2022 23:30:59 by
1.7.2
