[51770] | 1 | /** @file
|
---|
[73705] | 2 | * IPRT - Message-Digest Algorithm 4.
|
---|
[51770] | 3 | */
|
---|
| 4 |
|
---|
| 5 | /*
|
---|
[76553] | 6 | * Copyright (C) 2006-2019 Oracle Corporation
|
---|
[51770] | 7 | *
|
---|
| 8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
| 9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
| 10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
| 11 | * General Public License (GPL) as published by the Free Software
|
---|
| 12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
| 13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
| 14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
| 15 | *
|
---|
| 16 | * The contents of this file may alternatively be used under the terms
|
---|
| 17 | * of the Common Development and Distribution License Version 1.0
|
---|
| 18 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
| 19 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
| 20 | * CDDL are applicable instead of those of the GPL.
|
---|
| 21 | *
|
---|
| 22 | * You may elect to license modified versions of this file under the
|
---|
| 23 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
| 24 | */
|
---|
| 25 |
|
---|
[76557] | 26 | #ifndef IPRT_INCLUDED_md4_h
|
---|
| 27 | #define IPRT_INCLUDED_md4_h
|
---|
[76507] | 28 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
| 29 | # pragma once
|
---|
| 30 | #endif
|
---|
[51770] | 31 |
|
---|
| 32 | #include <iprt/types.h>
|
---|
| 33 |
|
---|
| 34 | RT_C_DECLS_BEGIN
|
---|
| 35 |
|
---|
[73705] | 36 | /** @defgroup grp_rt_md4 RTMd4 - Message-Digest algorithm 4
|
---|
[51770] | 37 | * @ingroup grp_rt
|
---|
[73705] | 38 | *
|
---|
| 39 | * @note This is just for backwards compatibility and completeness.
|
---|
| 40 | *
|
---|
[51770] | 41 | * @{
|
---|
| 42 | */
|
---|
| 43 |
|
---|
[73705] | 44 | /** Size of a MD4 hash. */
|
---|
| 45 | #define RTMD4_HASH_SIZE 16
|
---|
| 46 | /** The length of a MD4 digest string. The terminator is not included. */
|
---|
| 47 | #define RTMD4_DIGEST_LEN 32
|
---|
[51770] | 48 |
|
---|
| 49 | /**
|
---|
[73705] | 50 | * MD4 hash algorithm context.
|
---|
[51770] | 51 | */
|
---|
[73705] | 52 | typedef union RTMD4CONTEXT
|
---|
[51770] | 53 | {
|
---|
[51822] | 54 | uint64_t u64BetterAlignment;
|
---|
[73705] | 55 | uint8_t abPadding[22*4 + 64 + 8];
|
---|
| 56 | #ifdef RT_MD4_PRIVATE_CONTEXT
|
---|
| 57 | MD4_CTX Private;
|
---|
[51770] | 58 | #endif
|
---|
[73705] | 59 | #ifdef RT_MD4_PRIVATE_ALT_CONTEXT
|
---|
| 60 | RTMD4ALTPRIVATECTX AltPrivate;
|
---|
[51822] | 61 | #endif
|
---|
[73705] | 62 | } RTMD4CONTEXT;
|
---|
[51770] | 63 |
|
---|
[73705] | 64 | /** Pointer to MD4 hash algorithm context. */
|
---|
| 65 | typedef RTMD4CONTEXT *PRTMD4CONTEXT;
|
---|
[51770] | 66 |
|
---|
| 67 |
|
---|
| 68 | /**
|
---|
[73705] | 69 | * Compute the MD4 hash of the data.
|
---|
[51770] | 70 | *
|
---|
| 71 | * @param pvBuf Pointer to data.
|
---|
| 72 | * @param cbBuf Length of data (in bytes).
|
---|
| 73 | * @param pabDigest Where to store the hash.
|
---|
| 74 | * (What's passed is a pointer to the caller's buffer.)
|
---|
| 75 | */
|
---|
[73705] | 76 | RTDECL(void) RTMd4(const void *pvBuf, size_t cbBuf, uint8_t pabDigest[RTMD4_HASH_SIZE]);
|
---|
[51770] | 77 |
|
---|
| 78 | /**
|
---|
[73705] | 79 | * Initialize MD4 context.
|
---|
[51770] | 80 | *
|
---|
[73705] | 81 | * @param pCtx Pointer to the MD4 context to initialize.
|
---|
[51770] | 82 | */
|
---|
[73705] | 83 | RTDECL(void) RTMd4Init(PRTMD4CONTEXT pCtx);
|
---|
[51770] | 84 |
|
---|
| 85 | /**
|
---|
[73705] | 86 | * Feed data into the MD4 computation.
|
---|
[51770] | 87 | *
|
---|
[73705] | 88 | * @param pCtx Pointer to the MD4 context.
|
---|
[51770] | 89 | * @param pvBuf Pointer to data.
|
---|
| 90 | * @param cbBuf Length of data (in bytes).
|
---|
| 91 | */
|
---|
[73705] | 92 | RTDECL(void) RTMd4Update(PRTMD4CONTEXT pCtx, const void *pvBuf, size_t cbBuf);
|
---|
[51770] | 93 |
|
---|
| 94 | /**
|
---|
[73705] | 95 | * Compute the MD4 hash of the data.
|
---|
[51770] | 96 | *
|
---|
[73705] | 97 | * @param pCtx Pointer to the MD4 context.
|
---|
[51770] | 98 | * @param pabDigest Where to store the hash. (What's passed is a pointer to
|
---|
| 99 | * the caller's buffer.)
|
---|
| 100 | */
|
---|
[73705] | 101 | RTDECL(void) RTMd4Final(PRTMD4CONTEXT pCtx, uint8_t pabDigest[RTMD4_HASH_SIZE]);
|
---|
[51770] | 102 |
|
---|
| 103 | /**
|
---|
[73705] | 104 | * Converts a MD4 hash to a digest string.
|
---|
[51770] | 105 | *
|
---|
| 106 | * @returns IPRT status code.
|
---|
| 107 | *
|
---|
[73705] | 108 | * @param pabDigest The binary digest returned by RTMd4Final or RTMd4.
|
---|
[51770] | 109 | * @param pszDigest Where to return the stringified digest.
|
---|
| 110 | * @param cchDigest The size of the output buffer. Should be at least
|
---|
[73705] | 111 | * RTMD4_STRING_LEN + 1 bytes.
|
---|
[51770] | 112 | */
|
---|
[73705] | 113 | RTDECL(int) RTMd4ToString(uint8_t const pabDigest[RTMD4_HASH_SIZE], char *pszDigest, size_t cchDigest);
|
---|
[51770] | 114 |
|
---|
| 115 | /**
|
---|
[73705] | 116 | * Converts a MD4 hash to a digest string.
|
---|
[51770] | 117 | *
|
---|
| 118 | * @returns IPRT status code.
|
---|
| 119 | *
|
---|
| 120 | * @param pszDigest The stringified digest. Leading and trailing spaces are
|
---|
| 121 | * ignored.
|
---|
| 122 | * @param pabDigest Where to store the hash. (What is passed is a pointer to
|
---|
| 123 | * the caller's buffer.)
|
---|
| 124 | */
|
---|
[73705] | 125 | RTDECL(int) RTMd4FromString(char const *pszDigest, uint8_t pabDigest[RTMD4_HASH_SIZE]);
|
---|
[51770] | 126 |
|
---|
| 127 | /** @} */
|
---|
| 128 |
|
---|
| 129 | RT_C_DECLS_END
|
---|
| 130 |
|
---|
[76585] | 131 | #endif /* !IPRT_INCLUDED_md4_h */
|
---|
[51770] | 132 |
|
---|