EthernetNetIf Compatibility.

Dependents:   XBeeWiFi_SPI_example

Fork of NetServicesSource by Donatien Garnier

Committer:
donatien
Date:
Tue Jul 27 15:59:42 2010 +0000
Revision:
5:dd63a1e02b1b
Parent:
0:632c9925f013

        

Who changed what in which revision?

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