RetroArch
rhash.h
Go to the documentation of this file.
1 /* Copyright (C) 2010-2018 The RetroArch team
2  *
3  * ---------------------------------------------------------------------------------------
4  * The following license statement only applies to this file (rhash.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 /*
24  * sha1.h
25  *
26  * Copyright (C) 1998, 2009
27  * Paul E. Jones <[email protected]>
28  * All Rights Reserved
29  *
30  *****************************************************************************
31  * $Id: sha1.h 12 2009-06-22 19:34:25Z paulej $
32  *****************************************************************************
33  *
34  * Description:
35  * This class implements the Secure Hashing Standard as defined
36  * in FIPS PUB 180-1 published April 17, 1995.
37  *
38  * Many of the variable names in the SHA1Context, especially the
39  * single character names, were used because those were the names
40  * used in the publication.
41  *
42  * Please read the file sha1.c for more information.
43  *
44  */
45 
46 #ifndef __RARCH_HASH_H
47 #define __RARCH_HASH_H
48 
49 #include <stdint.h>
50 #include <stddef.h>
51 
52 #include <compat/msvc.h>
53 #ifdef HAVE_CONFIG_H
54 #include "config.h"
55 #endif
56 
57 #include <retro_inline.h>
58 
59 #include <retro_common_api.h>
60 
62 
71 void sha256_hash(char *out, const uint8_t *in, size_t size);
72 
73 typedef struct SHA1Context
74 {
75  unsigned Message_Digest[5]; /* Message Digest (output) */
76 
77  unsigned Length_Low; /* Message length in bits */
78  unsigned Length_High; /* Message length in bits */
79 
80  unsigned char Message_Block[64]; /* 512-bit message blocks */
81  int Message_Block_Index; /* Index into message block array */
82 
83  int Computed; /* Is the digest computed? */
84  int Corrupted; /* Is the message digest corruped? */
85 } SHA1Context;
86 
87 int sha1_calculate(const char *path, char *result);
88 
89 uint32_t djb2_calculate(const char *str);
90 
91 /* Any 32-bit or wider unsigned integer data type will do */
92 typedef unsigned int MD5_u32plus;
93 
94 typedef struct {
97  unsigned char buffer[64];
99 } MD5_CTX;
100 
101 /*
102  * This is an OpenSSL-compatible implementation of the RSA Data Security, Inc.
103  * MD5 Message-Digest Algorithm (RFC 1321).
104  *
105  * Homepage:
106  * http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5
107  *
108  * Author:
109  * Alexander Peslyak, better known as Solar Designer <solar at openwall.com>
110  *
111  * This software was written by Alexander Peslyak in 2001. No copyright is
112  * claimed, and the software is hereby placed in the public domain.
113  * In case this attempt to disclaim copyright and place the software in the
114  * public domain is deemed null and void, then the software is
115  * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the
116  * general public under the following terms:
117  *
118  * Redistribution and use in source and binary forms, with or without
119  * modification, are permitted.
120  *
121  * There's ABSOLUTELY NO WARRANTY, express or implied.
122  *
123  * See md5.c for more information.
124  */
125 
126 void MD5_Init(MD5_CTX *ctx);
127 void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size);
128 void MD5_Final(unsigned char *result, MD5_CTX *ctx);
129 
131 
132 #endif
int Corrupted
Definition: rhash.h:84
unsigned Length_Low
Definition: rhash.h:77
#define RETRO_BEGIN_DECLS
Definition: retro_common_api.h:41
Configuration options (set of defines)
unsigned Message_Digest[5]
Definition: rhash.h:75
GLsizei const GLchar ** path
Definition: glext.h:7901
GLsizeiptr size
Definition: glext.h:6559
struct passwd out
Definition: missing_libc_functions.c:51
Definition: ibxm.h:9
void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size)
Definition: md5.c:208
const GLubyte * c
Definition: glext.h:9812
GLboolean GLboolean GLboolean b
Definition: glext.h:6844
unsigned int MD5_u32plus
Definition: rhash.h:92
AVFormatContext * ctx
Definition: record_ffmpeg.c:247
struct SHA1Context SHA1Context
RETRO_BEGIN_DECLS void sha256_hash(char *out, const uint8_t *in, size_t size)
Definition: rhash.c:182
unsigned char Message_Block[64]
Definition: rhash.h:80
Definition: rhash.h:94
void MD5_Init(MD5_CTX *ctx)
Definition: md5.c:197
GLuint in
Definition: glext.h:10523
GLuint64EXT * result
Definition: glext.h:12211
uint32_t djb2_calculate(const char *str)
Definition: rhash.c:552
#define RETRO_END_DECLS
Definition: retro_common_api.h:42
static int block
Definition: psp2.c:31
Definition: rhash.h:73
int Message_Block_Index
Definition: rhash.h:81
MD5_u32plus d
Definition: rhash.h:96
void MD5_Final(unsigned char *result, MD5_CTX *ctx)
Definition: md5.c:245
unsigned Length_High
Definition: rhash.h:78
MD5_u32plus lo
Definition: rhash.h:95
Definition: video4linux2.c:51
unsigned char uint8_t
Definition: stdint.h:124
unsigned int uint32_t
Definition: stdint.h:126
const char *const str
Definition: portlistingparse.c:18
int sha1_calculate(const char *path, char *result)
Definition: rhash.c:509
int Computed
Definition: rhash.h:83
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6844