SNMP agent attached to SPI slave

Dependencies:   mbed

Committer:
lorcansmith
Date:
Mon Aug 13 15:07:40 2012 +0000
Revision:
0:2a53a4c3238c
v1.1 release includes ioAlarm traps

Who changed what in which revision?

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