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
sha256.h
00001 /* sha256.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 /* code submitted by raphael.huck@efixo.com */ 00024 00025 #ifndef WOLF_CRYPT_SHA256_H 00026 #define WOLF_CRYPT_SHA256_H 00027 00028 #include <wolfssl/wolfcrypt/types.h> 00029 00030 #ifndef NO_SHA256 00031 00032 #ifdef HAVE_FIPS 00033 /* for fips @wc_fips */ 00034 #include <cyassl/ctaocrypt/sha256.h> 00035 #endif 00036 00037 #ifdef FREESCALE_LTC_SHA 00038 #include "fsl_ltc.h" 00039 #endif 00040 00041 00042 #ifdef __cplusplus 00043 extern "C" { 00044 #endif 00045 00046 #ifndef HAVE_FIPS /* avoid redefinition of structs */ 00047 00048 #ifdef WOLFSSL_PIC32MZ_HASH 00049 #include "port/pic32/pic32mz-crypt.h" 00050 #endif 00051 #ifdef WOLFSSL_ASYNC_CRYPT 00052 #include <wolfssl/wolfcrypt/async.h> 00053 #endif 00054 00055 /* in bytes */ 00056 enum { 00057 SHA256 = 2, /* hash type unique */ 00058 SHA256_BLOCK_SIZE = 64, 00059 SHA256_DIGEST_SIZE = 32, 00060 SHA256_PAD_SIZE = 56 00061 }; 00062 00063 #ifndef WOLFSSL_TI_HASH 00064 00065 /* Sha256 digest */ 00066 typedef struct Sha256 { 00067 #ifdef FREESCALE_LTC_SHA 00068 ltc_hash_ctx_t ctx; 00069 #else 00070 /* alignment on digest and buffer speeds up ARMv8 crypto operations */ 00071 ALIGN16 word32 digest[SHA256_DIGEST_SIZE / sizeof(word32)]; 00072 ALIGN16 word32 buffer[SHA256_BLOCK_SIZE / sizeof(word32)]; 00073 word32 buffLen; /* in bytes */ 00074 word32 loLen; /* length in bytes */ 00075 word32 hiLen; /* length in bytes */ 00076 void* heap; 00077 #ifdef WOLFSSL_PIC32MZ_HASH 00078 pic32mz_desc desc; /* Crypt Engine descriptor */ 00079 #endif 00080 #ifdef WOLFSSL_ASYNC_CRYPT 00081 WC_ASYNC_DEV asyncDev; 00082 #endif /* WOLFSSL_ASYNC_CRYPT */ 00083 #endif /* FREESCALE_LTC_SHA */ 00084 } Sha256; 00085 00086 #else /* WOLFSSL_TI_HASH */ 00087 #include "wolfssl/wolfcrypt/port/ti/ti-hash.h" 00088 #endif 00089 00090 #endif /* HAVE_FIPS */ 00091 00092 WOLFSSL_API int wc_InitSha256(Sha256*); 00093 WOLFSSL_API int wc_InitSha256_ex(Sha256*, void*, int); 00094 WOLFSSL_API int wc_Sha256Update(Sha256*, const byte*, word32); 00095 WOLFSSL_API int wc_Sha256Final(Sha256*, byte*); 00096 WOLFSSL_API void wc_Sha256Free(Sha256*); 00097 00098 WOLFSSL_API int wc_Sha256GetHash(Sha256*, byte*); 00099 WOLFSSL_API int wc_Sha256Copy(Sha256* src, Sha256* dst); 00100 00101 #ifdef WOLFSSL_SHA224 00102 00103 #ifndef HAVE_FIPS /* avoid redefinition of structs */ 00104 /* in bytes */ 00105 enum { 00106 SHA224 = 8, /* hash type unique */ 00107 SHA224_BLOCK_SIZE = SHA256_BLOCK_SIZE, 00108 SHA224_DIGEST_SIZE = 28, 00109 SHA224_PAD_SIZE = SHA256_PAD_SIZE 00110 }; 00111 00112 typedef Sha256 Sha224; 00113 #endif /* HAVE_FIPS */ 00114 00115 WOLFSSL_API int wc_InitSha224(Sha224*); 00116 WOLFSSL_API int wc_InitSha224_ex(Sha224*, void*, int); 00117 WOLFSSL_API int wc_Sha224Update(Sha224*, const byte*, word32); 00118 WOLFSSL_API int wc_Sha224Final(Sha224*, byte*); 00119 WOLFSSL_API void wc_Sha224Free(Sha224*); 00120 00121 WOLFSSL_API int wc_Sha224GetHash(Sha224*, byte*); 00122 WOLFSSL_API int wc_Sha224Copy(Sha224* src, Sha224* dst); 00123 00124 #endif /* WOLFSSL_SHA224 */ 00125 00126 #ifdef __cplusplus 00127 } /* extern "C" */ 00128 #endif 00129 00130 #endif /* NO_SHA256 */ 00131 #endif /* WOLF_CRYPT_SHA256_H */ 00132 00133
Generated on Tue Jul 12 2022 23:30:59 by
1.7.2
