NetTribute library with debug turned on in FShandler Donatien Garner -> Segundo Equipo -> this version

Committer:
hexley
Date:
Fri Nov 19 01:54:45 2010 +0000
Revision:
0:281d6ff68967

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hexley 0:281d6ff68967 1 /*
hexley 0:281d6ff68967 2 * \file sha1.h
hexley 0:281d6ff68967 3 *
hexley 0:281d6ff68967 4 * Copyright (C) 2006-2010, Paul Bakker <polarssl_maintainer at polarssl.org>
hexley 0:281d6ff68967 5 * All rights reserved.
hexley 0:281d6ff68967 6 *
hexley 0:281d6ff68967 7 * This program is free software; you can redistribute it and/or modify
hexley 0:281d6ff68967 8 * it under the terms of the GNU General Public License as published by
hexley 0:281d6ff68967 9 * the Free Software Foundation; either version 2 of the License, or
hexley 0:281d6ff68967 10 * (at your option) any later version.
hexley 0:281d6ff68967 11 *
hexley 0:281d6ff68967 12 * This program is distributed in the hope that it will be useful,
hexley 0:281d6ff68967 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
hexley 0:281d6ff68967 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
hexley 0:281d6ff68967 15 * GNU General Public License for more details.
hexley 0:281d6ff68967 16 *
hexley 0:281d6ff68967 17 * You should have received a copy of the GNU General Public License along
hexley 0:281d6ff68967 18 * with this program; if not, write to the Free Software Foundation, Inc.,
hexley 0:281d6ff68967 19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
hexley 0:281d6ff68967 20 */
hexley 0:281d6ff68967 21 #ifndef POLARSSL_SHA1_H
hexley 0:281d6ff68967 22 #define POLARSSL_SHA1_H
hexley 0:281d6ff68967 23
hexley 0:281d6ff68967 24 /*
hexley 0:281d6ff68967 25 * \brief SHA-1 context structure
hexley 0:281d6ff68967 26 */
hexley 0:281d6ff68967 27 typedef struct
hexley 0:281d6ff68967 28 {
hexley 0:281d6ff68967 29 unsigned long total[2]; /*!< number of bytes processed */
hexley 0:281d6ff68967 30 unsigned long state[5]; /*!< intermediate digest state */
hexley 0:281d6ff68967 31 unsigned char buffer[64]; /*!< data block being processed */
hexley 0:281d6ff68967 32
hexley 0:281d6ff68967 33 unsigned char ipad[64]; /*!< HMAC: inner padding */
hexley 0:281d6ff68967 34 unsigned char opad[64]; /*!< HMAC: outer padding */
hexley 0:281d6ff68967 35 }
hexley 0:281d6ff68967 36 sha1_context;
hexley 0:281d6ff68967 37
hexley 0:281d6ff68967 38 #ifdef __cplusplus
hexley 0:281d6ff68967 39 extern "C" {
hexley 0:281d6ff68967 40 #endif
hexley 0:281d6ff68967 41
hexley 0:281d6ff68967 42 /*
hexley 0:281d6ff68967 43 * \brief SHA-1 context setup
hexley 0:281d6ff68967 44 *
hexley 0:281d6ff68967 45 * \param ctx context to be initialized
hexley 0:281d6ff68967 46 */
hexley 0:281d6ff68967 47 void sha1_starts( sha1_context *ctx );
hexley 0:281d6ff68967 48
hexley 0:281d6ff68967 49 /*
hexley 0:281d6ff68967 50 * \brief SHA-1 process buffer
hexley 0:281d6ff68967 51 *
hexley 0:281d6ff68967 52 * \param ctx SHA-1 context
hexley 0:281d6ff68967 53 * \param input buffer holding the data
hexley 0:281d6ff68967 54 * \param ilen length of the input data
hexley 0:281d6ff68967 55 */
hexley 0:281d6ff68967 56 void sha1_update( sha1_context *ctx, const unsigned char *input, int ilen );
hexley 0:281d6ff68967 57
hexley 0:281d6ff68967 58 /*
hexley 0:281d6ff68967 59 * \brief SHA-1 final digest
hexley 0:281d6ff68967 60 *
hexley 0:281d6ff68967 61 * \param ctx SHA-1 context
hexley 0:281d6ff68967 62 * \param output SHA-1 checksum result
hexley 0:281d6ff68967 63 */
hexley 0:281d6ff68967 64 void sha1_finish( sha1_context *ctx, unsigned char output[20] );
hexley 0:281d6ff68967 65
hexley 0:281d6ff68967 66 /*
hexley 0:281d6ff68967 67 * \brief Output = SHA-1( input buffer )
hexley 0:281d6ff68967 68 *
hexley 0:281d6ff68967 69 * \param input buffer holding the data
hexley 0:281d6ff68967 70 * \param ilen length of the input data
hexley 0:281d6ff68967 71 * \param output SHA-1 checksum result
hexley 0:281d6ff68967 72 */
hexley 0:281d6ff68967 73 void sha1( const unsigned char *input, int ilen, unsigned char output[20] );
hexley 0:281d6ff68967 74
hexley 0:281d6ff68967 75 #if 0 //No need for that
hexley 0:281d6ff68967 76 /*
hexley 0:281d6ff68967 77 * \brief Output = SHA-1( file contents )
hexley 0:281d6ff68967 78 *
hexley 0:281d6ff68967 79 * \param path input file name
hexley 0:281d6ff68967 80 * \param output SHA-1 checksum result
hexley 0:281d6ff68967 81 *
hexley 0:281d6ff68967 82 * \return 0 if successful, 1 if fopen failed,
hexley 0:281d6ff68967 83 * or 2 if fread failed
hexley 0:281d6ff68967 84 */
hexley 0:281d6ff68967 85 int sha1_file( const char *path, unsigned char output[20] );
hexley 0:281d6ff68967 86 #endif
hexley 0:281d6ff68967 87
hexley 0:281d6ff68967 88 /*
hexley 0:281d6ff68967 89 * \brief SHA-1 HMAC context setup
hexley 0:281d6ff68967 90 *
hexley 0:281d6ff68967 91 * \param ctx HMAC context to be initialized
hexley 0:281d6ff68967 92 * \param key HMAC secret key
hexley 0:281d6ff68967 93 * \param keylen length of the HMAC key
hexley 0:281d6ff68967 94 */
hexley 0:281d6ff68967 95 void sha1_hmac_starts( sha1_context *ctx, const unsigned char *key, int keylen );
hexley 0:281d6ff68967 96
hexley 0:281d6ff68967 97 /*
hexley 0:281d6ff68967 98 * \brief SHA-1 HMAC process buffer
hexley 0:281d6ff68967 99 *
hexley 0:281d6ff68967 100 * \param ctx HMAC context
hexley 0:281d6ff68967 101 * \param input buffer holding the data
hexley 0:281d6ff68967 102 * \param ilen length of the input data
hexley 0:281d6ff68967 103 */
hexley 0:281d6ff68967 104 void sha1_hmac_update( sha1_context *ctx, const unsigned char *input, int ilen );
hexley 0:281d6ff68967 105
hexley 0:281d6ff68967 106 /*
hexley 0:281d6ff68967 107 * \brief SHA-1 HMAC final digest
hexley 0:281d6ff68967 108 *
hexley 0:281d6ff68967 109 * \param ctx HMAC context
hexley 0:281d6ff68967 110 * \param output SHA-1 HMAC checksum result
hexley 0:281d6ff68967 111 */
hexley 0:281d6ff68967 112 void sha1_hmac_finish( sha1_context *ctx, unsigned char output[20] );
hexley 0:281d6ff68967 113
hexley 0:281d6ff68967 114 /*
hexley 0:281d6ff68967 115 * \brief SHA-1 HMAC context reset
hexley 0:281d6ff68967 116 *
hexley 0:281d6ff68967 117 * \param ctx HMAC context to be reset
hexley 0:281d6ff68967 118 */
hexley 0:281d6ff68967 119 void sha1_hmac_reset( sha1_context *ctx );
hexley 0:281d6ff68967 120
hexley 0:281d6ff68967 121 /*
hexley 0:281d6ff68967 122 * \brief Output = HMAC-SHA-1( hmac key, input buffer )
hexley 0:281d6ff68967 123 *
hexley 0:281d6ff68967 124 * \param key HMAC secret key
hexley 0:281d6ff68967 125 * \param keylen length of the HMAC key
hexley 0:281d6ff68967 126 * \param input buffer holding the data
hexley 0:281d6ff68967 127 * \param ilen length of the input data
hexley 0:281d6ff68967 128 * \param output HMAC-SHA-1 result
hexley 0:281d6ff68967 129 */
hexley 0:281d6ff68967 130 void sha1_hmac( const unsigned char *key, int keylen,
hexley 0:281d6ff68967 131 const unsigned char *input, int ilen,
hexley 0:281d6ff68967 132 unsigned char output[20] );
hexley 0:281d6ff68967 133
hexley 0:281d6ff68967 134 /*
hexley 0:281d6ff68967 135 * \brief Checkup routine
hexley 0:281d6ff68967 136 *
hexley 0:281d6ff68967 137 * \return 0 if successful, or 1 if the test failed
hexley 0:281d6ff68967 138 */
hexley 0:281d6ff68967 139 int sha1_self_test( int verbose );
hexley 0:281d6ff68967 140
hexley 0:281d6ff68967 141 #ifdef __cplusplus
hexley 0:281d6ff68967 142 }
hexley 0:281d6ff68967 143 #endif
hexley 0:281d6ff68967 144
hexley 0:281d6ff68967 145 #endif /* sha1.h */