VirtualBox

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

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

include/iprt: Use IPRT_INCLUDED_ rather than _iprt_ as header guard prefix, letting scm enforce this (thereby avoiding copy&paste errors like rsa.h).

  • 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-2019 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_INCLUDED_md4_h
27#define IPRT_INCLUDED_md4_h
28#ifndef RT_WITHOUT_PRAGMA_ONCE
29# pragma once
30#endif
31
32#include <iprt/types.h>
33
34RT_C_DECLS_BEGIN
35
36/** @defgroup grp_rt_md4 RTMd4 - Message-Digest algorithm 4
37 * @ingroup grp_rt
38 *
39 * @note This is just for backwards compatibility and completeness.
40 *
41 * @{
42 */
43
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
48
49/**
50 * MD4 hash algorithm context.
51 */
52typedef union RTMD4CONTEXT
53{
54 uint64_t u64BetterAlignment;
55 uint8_t abPadding[22*4 + 64 + 8];
56#ifdef RT_MD4_PRIVATE_CONTEXT
57 MD4_CTX Private;
58#endif
59#ifdef RT_MD4_PRIVATE_ALT_CONTEXT
60 RTMD4ALTPRIVATECTX AltPrivate;
61#endif
62} RTMD4CONTEXT;
63
64/** Pointer to MD4 hash algorithm context. */
65typedef RTMD4CONTEXT *PRTMD4CONTEXT;
66
67
68/**
69 * Compute the MD4 hash of the data.
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 */
76RTDECL(void) RTMd4(const void *pvBuf, size_t cbBuf, uint8_t pabDigest[RTMD4_HASH_SIZE]);
77
78/**
79 * Initialize MD4 context.
80 *
81 * @param pCtx Pointer to the MD4 context to initialize.
82 */
83RTDECL(void) RTMd4Init(PRTMD4CONTEXT pCtx);
84
85/**
86 * Feed data into the MD4 computation.
87 *
88 * @param pCtx Pointer to the MD4 context.
89 * @param pvBuf Pointer to data.
90 * @param cbBuf Length of data (in bytes).
91 */
92RTDECL(void) RTMd4Update(PRTMD4CONTEXT pCtx, const void *pvBuf, size_t cbBuf);
93
94/**
95 * Compute the MD4 hash of the data.
96 *
97 * @param pCtx Pointer to the MD4 context.
98 * @param pabDigest Where to store the hash. (What's passed is a pointer to
99 * the caller's buffer.)
100 */
101RTDECL(void) RTMd4Final(PRTMD4CONTEXT pCtx, uint8_t pabDigest[RTMD4_HASH_SIZE]);
102
103/**
104 * Converts a MD4 hash to a digest string.
105 *
106 * @returns IPRT status code.
107 *
108 * @param pabDigest The binary digest returned by RTMd4Final or RTMd4.
109 * @param pszDigest Where to return the stringified digest.
110 * @param cchDigest The size of the output buffer. Should be at least
111 * RTMD4_STRING_LEN + 1 bytes.
112 */
113RTDECL(int) RTMd4ToString(uint8_t const pabDigest[RTMD4_HASH_SIZE], char *pszDigest, size_t cchDigest);
114
115/**
116 * Converts a MD4 hash to a digest string.
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 */
125RTDECL(int) RTMd4FromString(char const *pszDigest, uint8_t pabDigest[RTMD4_HASH_SIZE]);
126
127/** @} */
128
129RT_C_DECLS_END
130
131#endif
132
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