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.
Dependents: CyaSSL-Twitter-OAuth4Tw Example-client-tls-cert TwitterReader TweetTest ... more
sha512.h
00001 /* sha512.h 00002 * 00003 * Copyright (C) 2006-2020 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 \file wolfssl/wolfcrypt/sha512.h 00024 */ 00025 00026 00027 #ifndef WOLF_CRYPT_SHA512_H 00028 #define WOLF_CRYPT_SHA512_H 00029 00030 #include <wolfssl/wolfcrypt/types.h > 00031 00032 #if defined(WOLFSSL_SHA512) || defined(WOLFSSL_SHA384) 00033 00034 #if defined(HAVE_FIPS) && \ 00035 defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2) 00036 #include <wolfssl/wolfcrypt/fips.h> 00037 #endif /* HAVE_FIPS_VERSION >= 2 */ 00038 00039 #if defined(HAVE_FIPS) && \ 00040 (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2)) 00041 #ifdef WOLFSSL_SHA512 00042 #define wc_Sha512 Sha512 00043 #define WC_SHA512 SHA512 00044 #define WC_SHA512_BLOCK_SIZE SHA512_BLOCK_SIZE 00045 #define WC_SHA512_DIGEST_SIZE SHA512_DIGEST_SIZE 00046 #define WC_SHA512_PAD_SIZE SHA512_PAD_SIZE 00047 #endif /* WOLFSSL_SHA512 */ 00048 #ifdef WOLFSSL_SHA384 00049 #define wc_Sha384 Sha384 00050 #define WC_SHA384 SHA384 00051 #define WC_SHA384_BLOCK_SIZE SHA384_BLOCK_SIZE 00052 #define WC_SHA384_DIGEST_SIZE SHA384_DIGEST_SIZE 00053 #define WC_SHA384_PAD_SIZE SHA384_PAD_SIZE 00054 #endif /* WOLFSSL_SHA384 */ 00055 00056 #define CYASSL_SHA512 00057 #if defined(WOLFSSL_SHA384) 00058 #define CYASSL_SHA384 00059 #endif 00060 /* for fips @wc_fips */ 00061 #include <cyassl/ctaocrypt/sha512.h> 00062 #endif 00063 00064 #ifdef __cplusplus 00065 extern "C" { 00066 #endif 00067 00068 /* avoid redefinition of structs */ 00069 #if !defined(HAVE_FIPS) || \ 00070 (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)) 00071 00072 #ifdef WOLFSSL_ASYNC_CRYPT 00073 #include <wolfssl/wolfcrypt/async.h> 00074 #endif 00075 #ifdef WOLFSSL_ESP32WROOM32_CRYPT 00076 #include <wolfssl/wolfcrypt/port/Espressif/esp32-crypt.h> 00077 #endif 00078 #if defined(_MSC_VER) 00079 #define SHA512_NOINLINE __declspec(noinline) 00080 #elif defined(__IAR_SYSTEMS_ICC__) || defined(__GNUC__) 00081 #define SHA512_NOINLINE __attribute__((noinline)) 00082 #else 00083 #define SHA512_NOINLINE 00084 #endif 00085 00086 #ifdef WOLFSSL_SHA512 00087 00088 #if !defined(NO_OLD_SHA_NAMES) 00089 #define SHA512 WC_SHA512 00090 #endif 00091 00092 #if !defined(NO_OLD_WC_NAMES) 00093 #define Sha512 wc_Sha512 00094 #define SHA512_BLOCK_SIZE WC_SHA512_BLOCK_SIZE 00095 #define SHA512_DIGEST_SIZE WC_SHA512_DIGEST_SIZE 00096 #define SHA512_PAD_SIZE WC_SHA512_PAD_SIZE 00097 #endif 00098 00099 #endif /* WOLFSSL_SHA512 */ 00100 00101 /* in bytes */ 00102 enum { 00103 #ifdef WOLFSSL_SHA512 00104 WC_SHA512 = WC_HASH_TYPE_SHA512, 00105 #endif 00106 WC_SHA512_BLOCK_SIZE = 128, 00107 WC_SHA512_DIGEST_SIZE = 64, 00108 WC_SHA512_PAD_SIZE = 112 00109 }; 00110 00111 00112 #ifdef WOLFSSL_IMX6_CAAM 00113 #include "wolfssl/wolfcrypt/port/caam/wolfcaam_sha.h" 00114 #else 00115 /* wc_Sha512 digest */ 00116 struct wc_Sha512 { 00117 word64 digest[WC_SHA512_DIGEST_SIZE / sizeof(word64)]; 00118 word64 buffer[WC_SHA512_BLOCK_SIZE / sizeof(word64)]; 00119 word32 buffLen; /* in bytes */ 00120 word64 loLen; /* length in bytes */ 00121 word64 hiLen; /* length in bytes */ 00122 void* heap; 00123 #ifdef USE_INTEL_SPEEDUP 00124 const byte* data; 00125 #endif 00126 #ifdef WOLFSSL_ASYNC_CRYPT 00127 WC_ASYNC_DEV asyncDev; 00128 #endif /* WOLFSSL_ASYNC_CRYPT */ 00129 #ifdef WOLFSSL_SMALL_STACK_CACHE 00130 word64* W; 00131 #endif 00132 #if defined(WOLFSSL_ESP32WROOM32_CRYPT) && \ 00133 !defined(NO_WOLFSSL_ESP32WROOM32_CRYPT_HASH) 00134 WC_ESP32SHA ctx; 00135 #endif 00136 #if defined(WOLFSSL_HASH_FLAGS) || defined(WOLF_CRYPTO_CB) 00137 word32 flags; /* enum wc_HashFlags in hash.h */ 00138 #endif 00139 }; 00140 00141 #ifndef WC_SHA512_TYPE_DEFINED 00142 typedef struct wc_Sha512 wc_Sha512; 00143 #define WC_SHA512_TYPE_DEFINED 00144 #endif 00145 #endif 00146 00147 #endif /* HAVE_FIPS */ 00148 00149 #ifdef WOLFSSL_ARMASM 00150 WOLFSSL_LOCAL void Transform_Sha512_Len(wc_Sha512* sha512, const byte* data, 00151 word32 len); 00152 #endif 00153 00154 #ifdef WOLFSSL_SHA512 00155 00156 WOLFSSL_API int wc_InitSha512(wc_Sha512*); 00157 WOLFSSL_API int wc_InitSha512_ex(wc_Sha512*, void*, int); 00158 WOLFSSL_API int wc_Sha512Update(wc_Sha512*, const byte*, word32); 00159 WOLFSSL_API int wc_Sha512FinalRaw(wc_Sha512*, byte*); 00160 WOLFSSL_API int wc_Sha512Final(wc_Sha512*, byte*); 00161 WOLFSSL_API void wc_Sha512Free(wc_Sha512*); 00162 00163 WOLFSSL_API int wc_Sha512GetHash(wc_Sha512*, byte*); 00164 WOLFSSL_API int wc_Sha512Copy(wc_Sha512* src, wc_Sha512* dst); 00165 00166 #if defined(WOLFSSL_HASH_FLAGS) || defined(WOLF_CRYPTO_CB) 00167 WOLFSSL_API int wc_Sha512SetFlags(wc_Sha512* sha512, word32 flags); 00168 WOLFSSL_API int wc_Sha512GetFlags(wc_Sha512* sha512, word32* flags); 00169 #endif 00170 00171 #endif /* WOLFSSL_SHA512 */ 00172 00173 #if defined(WOLFSSL_SHA384) 00174 00175 /* avoid redefinition of structs */ 00176 #if !defined(HAVE_FIPS) || \ 00177 (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)) 00178 00179 #if !defined(NO_OLD_SHA_NAMES) 00180 #define SHA384 WC_SHA384 00181 #endif 00182 00183 #if !defined(NO_OLD_WC_NAMES) 00184 #define Sha384 wc_Sha384 00185 #define SHA384_BLOCK_SIZE WC_SHA384_BLOCK_SIZE 00186 #define SHA384_DIGEST_SIZE WC_SHA384_DIGEST_SIZE 00187 #define SHA384_PAD_SIZE WC_SHA384_PAD_SIZE 00188 #endif 00189 00190 /* in bytes */ 00191 enum { 00192 WC_SHA384 = WC_HASH_TYPE_SHA384, 00193 WC_SHA384_BLOCK_SIZE = WC_SHA512_BLOCK_SIZE, 00194 WC_SHA384_DIGEST_SIZE = 48, 00195 WC_SHA384_PAD_SIZE = WC_SHA512_PAD_SIZE 00196 }; 00197 00198 00199 #ifndef WC_SHA384_TYPE_DEFINED 00200 typedef struct wc_Sha512 wc_Sha384; 00201 #define WC_SHA384_TYPE_DEFINED 00202 #endif 00203 #endif /* HAVE_FIPS */ 00204 00205 WOLFSSL_API int wc_InitSha384(wc_Sha384*); 00206 WOLFSSL_API int wc_InitSha384_ex(wc_Sha384*, void*, int); 00207 WOLFSSL_API int wc_Sha384Update(wc_Sha384*, const byte*, word32); 00208 WOLFSSL_API int wc_Sha384FinalRaw(wc_Sha384*, byte*); 00209 WOLFSSL_API int wc_Sha384Final(wc_Sha384*, byte*); 00210 WOLFSSL_API void wc_Sha384Free(wc_Sha384*); 00211 00212 WOLFSSL_API int wc_Sha384GetHash(wc_Sha384*, byte*); 00213 WOLFSSL_API int wc_Sha384Copy(wc_Sha384* src, wc_Sha384* dst); 00214 00215 #if defined(WOLFSSL_HASH_FLAGS) || defined(WOLF_CRYPTO_CB) 00216 WOLFSSL_API int wc_Sha384SetFlags(wc_Sha384* sha384, word32 flags); 00217 WOLFSSL_API int wc_Sha384GetFlags(wc_Sha384* sha384, word32* flags); 00218 #endif 00219 00220 #endif /* WOLFSSL_SHA384 */ 00221 00222 #ifdef __cplusplus 00223 } /* extern "C" */ 00224 #endif 00225 00226 #endif /* WOLFSSL_SHA512 || WOLFSSL_SHA384 */ 00227 #endif /* WOLF_CRYPT_SHA512_H */ 00228 00229
Generated on Tue Jul 12 2022 20:58:42 by
1.7.2