4
* Copyright (C) 2011, Con Kolivas <kernel@kolivas.org>
5
* Copyright (C) 2006-2010, Brainspark B.V.
7
* This file is part of PolarSSL (http://www.polarssl.org)
8
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
10
* All rights reserved.
12
* This program is free software; you can redistribute it and/or modify
13
* it under the terms of the GNU General Public License as published by
14
* the Free Software Foundation; either version 2 of the License, or
15
* (at your option) any later version.
17
* This program is distributed in the hope that it will be useful,
18
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
* GNU General Public License for more details.
22
* You should have received a copy of the GNU General Public License along
23
* with this program; if not, write to the Free Software Foundation, Inc.,
24
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26
#ifndef POLARSSL_SHA2_H
27
#define POLARSSL_SHA2_H
30
* \brief SHA-256 context structure
34
unsigned long total[2]; /*!< number of bytes processed */
35
unsigned long state[8]; /*!< intermediate digest state */
36
unsigned char buffer[64]; /*!< data block being processed */
38
unsigned char ipad[64]; /*!< HMAC: inner padding */
39
unsigned char opad[64]; /*!< HMAC: outer padding */
40
int is224; /*!< 0 => SHA-256, else SHA-224 */
49
* \brief SHA-256 context setup
51
* \param ctx context to be initialized
52
* \param is224 0 = use SHA256, 1 = use SHA224
54
void sha2_starts( sha2_context *ctx, int is224 );
57
* \brief SHA-256 process buffer
59
* \param ctx SHA-256 context
60
* \param input buffer holding the data
61
* \param ilen length of the input data
63
void sha2_update( sha2_context *ctx, const unsigned char *input, int ilen );
66
* \brief SHA-256 final digest
68
* \param ctx SHA-256 context
69
* \param output SHA-224/256 checksum result
71
void sha2_finish( sha2_context *ctx, unsigned char output[32] );
74
* \brief Output = SHA-256( input buffer )
76
* \param input buffer holding the data
77
* \param ilen length of the input data
78
* \param output SHA-224/256 checksum result
79
* \param is224 0 = use SHA256, 1 = use SHA224
81
void sha2( const unsigned char *input, int ilen,
82
unsigned char output[32], int is224 );