VirtualBox

source: vbox/trunk/include/iprt/md4.h@ 76417

Last change on this file since 76417 was 73705, checked in by vboxsync, 6 years ago

IPRT: Better fix for missing md4 failure; adding information status codes for indicating deprecated and compromised digests when used.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.8 KB
Line 
1/** @file
2 * IPRT - Message-Digest Algorithm 4.
3 */
4
5/*
6 * Copyright (C) 2006-2018 Oracle Corporation
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
26#ifndef ___iprt_md4_h
27#define ___iprt_md4_h
28
29#include <iprt/types.h>
30
31RT_C_DECLS_BEGIN
32
33/** @defgroup grp_rt_md4 RTMd4 - Message-Digest algorithm 4
34 * @ingroup grp_rt
35 *
36 * @note This is just for backwards compatibility and completeness.
37 *
38 * @{
39 */
40
41/** Size of a MD4 hash. */
42#define RTMD4_HASH_SIZE 16
43/** The length of a MD4 digest string. The terminator is not included. */
44#define RTMD4_DIGEST_LEN 32
45
46/**
47 * MD4 hash algorithm context.
48 */
49typedef union RTMD4CONTEXT
50{
51 uint64_t u64BetterAlignment;
52 uint8_t abPadding[22*4 + 64 + 8];
53#ifdef RT_MD4_PRIVATE_CONTEXT
54 MD4_CTX Private;
55#endif
56#ifdef RT_MD4_PRIVATE_ALT_CONTEXT
57 RTMD4ALTPRIVATECTX AltPrivate;
58#endif
59} RTMD4CONTEXT;
60
61/** Pointer to MD4 hash algorithm context. */
62typedef RTMD4CONTEXT *PRTMD4CONTEXT;
63
64
65/**
66 * Compute the MD4 hash of the data.
67 *
68 * @param pvBuf Pointer to data.
69 * @param cbBuf Length of data (in bytes).
70 * @param pabDigest Where to store the hash.
71 * (What's passed is a pointer to the caller's buffer.)
72 */
73RTDECL(void) RTMd4(const void *pvBuf, size_t cbBuf, uint8_t pabDigest[RTMD4_HASH_SIZE]);
74
75/**
76 * Initialize MD4 context.
77 *
78 * @param pCtx Pointer to the MD4 context to initialize.
79 */
80RTDECL(void) RTMd4Init(PRTMD4CONTEXT pCtx);
81
82/**
83 * Feed data into the MD4 computation.
84 *
85 * @param pCtx Pointer to the MD4 context.
86 * @param pvBuf Pointer to data.
87 * @param cbBuf Length of data (in bytes).
88 */
89RTDECL(void) RTMd4Update(PRTMD4CONTEXT pCtx, const void *pvBuf, size_t cbBuf);
90
91/**
92 * Compute the MD4 hash of the data.
93 *
94 * @param pCtx Pointer to the MD4 context.
95 * @param pabDigest Where to store the hash. (What's passed is a pointer to
96 * the caller's buffer.)
97 */
98RTDECL(void) RTMd4Final(PRTMD4CONTEXT pCtx, uint8_t pabDigest[RTMD4_HASH_SIZE]);
99
100/**
101 * Converts a MD4 hash to a digest string.
102 *
103 * @returns IPRT status code.
104 *
105 * @param pabDigest The binary digest returned by RTMd4Final or RTMd4.
106 * @param pszDigest Where to return the stringified digest.
107 * @param cchDigest The size of the output buffer. Should be at least
108 * RTMD4_STRING_LEN + 1 bytes.
109 */
110RTDECL(int) RTMd4ToString(uint8_t const pabDigest[RTMD4_HASH_SIZE], char *pszDigest, size_t cchDigest);
111
112/**
113 * Converts a MD4 hash to a digest string.
114 *
115 * @returns IPRT status code.
116 *
117 * @param pszDigest The stringified digest. Leading and trailing spaces are
118 * ignored.
119 * @param pabDigest Where to store the hash. (What is passed is a pointer to
120 * the caller's buffer.)
121 */
122RTDECL(int) RTMd4FromString(char const *pszDigest, uint8_t pabDigest[RTMD4_HASH_SIZE]);
123
124/** @} */
125
126RT_C_DECLS_END
127
128#endif
129
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette