1 /**************************************************************************\
3 | Copyright (C) 2012 CWI
8 | Centrum Wiskunde & Informatica
9 | P.O. Box 94079, 1090 GB Amsterdam, Netherlands
10 | marc@marc-stevens.nl
12 | Permission is hereby granted, free of charge, to any person obtaining a copy
13 | of this software and associated documentation files (the "Software"), to deal
14 | in the Software without restriction, including without limitation the rights
15 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16 | copies of the Software, and to permit persons to whom the Software is
17 | furnished to do so, subject to the following conditions:
19 | The above copyright notice and this permission notice shall be included in
20 | all copies or substantial portions of the Software.
22 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30 \**************************************************************************/
34 // lib interface below
39 unsigned char buffer[64];
48 uint32_t statesmsb[260];
50 uint32_t tmpblock[16];
52 uint32_t prevblock[16];
56 void md5compress_states(uint32_t ihv[4], const uint32_t block[16], uint32_t states[260]);
57 int md5recompress_fast(unsigned t, uint32_t ihv[4], const uint32_t block[16], const uint32_t state[4], const uint32_t rihv[4]);
58 int detect_coll(const uint32_t block1[16], const uint32_t states[260], const uint32_t statesmsb[260], const uint32_t tihv[4], uint32_t ihv2[4], uint32_t block2[16]);
67 extern msgdiff_tuples_t msgdiff_tuples[];
72 unsigned char buffer[64];
81 uint32_t states[81*5];
84 void sha1compress_me(const uint32_t block[16], uint32_t me[80]);
85 void sha1compress_states(uint32_t ihv[5], const uint32_t me[80], uint32_t states[81*5]);
86 int sha1recompress_fast(unsigned t, uint32_t ihv[5], const uint32_t me[80], const uint32_t state[5], const uint32_t rihv[5]);
92 void MD5Init(MD5_CTX*); // outputs MD5 hash if no collision was found and a modified-MD5 hash otherwise
93 void MD5Init_unsafe(MD5_CTX*); // always outputs MD5 hash
94 void MD5Update(MD5_CTX*, const char* buf, unsigned len);
95 int MD5Final(unsigned char hash[16], MD5_CTX*); // returns: 0 = no collision, otherwise = collision found => warn user for active attack
97 void SHA1Init(SHA1_CTX*); // outputs SHA-1 hash if no collision was found and a modified-SHA-1 hash otherwise
98 void SHA1Init_unsafe(SHA1_CTX*); // always outputs SHA-1 hash
99 void SHA1Update(SHA1_CTX*, const char* buf, unsigned len);
100 int SHA1Final(unsigned char hash[20], SHA1_CTX*); // returns: 0 = no collision, otherwise = collision found => warn user for active attack