md.h

Go to the documentation of this file.
00001 
00025 #ifndef MBEDTLS_MD_H
00026 #define MBEDTLS_MD_H
00027 
00028 #include <stddef.h>
00029 
00030 #define MBEDTLS_ERR_MD_FEATURE_UNAVAILABLE                -0x5080  
00031 #define MBEDTLS_ERR_MD_BAD_INPUT_DATA                     -0x5100  
00032 #define MBEDTLS_ERR_MD_ALLOC_FAILED                       -0x5180  
00033 #define MBEDTLS_ERR_MD_FILE_IO_ERROR                      -0x5200  
00035 #ifdef __cplusplus
00036 extern "C" {
00037 #endif
00038 
00039 typedef enum {
00040     MBEDTLS_MD_NONE=0,
00041     MBEDTLS_MD_MD2,
00042     MBEDTLS_MD_MD4,
00043     MBEDTLS_MD_MD5,
00044     MBEDTLS_MD_SHA1,
00045     MBEDTLS_MD_SHA224,
00046     MBEDTLS_MD_SHA256,
00047     MBEDTLS_MD_SHA384,
00048     MBEDTLS_MD_SHA512,
00049     MBEDTLS_MD_RIPEMD160,
00050 } mbedtls_md_type_t;
00051 
00052 #if defined(MBEDTLS_SHA512_C)
00053 #define MBEDTLS_MD_MAX_SIZE         64  /* longest known is SHA512 */
00054 #else
00055 #define MBEDTLS_MD_MAX_SIZE         32  /* longest known is SHA256 or less */
00056 #endif
00057 
00061 typedef struct mbedtls_md_info_t mbedtls_md_info_t;
00062 
00066 typedef struct {
00068     const mbedtls_md_info_t *md_info;
00069 
00071     void *md_ctx;
00072 
00074     void *hmac_ctx;
00075 } mbedtls_md_context_t;
00076 
00083 const int *mbedtls_md_list( void );
00084 
00094 const mbedtls_md_info_t *mbedtls_md_info_from_string( const char *md_name );
00095 
00105 const mbedtls_md_info_t *mbedtls_md_info_from_type( mbedtls_md_type_t md_type );
00106 
00112 void mbedtls_md_init( mbedtls_md_context_t *ctx );
00113 
00119 void mbedtls_md_free( mbedtls_md_context_t *ctx );
00120 
00121 #if ! defined(MBEDTLS_DEPRECATED_REMOVED)
00122 #if defined(MBEDTLS_DEPRECATED_WARNING)
00123 #define MBEDTLS_DEPRECATED    __attribute__((deprecated))
00124 #else
00125 #define MBEDTLS_DEPRECATED
00126 #endif
00127 
00141 int mbedtls_md_init_ctx( mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info ) MBEDTLS_DEPRECATED;
00142 #undef MBEDTLS_DEPRECATED
00143 #endif /* MBEDTLS_DEPRECATED_REMOVED */
00144 
00159 int mbedtls_md_setup( mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info, int hmac );
00160 
00175 int mbedtls_md_clone( mbedtls_md_context_t *dst,
00176                       const mbedtls_md_context_t *src );
00177 
00185 unsigned char mbedtls_md_get_size( const mbedtls_md_info_t *md_info );
00186 
00194 mbedtls_md_type_t mbedtls_md_get_type( const mbedtls_md_info_t *md_info );
00195 
00203 const char *mbedtls_md_get_name( const mbedtls_md_info_t *md_info );
00204 
00215 int mbedtls_md_starts( mbedtls_md_context_t *ctx );
00216 
00229 int mbedtls_md_update( mbedtls_md_context_t *ctx, const unsigned char *input, size_t ilen );
00230 
00242 int mbedtls_md_finish( mbedtls_md_context_t *ctx, unsigned char *output );
00243 
00255 int mbedtls_md( const mbedtls_md_info_t *md_info, const unsigned char *input, size_t ilen,
00256         unsigned char *output );
00257 
00258 #if defined(MBEDTLS_FS_IO)
00259 
00270 int mbedtls_md_file( const mbedtls_md_info_t *md_info, const char *path,
00271                      unsigned char *output );
00272 #endif /* MBEDTLS_FS_IO */
00273 
00285 int mbedtls_md_hmac_starts( mbedtls_md_context_t *ctx, const unsigned char *key,
00286                     size_t keylen );
00287 
00301 int mbedtls_md_hmac_update( mbedtls_md_context_t *ctx, const unsigned char *input,
00302                     size_t ilen );
00303 
00316 int mbedtls_md_hmac_finish( mbedtls_md_context_t *ctx, unsigned char *output);
00317 
00328 int mbedtls_md_hmac_reset( mbedtls_md_context_t *ctx );
00329 
00343 int mbedtls_md_hmac( const mbedtls_md_info_t *md_info, const unsigned char *key, size_t keylen,
00344                 const unsigned char *input, size_t ilen,
00345                 unsigned char *output );
00346 
00347 /* Internal use */
00348 int mbedtls_md_process( mbedtls_md_context_t *ctx, const unsigned char *data );
00349 
00350 #ifdef __cplusplus
00351 }
00352 #endif
00353 
00354 #endif /* MBEDTLS_MD_H */

Generated on 11 Mar 2017 for mbed TLS v2.4.2 by  doxygen 1.4.7