Bonjour/Zerconf library

Dependencies:   mbed

Committer:
dirkx
Date:
Sat Aug 14 15:54:31 2010 +0000
Revision:
5:8e53abda9900
Parent:
0:355018f44c9f

        

Who changed what in which revision?

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