2 Unix SMB/CIFS implementation.
4 Copyright (C) Stefan Metzmacher
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "../lib/util/samba_util.h"
22 #include "../lib/crypto/crypto.h"
24 struct torture_context
;
26 bool torture_local_crypto_md5(struct torture_context
*torture
);
29 This uses the test values from rfc1321
31 bool torture_local_crypto_md5(struct torture_context
*torture
)
41 .md5
= "d41d8cd98f00b204e9800998ecf8427e"
44 .md5
= "0cc175b9c0f1b6a831c399e269772661"
47 .md5
= "900150983cd24fb0d6963f7d28e17f72"
49 .data
= "message digest",
50 .md5
= "f96b697d7cb7938d525a2f31aaf161d0"
52 .data
= "abcdefghijklmnopqrstuvwxyz",
53 .md5
= "c3fcd3d76192e4007dfb496cca67e13b"
55 .data
= "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
56 "abcdefghijklmnopqrstuvwxyz"
58 .md5
= "d174ab98d277d9f5a5611c2c9f419d9f"
60 .data
= "123456789012345678901234567890"
61 "123456789012345678901234567890"
62 "12345678901234567890",
63 .md5
= "57edf4a22be3c955ac49da2e2107b67a"
67 for (i
=0; i
< ARRAY_SIZE(testarray
); i
++) {
75 data
= data_blob_string_const(testarray
[i
].data
);
76 md5blob
= strhex_to_data_blob(NULL
, testarray
[i
].md5
);
79 MD5Update(&ctx
, data
.data
, data
.length
);
82 e
= memcmp(md5blob
.data
,
84 MIN(md5blob
.length
, sizeof(md5
)));
86 printf("md5 test[%u]: failed\n", i
);
87 dump_data(0, data
.data
, data
.length
);
88 dump_data(0, md5blob
.data
, md5blob
.length
);
89 dump_data(0, md5
, sizeof(md5
));
92 talloc_free(md5blob
.data
);