| 1 |
// Copyright (C) 1995-1998 Eric Young ([email protected]) All rights reserved. |
| 2 |
// SPDX-License-Identifier: Apache-2.0 |
| 3 |
|
| 4 |
#ifndef OPENSSL_HEADER_MD5_H |
| 5 |
#define OPENSSL_HEADER_MD5_H |
| 6 |
|
| 7 |
#include <openssl/base.h> |
| 8 |
|
| 9 |
#if defined(__cplusplus) |
| 10 |
extern "C" { |
| 11 |
#endif |
| 12 |
|
| 13 |
|
| 14 |
// MD5. |
| 15 |
|
| 16 |
|
| 17 |
// MD5_CBLOCK is the block size of MD5. |
| 18 |
#define MD5_CBLOCK 64 |
| 19 |
|
| 20 |
// MD5_DIGEST_LENGTH is the length of an MD5 digest. |
| 21 |
#define MD5_DIGEST_LENGTH 16 |
| 22 |
|
| 23 |
// MD5_Init initialises |md5| and returns one. |
| 24 |
OPENSSL_EXPORT int MD5_Init(MD5_CTX *md5); |
| 25 |
|
| 26 |
// MD5_Update adds |len| bytes from |data| to |md5| and returns one. |
| 27 |
OPENSSL_EXPORT int MD5_Update(MD5_CTX *md5, const void *data, size_t len); |
| 28 |
|
| 29 |
// MD5_Final adds the final padding to |md5| and writes the resulting digest to |
| 30 |
// |out|, which must have at least |MD5_DIGEST_LENGTH| bytes of space. It |
| 31 |
// returns one. |
| 32 |
OPENSSL_EXPORT int MD5_Final(uint8_t out[MD5_DIGEST_LENGTH], MD5_CTX *md5); |
| 33 |
|
| 34 |
// MD5 writes the digest of |len| bytes from |data| to |out| and returns |out|. |
| 35 |
// There must be at least |MD5_DIGEST_LENGTH| bytes of space in |out|. |
| 36 |
OPENSSL_EXPORT uint8_t *MD5(const uint8_t *data, size_t len, |
| 37 |
uint8_t out[MD5_DIGEST_LENGTH]); |
| 38 |
|
| 39 |
// MD5_Transform is a low-level function that performs a single, MD5 block |
| 40 |
// transformation using the state from |md5| and 64 bytes from |block|. |
| 41 |
OPENSSL_EXPORT void MD5_Transform(MD5_CTX *md5, |
| 42 |
const uint8_t block[MD5_CBLOCK]); |
| 43 |
|
| 44 |
struct md5_state_st { |
| 45 |
uint32_t h[4]; |
| 46 |
uint32_t Nl, Nh; |
| 47 |
uint8_t data[MD5_CBLOCK]; |
| 48 |
unsigned num; |
| 49 |
}; |
| 50 |
|
| 51 |
|
| 52 |
#if defined(__cplusplus) |
| 53 |
} // extern C |
| 54 |
#endif |
| 55 |
|
| 56 |
#endif // OPENSSL_HEADER_MD5_H |