VirtualBox

source: vbox/trunk/include/iprt/md2.h@ 78364

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

*: scm --fix-header-guard-endif

  • 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 2.
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_md2_h
27#define IPRT_INCLUDED_md2_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_md2 RTMd2 - Message-Digest algorithm 2
37 * @ingroup grp_rt
38 * @{
39 */
40
41/** Size of a MD2 hash. */
42#define RTMD2_HASH_SIZE 16
43/** The length of a MD2 digest string. The terminator is not included. */
44#define RTMD2_DIGEST_LEN 32
45
46/**
47 * MD2 hash algorithm context.
48 */
49typedef union RTMD2CONTEXT
50{
51 uint64_t u64BetterAlignment;
52 uint8_t abPadding[4 + 16 + 16*4 + 16*4];
53#ifdef RT_MD2_PRIVATE_CONTEXT
54 MD2_CTX Private;
55#endif
56#ifdef RT_MD2_PRIVATE_ALT_CONTEXT
57 RTMD2ALTPRIVATECTX AltPrivate;
58#endif
59} RTMD2CONTEXT;
60
61/** Pointer to MD2 hash algorithm context. */
62typedef RTMD2CONTEXT *PRTMD2CONTEXT;
63
64
65/**
66 * Compute the MD2 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) RTMd2(const void *pvBuf, size_t cbBuf, uint8_t pabDigest[RTMD2_HASH_SIZE]);
74
75/**
76 * Initialize MD2 context.
77 *
78 * @param pCtx Pointer to the MD2 context to initialize.
79 */
80RTDECL(void) RTMd2Init(PRTMD2CONTEXT pCtx);
81
82/**
83 * Feed data into the MD2 computation.
84 *
85 * @param pCtx Pointer to the MD2 context.
86 * @param pvBuf Pointer to data.
87 * @param cbBuf Length of data (in bytes).
88 */
89RTDECL(void) RTMd2Update(PRTMD2CONTEXT pCtx, const void *pvBuf, size_t cbBuf);
90
91/**
92 * Compute the MD2 hash of the data.
93 *
94 * @param pCtx Pointer to the MD2 context.
95 * @param pabDigest Where to store the hash. (What's passed is a pointer to
96 * the caller's buffer.)
97 */
98RTDECL(void) RTMd2Final(PRTMD2CONTEXT pCtx, uint8_t pabDigest[RTMD2_HASH_SIZE]);
99
100/**
101 * Converts a MD2 hash to a digest string.
102 *
103 * @returns IPRT status code.
104 *
105 * @param pabDigest The binary digest returned by RTMd2Final or RTMd2.
106 * @param pszDigest Where to return the stringified digest.
107 * @param cchDigest The size of the output buffer. Should be at least
108 * RTMD2_STRING_LEN + 1 bytes.
109 */
110RTDECL(int) RTMd2ToString(uint8_t const pabDigest[RTMD2_HASH_SIZE], char *pszDigest, size_t cchDigest);
111
112/**
113 * Converts a MD2 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) RTMd2FromString(char const *pszDigest, uint8_t pabDigest[RTMD2_HASH_SIZE]);
123
124/** @} */
125
126RT_C_DECLS_END
127
128#endif /* !IPRT_INCLUDED_md2_h */
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