Webserver+3d print

Dependents:   Nucleo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers sha512.h Source File

sha512.h

Go to the documentation of this file.
00001 /**
00002  * @file sha512.h
00003  * @brief SHA-512 (Secure Hash Algorithm 512)
00004  *
00005  * @section License
00006  *
00007  * Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved.
00008  *
00009  * This file is part of CycloneCrypto Open.
00010  *
00011  * This program is free software; you can redistribute it and/or
00012  * modify it under the terms of the GNU General Public License
00013  * as published by the Free Software Foundation; either version 2
00014  * of the License, or (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software Foundation,
00023  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00024  *
00025  * @author Oryx Embedded SARL (www.oryx-embedded.com)
00026  * @version 1.7.6
00027  **/
00028 
00029 #ifndef _SHA512_H
00030 #define _SHA512_H
00031 
00032 //Dependencies
00033 #include "crypto.h"
00034 
00035 //SHA-512 block size
00036 #define SHA512_BLOCK_SIZE 128
00037 //SHA-512 digest size
00038 #define SHA512_DIGEST_SIZE 64
00039 //Common interface for hash algorithms
00040 #define SHA512_HASH_ALGO (&sha512HashAlgo)
00041 
00042 
00043 /**
00044  * @brief SHA-512 algorithm context
00045  **/
00046 
00047 typedef struct
00048 {
00049    union
00050    {
00051       uint64_t h[8];
00052       uint8_t digest[64];
00053    };
00054    union
00055    {
00056       uint64_t w[16];
00057       uint8_t buffer[128];
00058    };
00059    size_t size;
00060    uint64_t totalSize;
00061 } Sha512Context;
00062 
00063 
00064 //SHA-512 related constants
00065 extern const HashAlgo sha512HashAlgo;
00066 
00067 //SHA-512 related functions
00068 error_t sha512Compute(const void *data, size_t length, uint8_t *digest);
00069 void sha512Init(Sha512Context *context);
00070 void sha512Update(Sha512Context *context, const void *data, size_t length);
00071 void sha512Final(Sha512Context *context, uint8_t *digest);
00072 void sha512ProcessBlock(Sha512Context *context);
00073 
00074 #endif
00075