2 * Copyright (C) 2004, 2005 Free Software Foundation
4 * This file is part of GNUTLS.
6 * GNUTLS 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 * GNUTLS 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, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
33 is_secure_mem (const void *ign
)
44 /* XXX: We need this to fix secure memory. */
49 fail ("gc_init() failed: %d\n", err
);
51 gc_set_allocators (malloc
, malloc
, is_secure_mem
, realloc
, free
);
53 err
= gc_md5 ("abcdefgh", 8, digest
);
55 fail ("gc_md5() failed: %d\n", err
);
58 if (memcmp (digest
, "\xe8\xdc\x40\x81\xb1\x34\x34\xb4"
59 "\x51\x89\xa7\x20\xb7\x7b\x68\x18", 16) == 0)
60 success ("gc_md5() OK\n");
63 hexprint (digest
, 16);
64 fail ("gc_md5() failure\n");
68 err
= gc_hash_buffer (GC_MD5
, "abcdefgh", 8, digest
);
70 fail ("gc_hash_buffer(GC_MD5) failed: %d\n", err
);
73 if (memcmp (digest
, "\xe8\xdc\x40\x81\xb1\x34\x34\xb4"
74 "\x51\x89\xa7\x20\xb7\x7b\x68\x18", 16) == 0)
75 success ("gc_hash_buffer(GC_MD5) OK\n");
78 hexprint (digest
, 16);
79 fail ("gc_hash_buffer(GC_MD5) failure\n");
83 err
= gc_hash_buffer (GC_SHA1
, "abcdefgh", 8, digest
);
85 fail ("gc_hash_buffer(GC_SHA1) failed: %d\n", err
);
88 if (memcmp (digest
, "\x42\x5a\xf1\x2a\x07\x43\x50\x2b"
89 "\x32\x2e\x93\xa0\x15\xbc\xf8\x68\xe3\x24\xd5\x6a",
91 success ("gc_hash_buffer(GC_SHA1) OK\n");
94 hexprint (digest
, 20);
95 fail ("gc_hash_buffer(GC_SHA1) failure\n");
99 err
= gc_hmac_md5 ("keykeykey", 9, "abcdefgh", 8, digest
);
101 fail ("gc_hmac_md5() failed: %d\n", err
);
104 if (memcmp (digest
, "\x3c\xb0\x9d\x83\x28\x01\xef\xc0"
105 "\x7b\xb3\xaf\x42\x69\xe5\x93\x9a", 16) == 0)
106 success ("gc_hmac_md5() OK\n");
109 hexprint (digest
, 16);
110 fail ("gc_hmac_md5() failure\n");
114 err
= gc_hmac_sha1 ("keykeykey", 9, "abcdefgh", 8, digest
);
116 fail ("gc_hmac_sha1() failed: %d\n", err
);
119 if (memcmp (digest
, "\x58\x93\x7a\x58\xfe\xea\x82\xf8"
120 "\x0e\x64\x62\x01\x40\x2b\x2c\xed\x5d\x54\xc1\xfa",
122 success ("gc_hmac_sha1() OK\n");
125 hexprint (digest
, 20);
126 fail ("gc_hmac_sha1() failure\n");
130 err
= gc_pbkdf2_sha1 ("password", 8, "salt", 4, 4711, digest
, 16);
132 fail ("gc_pkcs5_pbkdf2_sha1() failed: %d\n", err
);
135 if (memcmp (digest
, "\x09\xb7\x85\x57\xdd\xf6\x07\x15"
136 "\x1c\x52\x34\xde\xba\x5c\xdc\x59", 16) == 0)
137 success ("gc_pkcs5_pbkdf2_sha1() OK\n");
140 hexprint (digest
, 16);
141 fail ("gc_pkcs5_pbkdf2_sha1() failure\n");