Version of http://mbed.org/cookbook/NetServicesTribute with setting set the same for LPC2368

Dependents:   UDPSocketExample 24LCxx_I2CApp WeatherPlatform_pachube HvZServerLib ... more

Committer:
simon
Date:
Tue Nov 23 14:15:36 2010 +0000
Revision:
0:350011bf8be7
Experimental version for testing UDP

Who changed what in which revision?

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