plibsys
pcryptohash.h
Go to the documentation of this file.
1 /*
2  * The MIT License
3  *
4  * Copyright (C) 2010-2016 Alexander Saprykin <saprykin.spb@gmail.com>
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining
7  * a copy of this software and associated documentation files (the
8  * 'Software'), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sublicense, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be
15  * included in all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  */
25 
72 #if !defined (PLIBSYS_H_INSIDE) && !defined (PLIBSYS_COMPILATION)
73 # error "Header files shouldn't be included directly, consider using <plibsys.h> instead."
74 #endif
75 
76 #ifndef PLIBSYS_HEADER_PCRYPTOHASH_H
77 #define PLIBSYS_HEADER_PCRYPTOHASH_H
78 
79 #include <pmacros.h>
80 #include <ptypes.h>
81 
83 
85 typedef struct PCryptoHash_ PCryptoHash;
86 
88 typedef enum PCryptoHashType_ {
101 
110 
121  const puchar *data,
122  psize len);
123 
134 
146 
158  puchar *buf,
159  psize *len);
160 
170 
178 
185 
187 
188 #endif /* PLIBSYS_HEADER_PCRYPTOHASH_H */
P_LIB_API void p_crypto_hash_reset(PCryptoHash *hash)
Resets a hash state.
#define P_END_DECLS
Closes .h file declarations to be exported as C functions, should be always used after P_BEGIN_DECLS...
Definition: pmacros.h:299
P_LIB_API void p_crypto_hash_free(PCryptoHash *hash)
Frees a previously initialized hash context.
SHA-2/256 hash function.
Definition: pcryptohash.h:92
P_LIB_API pssize p_crypto_hash_get_length(const PCryptoHash *hash)
Gets a hash digest length depending on its type.
SHA-2/512 hash function.
Definition: pcryptohash.h:94
SHA-2/224 hash function.
Definition: pcryptohash.h:91
P_LIB_API PCryptoHash * p_crypto_hash_new(PCryptoHashType type)
Initializes a new PCryptoHash context.
enum PCryptoHashType_ PCryptoHashType
Cryptographic hash function types for PCryptoHash.
char pchar
Type for a char.
Definition: ptypes.h:116
MD5 hash function.
Definition: pcryptohash.h:89
P_LIB_API pchar * p_crypto_hash_get_string(PCryptoHash *hash)
Gets a hash in a hexidemical representation.
GOST (R 34.11-94) hash function.
Definition: pcryptohash.h:99
unsigned int psize
Type for a platform independent size_t.
Definition: ptypes.h:224
Miscellaneous macros.
SHA-2/384 hash function.
Definition: pcryptohash.h:97
SHA-2/224 hash function.
Definition: pcryptohash.h:95
P_LIB_API PCryptoHashType p_crypto_hash_get_type(const PCryptoHash *hash)
Gets a hash function type.
SHA-3/512 hash function.
Definition: pcryptohash.h:98
unsigned char puchar
Type for an unsigned char.
Definition: ptypes.h:125
SHA-2/384 hash function.
Definition: pcryptohash.h:93
P_LIB_API void p_crypto_hash_get_digest(PCryptoHash *hash, puchar *buf, psize *len)
Gets a hash in a raw representation.
#define P_LIB_API
Exports a symbol from a shared library.
Definition: pmacros.h:138
PCryptoHashType_
Cryptographic hash function types for PCryptoHash.
Definition: pcryptohash.h:88
SHA-1 hash function.
Definition: pcryptohash.h:90
P_LIB_API void p_crypto_hash_update(PCryptoHash *hash, const puchar *data, psize len)
Adds a new chunk of data for hashing.
typedefP_BEGIN_DECLS struct PCryptoHash_ PCryptoHash
Opaque data structure for handling a cryptographic hash context.
Definition: pcryptohash.h:85
SHA-2/256 hash function.
Definition: pcryptohash.h:96
Types definitions.
signed int pssize
Type for a platform independent signed size_t.
Definition: ptypes.h:223
#define P_BEGIN_DECLS
Starts .h file declarations to be exported as C functions.
Definition: pmacros.h:298