Add install target
[tmk.git] / tm_crypto.h
blob709dde33205ce4ab5635f6a290803873e65a13e4
2 /*
4 Copyright (c) 2016, Andre Schalkwyk and Cory Burgett
5 All rights reserved.
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
10 * Redistributions of source code must retain the above copyright notice, this
11 list of conditions and the following disclaimer.
13 * Redistributions in binary form must reproduce the above copyright notice,
14 this list of conditions and the following disclaimer in the documentation
15 and/or other materials provided with the distribution.
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #ifndef TM_CRYPTO_H
31 #define TM_CRYPTO_H
33 #define TM_CRYPTO_USAGE_ERROR 0x1
34 #define TM_CRYPTO_FILE_ERROR 0x2
36 #define CRYPTO_HASH_SIZE 20
37 #define CRYPTO_HASH_STRING_LENGTH 41
39 void tm_CryptoHashData(const unsigned char* data, unsigned char digest[CRYPTO_HASH_SIZE]);
40 void tm_CryptoHashFile(const char* file, unsigned char digest[CRYPTO_HASH_SIZE]);
41 void tm_CryptoHashToString(const unsigned char digest[CRYPTO_HASH_SIZE], char hash[CRYPTO_HASH_STRING_LENGTH]);
43 #define TM_CRYPTO_HASH_DATA(DATA, DIGEST) tm_CryptoHashData((const unsigned char*)(DATA), (unsigned char*)(DIGEST))
44 #define TM_CRYPTO_HASH_FILE(FILE, DIGEST) tm_CryptoHashFile((const char*)(FILE), (unsigned char*)(DIGEST))
45 #define TM_CRYPTO_HASH_TO_STRING(DIGEST, HASH) tm_CryptoHashToString((const unsigned char*)(DIGEST), (char*)(HASH))
46 #endif