1 /**

2 * @file rsa_test.h

3 *

4 * @brief Tests for the hasher_t classes.

5 *

6 */

8 /*

9 * Copyright (C) 2005 Jan Hutter, Martin Willi

10 * Hochschule fuer Technik Rapperswil

11 *

12 * This program is free software; you can redistribute it and/or modify it

13 * under the terms of the GNU General Public License as published by the

14 * Free Software Foundation; either version 2 of the License, or (at your

15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.

16 *

17 * This program is distributed in the hope that it will be useful, but

18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY

19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License

20 * for more details.

21 */

23 #include <string.h>

27 #include <daemon.h>

28 #include <utils/logger.h>

29 #include <crypto/certificate.h>

107 };

110 // 0x30,0x82,0x01,0x21,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,

111 // 0x01,0x05,0x00,0x03,0x82,0x01,0x0e,0x00,

131 };

133 /*

134 * described in Header-File

135 */

137 {

145 status_t status;

147 u_int8_t test_data[] = {

157 };

164 /* key generation and signing */

165 // private_key = rsa_private_key_create(512);

166 // tester->assert_true(tester, private_key != NULL, "generating private key");

167 //

168 // status = private_key->build_emsa_pkcs1_signature(private_key, HASH_MD5, data, &signature);

169 // tester->assert_true(tester, status == SUCCESS, "build emsa_pkcs1_signature (genkey)");

170 //

171 // public_key = private_key->get_public_key(private_key);

172 // tester->assert_true(tester, public_key != NULL, "extracting public key");

173 //

174 // status = public_key->verify_emsa_pkcs1_signature(public_key, data, signature);

175 // tester->assert_true(tester, status == SUCCESS, "verify emsa_pkcs1_signature (genkey)");

176 //

177 // free(signature.ptr);

178 //

179 // private_key->destroy(private_key);

180 // public_key->destroy(public_key);

182 /* key setting */

195 /* key comparison */

196 tester->assert_true(tester, private_key->belongs_to(private_key, public_key), "key belongs to");

200 tester->assert_false(tester, private_key->belongs_to(private_key, public_key), "key belongs not to");

205 /* key loading */

213 tester->assert_true(tester, private_key->belongs_to(private_key, public_key), "key belongs to");

226 }