MD5 message digest algorithm (hash function). More...
#include "config.h"
#include <string.h>
#include <inttypes.h>
Go to the source code of this file.
Data Structures | |
struct | md5_context |
MD5 context structure. More... | |
Defines | |
#define | POLARSSL_ERR_MD5_FILE_IO_ERROR -0x0074 |
Read/write error in file. | |
Functions | |
void | md5_starts (md5_context *ctx) |
MD5 context setup. | |
void | md5_update (md5_context *ctx, const unsigned char *input, size_t ilen) |
MD5 process buffer. | |
void | md5_finish (md5_context *ctx, unsigned char output[16]) |
MD5 final digest. | |
void | md5_process (md5_context *ctx, const unsigned char data[64]) |
void | md5 (const unsigned char *input, size_t ilen, unsigned char output[16]) |
Output = MD5( input buffer ). | |
int | md5_file (const char *path, unsigned char output[16]) |
Output = MD5( file contents ). | |
void | md5_hmac_starts (md5_context *ctx, const unsigned char *key, size_t keylen) |
MD5 HMAC context setup. | |
void | md5_hmac_update (md5_context *ctx, const unsigned char *input, size_t ilen) |
MD5 HMAC process buffer. | |
void | md5_hmac_finish (md5_context *ctx, unsigned char output[16]) |
MD5 HMAC final digest. | |
void | md5_hmac_reset (md5_context *ctx) |
MD5 HMAC context reset. | |
void | md5_hmac (const unsigned char *key, size_t keylen, const unsigned char *input, size_t ilen, unsigned char output[16]) |
Output = HMAC-MD5( hmac key, input buffer ). | |
int | md5_self_test (int verbose) |
Checkup routine. |
MD5 message digest algorithm (hash function).
Copyright (C) 2006-2013, Brainspark B.V.
This file is part of PolarSSL (http://www.polarssl.org) Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
All rights reserved.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Definition in file md5.h.
#define POLARSSL_ERR_MD5_FILE_IO_ERROR -0x0074 |
Read/write error in file.
Definition at line 41 of file md5.h.
Referenced by md5_file(), and polarssl_strerror().
void md5 | ( | const unsigned char * | input, | |
size_t | ilen, | |||
unsigned char | output[16] | |||
) |
Output = MD5( input buffer ).
input | buffer holding the data | |
ilen | length of the input data | |
output | MD5 checksum result |
Definition at line 286 of file md5.c.
References md5_finish(), md5_starts(), and md5_update().
Referenced by md5_hmac_starts(), md5_self_test(), ssl3_prf(), ssl_calc_finished_ssl(), ssl_calc_finished_tls(), ssl_calc_verify_ssl(), ssl_calc_verify_tls(), ssl_parse_server_key_exchange(), ssl_write_server_key_exchange(), and test_suite_md5_text().
int md5_file | ( | const char * | path, | |
unsigned char | output[16] | |||
) |
Output = MD5( file contents ).
path | input file name | |
output | MD5 checksum result |
Definition at line 301 of file md5.c.
References md5_finish(), md5_starts(), md5_update(), and POLARSSL_ERR_MD5_FILE_IO_ERROR.
Referenced by md5_file_wrap(), and test_suite_md5_file().
void md5_finish | ( | md5_context * | ctx, | |
unsigned char | output[16] | |||
) |
MD5 final digest.
ctx | MD5 context | |
output | MD5 checksum result |
Definition at line 256 of file md5.c.
References md5_padding, md5_update(), PUT_UINT32_LE, md5_context::state, and md5_context::total.
Referenced by md5(), md5_file(), md5_finish_wrap(), md5_hmac_finish(), pem_pbkdf1(), ssl3_prf(), ssl_calc_finished_ssl(), ssl_calc_finished_tls(), ssl_calc_verify_ssl(), ssl_calc_verify_tls(), ssl_parse_server_key_exchange(), and ssl_write_server_key_exchange().
void md5_hmac | ( | const unsigned char * | key, | |
size_t | keylen, | |||
const unsigned char * | input, | |||
size_t | ilen, | |||
unsigned char | output[16] | |||
) |
Output = HMAC-MD5( hmac key, input buffer ).
key | HMAC secret key | |
keylen | length of the HMAC key | |
input | buffer holding the data | |
ilen | length of the input data | |
output | HMAC-MD5 result |
Definition at line 397 of file md5.c.
References md5_hmac_finish(), md5_hmac_starts(), and md5_hmac_update().
Referenced by test_suite_md5_hmac(), and tls1_prf().
void md5_hmac_finish | ( | md5_context * | ctx, | |
unsigned char | output[16] | |||
) |
MD5 HMAC final digest.
ctx | HMAC context | |
output | MD5 HMAC checksum result |
Definition at line 372 of file md5.c.
References md5_finish(), md5_starts(), md5_update(), and md5_context::opad.
Referenced by md5_hmac(), md5_hmac_finish_wrap(), and md5_self_test().
void md5_hmac_reset | ( | md5_context * | ctx | ) |
MD5 HMAC context reset.
ctx | HMAC context to be reset |
Definition at line 388 of file md5.c.
References md5_context::ipad, md5_starts(), and md5_update().
Referenced by md5_hmac_reset_wrap().
void md5_hmac_starts | ( | md5_context * | ctx, | |
const unsigned char * | key, | |||
size_t | keylen | |||
) |
MD5 HMAC context setup.
ctx | HMAC context to be initialized | |
key | HMAC secret key | |
keylen | length of the HMAC key |
Definition at line 334 of file md5.c.
References md5_context::ipad, md5(), md5_starts(), md5_update(), and md5_context::opad.
Referenced by md5_hmac(), md5_hmac_starts_wrap(), and md5_self_test().
void md5_hmac_update | ( | md5_context * | ctx, | |
const unsigned char * | input, | |||
size_t | ilen | |||
) |
MD5 HMAC process buffer.
ctx | HMAC context | |
input | buffer holding the data | |
ilen | length of the input data |
Definition at line 364 of file md5.c.
References md5_update().
Referenced by md5_hmac(), md5_hmac_update_wrap(), and md5_self_test().
void md5_process | ( | md5_context * | ctx, | |
const unsigned char | data[64] | |||
) |
Definition at line 80 of file md5.c.
References A, GET_UINT32_LE, P, and md5_context::state.
Referenced by md5_process_wrap(), and md5_update().
int md5_self_test | ( | int | verbose | ) |
Checkup routine.
Definition at line 515 of file md5.c.
References md5(), md5_hmac_finish(), md5_hmac_starts(), md5_hmac_test_buf, md5_hmac_test_buflen, md5_hmac_test_key, md5_hmac_test_keylen, md5_hmac_test_sum, md5_hmac_update(), md5_test_buf, md5_test_buflen, and md5_test_sum.
Referenced by test_suite_md5_selftest().
void md5_starts | ( | md5_context * | ctx | ) |
MD5 context setup.
ctx | context to be initialized |
Definition at line 69 of file md5.c.
References md5_context::state, and md5_context::total.
Referenced by md5(), md5_file(), md5_hmac_finish(), md5_hmac_reset(), md5_hmac_starts(), md5_starts_wrap(), pem_pbkdf1(), ssl3_prf(), ssl_calc_finished_ssl(), ssl_calc_verify_ssl(), ssl_handshake_init(), ssl_parse_server_key_exchange(), and ssl_write_server_key_exchange().
void md5_update | ( | md5_context * | ctx, | |
const unsigned char * | input, | |||
size_t | ilen | |||
) |
MD5 process buffer.
ctx | MD5 context | |
input | buffer holding the data | |
ilen | length of the input data |
Definition at line 206 of file md5.c.
References md5_context::buffer, md5_process(), and md5_context::total.
Referenced by md5(), md5_file(), md5_finish(), md5_hmac_finish(), md5_hmac_reset(), md5_hmac_starts(), md5_hmac_update(), md5_update_wrap(), pem_pbkdf1(), ssl3_prf(), ssl_calc_finished_ssl(), ssl_calc_verify_ssl(), ssl_parse_server_key_exchange(), ssl_update_checksum_md5sha1(), ssl_update_checksum_start(), and ssl_write_server_key_exchange().