Renesas / SecureDweet
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers sha.h Source File

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 __cplusplus
00036     extern "C" {
00037 #endif
00038 
00039 #ifndef HAVE_FIPS /* avoid redefining structs */
00040 /* in bytes */
00041 enum {
00042 #ifdef STM32F2_HASH
00043     SHA_REG_SIZE     =  4,    /* STM32 register size, bytes */
00044 #endif
00045     SHA              =  1,    /* hash type unique */
00046     SHA_BLOCK_SIZE   = 64,
00047     SHA_DIGEST_SIZE  = 20,
00048     SHA_PAD_SIZE     = 56
00049 };
00050 
00051 #ifdef WOLFSSL_PIC32MZ_HASH
00052 #include "port/pic32/pic32mz-crypt.h"
00053 #endif
00054 
00055 #ifndef WOLFSSL_TI_HASH
00056       
00057 /* Sha digest */
00058 typedef struct Sha {
00059     word32  buffLen;   /* in bytes          */
00060     word32  loLen;     /* length in bytes   */
00061     word32  hiLen;     /* length in bytes   */
00062     word32  buffer[SHA_BLOCK_SIZE  / sizeof(word32)];
00063     #ifndef WOLFSSL_PIC32MZ_HASH
00064         word32  digest[SHA_DIGEST_SIZE / sizeof(word32)];
00065     #else
00066         word32  digest[PIC32_HASH_SIZE / sizeof(word32)];
00067         pic32mz_desc desc; /* Crypt Engine descriptor */
00068     #endif
00069 } Sha;
00070 
00071 #else /* WOLFSSL_TI_HASH */
00072     #include "wolfssl/wolfcrypt/port/ti/ti-hash.h"
00073 #endif
00074 
00075 #endif /* HAVE_FIPS */
00076 
00077 WOLFSSL_API int wc_InitSha(Sha*);
00078 WOLFSSL_API int wc_ShaUpdate(Sha*, const byte*, word32);
00079 WOLFSSL_API int wc_ShaFinal(Sha*, byte*);
00080 
00081 #ifdef __cplusplus
00082     } /* extern "C" */
00083 #endif
00084 
00085 #endif /* NO_SHA */
00086 #endif /* WOLF_CRYPT_SHA_H */
00087 
00088