Modified version of NetServices. Fixes an issue where connections failed should the HTTP response status line be received in a packet on its own prior to any further headers. Changes are made to the HTTPClient.cpp file's readHeaders method.

Committer:
andrewbonney
Date:
Fri Apr 08 14:39:41 2011 +0000
Revision:
0:ec559500a63f

        

Who changed what in which revision?

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