-
Notifications
You must be signed in to change notification settings - Fork 13
/
test_shared.cxx
55 lines (49 loc) · 1.15 KB
/
test_shared.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <test_shared.hxx>
#include <cryptlib.h>
#include <sha.h>
#include <stdint.h>
extern "C" DLL_PUBLIC
int sha1_hash(uint8_t* digest, size_t dsize, const uint8_t* message, size_t msize)
{
using CryptoPP::SHA1;
using CryptoPP::Exception;
try
{
SHA1().CalculateTruncatedDigest(digest, dsize, message, msize);
return 0; // success
}
catch(const Exception&)
{
return 1; // failure
}
}
extern "C" DLL_PUBLIC
int sha256_hash(uint8_t* digest, size_t dsize, const uint8_t* message, size_t msize)
{
using CryptoPP::SHA256;
using CryptoPP::Exception;
try
{
SHA256().CalculateTruncatedDigest(digest, dsize, message, msize);
return 0; // success
}
catch(const Exception&)
{
return 1; // failure
}
}
extern "C" DLL_PUBLIC
int sha512_hash(uint8_t* digest, size_t dsize, const uint8_t* message, size_t msize)
{
using CryptoPP::SHA512;
using CryptoPP::Exception;
try
{
SHA512().CalculateTruncatedDigest(digest, dsize, message, msize);
return 0; // success
}
catch(const Exception&)
{
return 1; // failure
}
}