WebSocketServer test

Dependencies:   mbed

Committer:
gtk2k
Date:
Sun Apr 29 03:58:08 2012 +0000
Revision:
0:74be48b504a5
WebSocketServer

Who changed what in which revision?

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