1e5c31af7Sopenharmony_ci#ifndef _VKMD5SUM_HPP
2e5c31af7Sopenharmony_ci#define _VKMD5SUM_HPP
3e5c31af7Sopenharmony_ci/*------------------------------------------------------------------------
4e5c31af7Sopenharmony_ci * Vulkan Conformance Tests
5e5c31af7Sopenharmony_ci * ------------------------
6e5c31af7Sopenharmony_ci *
7e5c31af7Sopenharmony_ci * Copyright (c) 2023 The Khronos Group Inc.
8e5c31af7Sopenharmony_ci * Copyright (c) 2023 The SQLite Project.
9e5c31af7Sopenharmony_ci *
10e5c31af7Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
11e5c31af7Sopenharmony_ci * you may not use this file except in compliance with the License.
12e5c31af7Sopenharmony_ci * You may obtain a copy of the License at
13e5c31af7Sopenharmony_ci *
14e5c31af7Sopenharmony_ci *	  http://www.apache.org/licenses/LICENSE-2.0
15e5c31af7Sopenharmony_ci *
16e5c31af7Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
17e5c31af7Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
18e5c31af7Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19e5c31af7Sopenharmony_ci * See the License for the specific language governing permissions and
20e5c31af7Sopenharmony_ci * limitations under the License.
21e5c31af7Sopenharmony_ci *
22e5c31af7Sopenharmony_ci *//*!
23e5c31af7Sopenharmony_ci * \file
24e5c31af7Sopenharmony_ci * \brief Utilities for calculating MD5 checksums.
25e5c31af7Sopenharmony_ci *
26e5c31af7Sopenharmony_ci * This file was modified from Chromium,
27e5c31af7Sopenharmony_ci * https://chromium.googlesource.com/chromium/src/base/+/7ef85b701132474f71e6369f081a2fb84582ee88/md5.h
28e5c31af7Sopenharmony_ci *
29e5c31af7Sopenharmony_ci * This code implements the MD5 message-digest algorithm.
30e5c31af7Sopenharmony_ci * The algorithm is due to Ron Rivest.  This code was
31e5c31af7Sopenharmony_ci * written by Colin Plumb in 1993, no copyright is claimed.
32e5c31af7Sopenharmony_ci * This code is in the public domain; do with it what you wish.
33e5c31af7Sopenharmony_ci *
34e5c31af7Sopenharmony_ci * Equivalent code is available from RSA Data Security, Inc.
35e5c31af7Sopenharmony_ci * This code has been tested against that, and is equivalent,
36e5c31af7Sopenharmony_ci * except that you don't need to include two pages of legalese
37e5c31af7Sopenharmony_ci * with every copy.
38e5c31af7Sopenharmony_ci *
39e5c31af7Sopenharmony_ci * To compute the message digest of a chunk of bytes, declare an
40e5c31af7Sopenharmony_ci * MD5Context structure, pass it to MD5Init, call MD5Update as
41e5c31af7Sopenharmony_ci * needed on buffers full of bytes, and then call MD5Final, which
42e5c31af7Sopenharmony_ci * will fill a supplied 16-byte array with the digest.
43e5c31af7Sopenharmony_ci *--------------------------------------------------------------------*/
44e5c31af7Sopenharmony_ci
45e5c31af7Sopenharmony_ci#include <cstdint>
46e5c31af7Sopenharmony_ci#include <deDefs.h>
47e5c31af7Sopenharmony_ci#include <string>
48e5c31af7Sopenharmony_ci
49e5c31af7Sopenharmony_cinamespace vk
50e5c31af7Sopenharmony_ci{
51e5c31af7Sopenharmony_ci
52e5c31af7Sopenharmony_ci// The output of an MD5 operation.
53e5c31af7Sopenharmony_cistruct MD5Digest
54e5c31af7Sopenharmony_ci{
55e5c31af7Sopenharmony_ci	unsigned char a[16];
56e5c31af7Sopenharmony_ci};
57e5c31af7Sopenharmony_ci
58e5c31af7Sopenharmony_ci// Used for storing intermediate data during an MD5 computation. Callers
59e5c31af7Sopenharmony_ci// should not access the data.
60e5c31af7Sopenharmony_citypedef char MD5Context[88];
61e5c31af7Sopenharmony_ci
62e5c31af7Sopenharmony_civoid MD5Sum(const void* data, std::size_t length, MD5Digest* digest);
63e5c31af7Sopenharmony_ci
64e5c31af7Sopenharmony_ci// Converts a digest into human-readable hexadecimal.
65e5c31af7Sopenharmony_cistd::string MD5DigestToBase16(const MD5Digest& digest);
66e5c31af7Sopenharmony_ci
67e5c31af7Sopenharmony_ci// Helper for doing the common case of MD5Sum followed by MD5DigestToBase16.
68e5c31af7Sopenharmony_cistd::string MD5SumBase16(const void* data, std::size_t length);
69e5c31af7Sopenharmony_ci
70e5c31af7Sopenharmony_ci} // namespace vk
71e5c31af7Sopenharmony_ci
72e5c31af7Sopenharmony_ci#endif // _VKMD5SUM_HPP
73