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 \**************************************************************************/
36 #include "libdetectcoll.h"
38 void gen_sha1_dv_xm_tables();
40 int main(int argc, char** argv) {
42 unsigned char hash[16];
43 unsigned char hash2[20];
50 gen_sha1_dv_xm_tables();
52 printf("Usage: md5sum <file>\n");
55 for (i=1; i < argc; ++i) {
56 fd = fopen(argv[i], "rb");
58 printf("cannot open file: %s\n", argv[i]);
63 SHA1Init_unsafe(&ctx2);
66 size=fread(buffer,1,65536,fd);
67 MD5Update(&ctx, buffer, size);
68 SHA1Update(&ctx2, buffer, size);
73 printf("error while reading file: %s\n", argv[i]);
77 printf("not end of file?: %s\n",argv[i]);
82 for (j = 0; j < 16; ++j)
83 sprintf(buffer+(j*2), "%02x", hash[j]);
85 if (ctx.found_collision) {
86 printf("md5 *coll* %s %s\n", buffer, argv[i]);
88 printf("md5 %s %s\n", buffer, argv[i]);
91 SHA1Final(hash2,&ctx2);
92 for (j = 0; j < 20; ++j)
93 sprintf(buffer+(j*2), "%02x", hash2[j]);
95 if (ctx2.found_collision) {
96 printf("sha1 *coll* %s %s\n", buffer, argv[i]);
98 printf("sha1 %s %s\n", buffer, argv[i]);