Dependents:   SimpleLCDClock readCard2Twitter_http AnalogClock_StepperMotor_NTP ServoCamV1

Committer:
donatien
Date:
Tue Jun 01 12:55:46 2010 +0000
Revision:
8:65b403c38e41

        

Who changed what in which revision?

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