1 /* 2 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 3 * 4 * Licensed under the OpenSSL license (the "License"). You may not use 5 * this file except in compliance with the License. You can obtain a copy 6 * in the file LICENSE in the source distribution or at 7 * https://www.openssl.org/source/license.html 8 */ 9 10 #ifndef OPENSSL_HEADER_MD5_H 11 #define OPENSSL_HEADER_MD5_H 12 13 #include <openssl/base.h> 14 15 #if defined(__cplusplus) 16 extern "C" { 17 #endif 18 19 20 // MD5. 21 22 23 // MD5_CBLOCK is the block size of MD5. 24 #define MD5_CBLOCK 64 25 26 // MD5_DIGEST_LENGTH is the length of an MD5 digest. 27 #define MD5_DIGEST_LENGTH 16 28 29 // MD5_Init initialises |md5| and returns one. 30 OPENSSL_EXPORT int MD5_Init(MD5_CTX *md5); 31 32 // MD5_Update adds |len| bytes from |data| to |md5| and returns one. 33 OPENSSL_EXPORT int MD5_Update(MD5_CTX *md5, const void *data, size_t len); 34 35 // MD5_Final adds the final padding to |md5| and writes the resulting digest to 36 // |out|, which must have at least |MD5_DIGEST_LENGTH| bytes of space. It 37 // returns one. 38 OPENSSL_EXPORT int MD5_Final(uint8_t out[MD5_DIGEST_LENGTH], MD5_CTX *md5); 39 40 // MD5 writes the digest of |len| bytes from |data| to |out| and returns |out|. 41 // There must be at least |MD5_DIGEST_LENGTH| bytes of space in |out|. 42 OPENSSL_EXPORT uint8_t *MD5(const uint8_t *data, size_t len, 43 uint8_t out[MD5_DIGEST_LENGTH]); 44 45 // MD5_Transform is a low-level function that performs a single, MD5 block 46 // transformation using the state from |md5| and 64 bytes from |block|. 47 OPENSSL_EXPORT void MD5_Transform(MD5_CTX *md5, 48 const uint8_t block[MD5_CBLOCK]); 49 50 struct md5_state_st { 51 uint32_t h[4]; 52 uint32_t Nl, Nh; 53 uint8_t data[MD5_CBLOCK]; 54 unsigned num; 55 }; 56 57 58 #if defined(__cplusplus) 59 } // extern C 60 #endif 61 62 #endif // OPENSSL_HEADER_MD5_H 63