VirtualBox

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

Last change on this file since 60343 was 56291, checked in by vboxsync, 10 years ago

include: Updated (C) year.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.7 KB
Line 
1/** @file
2 * IPRT - Message-Digest Algorithm 2.
3 */
4
5/*
6 * Copyright (C) 2006-2015 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_md2_h
27#define ___iprt_md2_h
28
29#include <iprt/types.h>
30
31RT_C_DECLS_BEGIN
32
33/** @defgroup grp_rt_md2 RTMd2 - Message-Digest algorithm 2
34 * @ingroup grp_rt
35 * @{
36 */
37
38/** Size of a MD2 hash. */
39#define RTMD2_HASH_SIZE 16
40/** The length of a MD2 digest string. The terminator is not included. */
41#define RTMD2_DIGEST_LEN 32
42
43/**
44 * MD2 hash algorithm context.
45 */
46typedef union RTMD2CONTEXT
47{
48 uint64_t u64BetterAlignment;
49 uint8_t abPadding[4 + 16 + 16*4 + 16*4];
50#ifdef RT_MD2_PRIVATE_CONTEXT
51 MD2_CTX Private;
52#endif
53#ifdef RT_MD2_PRIVATE_ALT_CONTEXT
54 RTMD2ALTPRIVATECTX AltPrivate;
55#endif
56} RTMD2CONTEXT;
57
58/** Pointer to MD2 hash algorithm context. */
59typedef RTMD2CONTEXT *PRTMD2CONTEXT;
60
61
62/**
63 * Compute the MD2 hash of the data.
64 *
65 * @param pvBuf Pointer to data.
66 * @param cbBuf Length of data (in bytes).
67 * @param pabDigest Where to store the hash.
68 * (What's passed is a pointer to the caller's buffer.)
69 */
70RTDECL(void) RTMd2(const void *pvBuf, size_t cbBuf, uint8_t pabDigest[RTMD2_HASH_SIZE]);
71
72/**
73 * Initialize MD2 context.
74 *
75 * @param pCtx Pointer to the MD2 context to initialize.
76 */
77RTDECL(void) RTMd2Init(PRTMD2CONTEXT pCtx);
78
79/**
80 * Feed data into the MD2 computation.
81 *
82 * @param pCtx Pointer to the MD2 context.
83 * @param pvBuf Pointer to data.
84 * @param cbBuf Length of data (in bytes).
85 */
86RTDECL(void) RTMd2Update(PRTMD2CONTEXT pCtx, const void *pvBuf, size_t cbBuf);
87
88/**
89 * Compute the MD2 hash of the data.
90 *
91 * @param pCtx Pointer to the MD2 context.
92 * @param pabDigest Where to store the hash. (What's passed is a pointer to
93 * the caller's buffer.)
94 */
95RTDECL(void) RTMd2Final(PRTMD2CONTEXT pCtx, uint8_t pabDigest[RTMD2_HASH_SIZE]);
96
97/**
98 * Converts a MD2 hash to a digest string.
99 *
100 * @returns IPRT status code.
101 *
102 * @param pabDigest The binary digest returned by RTMd2Final or RTMd2.
103 * @param pszDigest Where to return the stringified digest.
104 * @param cchDigest The size of the output buffer. Should be at least
105 * RTMD2_STRING_LEN + 1 bytes.
106 */
107RTDECL(int) RTMd2ToString(uint8_t const pabDigest[RTMD2_HASH_SIZE], char *pszDigest, size_t cchDigest);
108
109/**
110 * Converts a MD2 hash to a digest string.
111 *
112 * @returns IPRT status code.
113 *
114 * @param pszDigest The stringified digest. Leading and trailing spaces are
115 * ignored.
116 * @param pabDigest Where to store the hash. (What is passed is a pointer to
117 * the caller's buffer.)
118 */
119RTDECL(int) RTMd2FromString(char const *pszDigest, uint8_t pabDigest[RTMD2_HASH_SIZE]);
120
121/** @} */
122
123RT_C_DECLS_END
124
125#endif
126
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