git subrepo pull --force deps/lightrec
[pcsx_rearmed.git] / deps / libretro-common / include / lrc_hash.h
CommitLineData
3719602c
PC
1/* Copyright (C) 2010-2020 The RetroArch team
2 *
3 * ---------------------------------------------------------------------------------------
4 * The following license statement only applies to this file (lrc_hash.h).
5 * ---------------------------------------------------------------------------------------
6 *
7 * Permission is hereby granted, free of charge,
8 * to any person obtaining a copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation the rights to
10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
11 * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 */
22
23#ifndef __LIBRETRO_SDK_HASH_H
24#define __LIBRETRO_SDK_HASH_H
25
26#include <stdint.h>
27#include <stddef.h>
28
29#include <compat/msvc.h>
30#ifdef HAVE_CONFIG_H
31#include "config.h"
32#endif
33
34#include <retro_inline.h>
35
36#include <retro_common_api.h>
37
38RETRO_BEGIN_DECLS
39
40/**
41 * sha256_hash:
42 * @out : Output.
43 * @in : Input.
44 * @size : Size of @out.
45 *
46 * Hashes SHA256 and outputs a human readable string.
47 **/
48void sha256_hash(char *out, const uint8_t *in, size_t size);
49
50int sha1_calculate(const char *path, char *result);
51
52uint32_t djb2_calculate(const char *str);
53
54/* Any 32-bit or wider unsigned integer data type will do */
55typedef unsigned int MD5_u32plus;
56
57typedef struct {
58 MD5_u32plus lo, hi;
59 MD5_u32plus a, b, c, d;
60 unsigned char buffer[64];
61 MD5_u32plus block[16];
62} MD5_CTX;
63
64/*
65 * This is an OpenSSL-compatible implementation of the RSA Data Security, Inc.
66 * MD5 Message-Digest Algorithm (RFC 1321).
67 *
68 * Homepage:
69 * http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5
70 *
71 * Author:
72 * Alexander Peslyak, better known as Solar Designer <solar at openwall.com>
73 *
74 * This software was written by Alexander Peslyak in 2001. No copyright is
75 * claimed, and the software is hereby placed in the public domain.
76 * In case this attempt to disclaim copyright and place the software in the
77 * public domain is deemed null and void, then the software is
78 * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the
79 * general public under the following terms:
80 *
81 * Redistribution and use in source and binary forms, with or without
82 * modification, are permitted.
83 *
84 * There's ABSOLUTELY NO WARRANTY, express or implied.
85 *
86 * See md5.c for more information.
87 */
88
89void MD5_Init(MD5_CTX *ctx);
90void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size);
91void MD5_Final(unsigned char *result, MD5_CTX *ctx);
92
93RETRO_END_DECLS
94
95#endif