~braiampe/+junk/cgminer

« back to all changes in this revision

Viewing changes to sha2.h

  • Committer: Braiam Peguero
  • Date: 2011-10-09 06:47:47 UTC
  • Revision ID: braiamp@gmail.com-20111009064747-iju2nhzrh6ya56zs
* Forgot adding files to the branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * \file sha2.h
 
3
 *
 
4
 *  Copyright (C) 2011, Con Kolivas <kernel@kolivas.org>
 
5
 *  Copyright (C) 2006-2010, Brainspark B.V.
 
6
 *
 
7
 *  This file is part of PolarSSL (http://www.polarssl.org)
 
8
 *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
 
9
 *
 
10
 *  All rights reserved.
 
11
 *
 
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.
 
16
 *
 
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.
 
21
 *
 
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.
 
25
 */
 
26
#ifndef POLARSSL_SHA2_H
 
27
#define POLARSSL_SHA2_H
 
28
 
 
29
/**
 
30
 * \brief          SHA-256 context structure
 
31
 */
 
32
typedef struct
 
33
{
 
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 */
 
37
 
 
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 */
 
41
}
 
42
sha2_context;
 
43
 
 
44
#ifdef __cplusplus
 
45
extern "C" {
 
46
#endif
 
47
 
 
48
/**
 
49
 * \brief          SHA-256 context setup
 
50
 *
 
51
 * \param ctx      context to be initialized
 
52
 * \param is224    0 = use SHA256, 1 = use SHA224
 
53
 */
 
54
void sha2_starts( sha2_context *ctx, int is224 );
 
55
 
 
56
/**
 
57
 * \brief          SHA-256 process buffer
 
58
 *
 
59
 * \param ctx      SHA-256 context
 
60
 * \param input    buffer holding the  data
 
61
 * \param ilen     length of the input data
 
62
 */
 
63
void sha2_update( sha2_context *ctx, const unsigned char *input, int ilen );
 
64
 
 
65
/**
 
66
 * \brief          SHA-256 final digest
 
67
 *
 
68
 * \param ctx      SHA-256 context
 
69
 * \param output   SHA-224/256 checksum result
 
70
 */
 
71
void sha2_finish( sha2_context *ctx, unsigned char output[32] );
 
72
 
 
73
/**
 
74
 * \brief          Output = SHA-256( input buffer )
 
75
 *
 
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
 
80
 */
 
81
void sha2( const unsigned char *input, int ilen,
 
82
           unsigned char output[32], int is224 );
 
83
 
 
84
#ifdef __cplusplus
 
85
}
 
86
#endif
 
87
 
 
88
#endif /* sha2.h */