Example self-announcing webserver which controls a servo through a smallHTML userinterface.

Dependencies:   mbed

Committer:
dirkx
Date:
Sat Aug 14 15:56:01 2010 +0000
Revision:
0:a259777c45a3

        

Who changed what in which revision?

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