Browse Source

[test] Add self-tests for RSA

Add self-tests for the RSA algorithm using test vectors generated with
the openssl tools.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 12 years ago
parent
commit
7fb064470f
3 changed files with 667 additions and 0 deletions
  1. 175
    0
      src/tests/pubkey_test.h
  2. 491
    0
      src/tests/rsa_test.c
  3. 1
    0
      src/tests/tests.c

+ 175
- 0
src/tests/pubkey_test.h View File

@@ -0,0 +1,175 @@
1
+#ifndef _PUBKEY_TEST_H
2
+#define _PUBKEY_TEST_H
3
+
4
+FILE_LICENCE ( GPL2_OR_LATER );
5
+
6
+#include <stdint.h>
7
+#include <ipxe/crypto.h>
8
+#include <ipxe/test.h>
9
+
10
+/**
11
+ * Report public key decryption test result
12
+ *
13
+ * @v pubkey		Public key algorithm
14
+ * @v key		Key
15
+ * @v key_len		Key length
16
+ * @v ciphertext	Ciphertext
17
+ * @v ciphertext_len	Ciphertext length
18
+ * @v expected		Expected plaintext
19
+ * @v expected_len	Expected plaintext length
20
+ */
21
+#define pubkey_decrypt_ok( pubkey, key, key_len, ciphertext,		\
22
+			   ciphertext_len, expected, expected_len ) do {\
23
+	uint8_t ctx[ (pubkey)->ctxsize ];				\
24
+									\
25
+	ok ( pubkey_init ( (pubkey), ctx, (key), (key_len) ) == 0 );	\
26
+	{								\
27
+		size_t max_len = pubkey_max_len ( (pubkey), ctx );	\
28
+		uint8_t decrypted[ max_len ];				\
29
+		int decrypted_len;					\
30
+									\
31
+		decrypted_len = pubkey_decrypt ( (pubkey), ctx,		\
32
+						 (ciphertext),		\
33
+						 (ciphertext_len),	\
34
+						 decrypted );		\
35
+		ok ( decrypted_len == ( ( int ) (expected_len) ) );	\
36
+		ok ( memcmp ( decrypted, (expected),			\
37
+			      (expected_len) ) == 0 );			\
38
+	}								\
39
+	pubkey_final ( (pubkey), ctx );					\
40
+	} while ( 0 )
41
+
42
+/**
43
+ * Report public key encryption and decryption test result
44
+ *
45
+ * @v pubkey		Public key algorithm
46
+ * @v encrypt_key	Encryption key
47
+ * @v encrypt_key_len	Encryption key length
48
+ * @v decrypt_key	Decryption key
49
+ * @v decrypt_key_len	Decryption key length
50
+ * @v plaintext		Plaintext
51
+ * @v plaintext_len	Plaintext length
52
+ */
53
+#define pubkey_encrypt_ok( pubkey, encrypt_key, encrypt_key_len,	\
54
+			   decrypt_key, decrypt_key_len, plaintext,	\
55
+			   plaintext_len ) do {				\
56
+	uint8_t ctx[ (pubkey)->ctxsize ];				\
57
+									\
58
+	ok ( pubkey_init ( (pubkey), ctx, (encrypt_key),		\
59
+			   (encrypt_key_len) ) == 0 );			\
60
+	{								\
61
+		size_t max_len = pubkey_max_len ( (pubkey), ctx );	\
62
+		uint8_t encrypted[ max_len ];				\
63
+		int encrypted_len;					\
64
+									\
65
+		encrypted_len = pubkey_encrypt ( (pubkey), ctx,		\
66
+						 (plaintext),		\
67
+						 (plaintext_len),	\
68
+						 encrypted );		\
69
+		ok ( encrypted_len >= 0 );				\
70
+		pubkey_decrypt_ok ( (pubkey), (decrypt_key),		\
71
+				    (decrypt_key_len), encrypted,	\
72
+				    encrypted_len, (plaintext),		\
73
+				    (plaintext_len) );			\
74
+	}								\
75
+	pubkey_final ( (pubkey), ctx );					\
76
+	} while ( 0 )
77
+
78
+/**
79
+ * Report public key signature test result
80
+ *
81
+ * @v pubkey		Public key algorithm
82
+ * @v key		Key
83
+ * @v key_len		Key length
84
+ * @v digest		Digest algorithm
85
+ * @v plaintext		Plaintext
86
+ * @v plaintext_len	Plaintext length
87
+ * @v expected		Expected signature
88
+ * @v expected_len	Expected signature length
89
+ */
90
+#define pubkey_sign_ok( pubkey, key, key_len, digest, plaintext,	\
91
+			plaintext_len, expected, expected_len ) do {	\
92
+	uint8_t ctx[ (pubkey)->ctxsize ];				\
93
+	uint8_t digestctx[ (digest)->ctxsize ];				\
94
+	uint8_t digestout[ (digest)->digestsize ];			\
95
+									\
96
+	digest_init ( (digest), digestctx );				\
97
+	digest_update ( (digest), digestctx, (plaintext),		\
98
+			(plaintext_len) );				\
99
+	digest_final ( (digest), digestctx, digestout );		\
100
+									\
101
+	ok ( pubkey_init ( (pubkey), ctx, (key), (key_len) ) == 0 );	\
102
+	{								\
103
+		size_t max_len = pubkey_max_len ( (pubkey), ctx );	\
104
+		uint8_t signature[ max_len ];				\
105
+		int signature_len;					\
106
+									\
107
+		signature_len = pubkey_sign ( (pubkey), ctx, (digest),	\
108
+					      digestout, signature );	\
109
+		ok ( signature_len == ( ( int ) (expected_len) ) );	\
110
+		ok ( memcmp ( signature, (expected),			\
111
+			      (expected_len) ) == 0 );			\
112
+	}								\
113
+	pubkey_final ( (pubkey), ctx );					\
114
+	} while ( 0 )
115
+
116
+/**
117
+ * Report public key verification test result
118
+ *
119
+ * @v pubkey		Public key algorithm
120
+ * @v key		Key
121
+ * @v key_len		Key length
122
+ * @v digest		Digest algorithm
123
+ * @v plaintext		Plaintext
124
+ * @v plaintext_len	Plaintext length
125
+ * @v signature		Signature
126
+ * @v signature_len	Signature length
127
+ */
128
+#define pubkey_verify_ok( pubkey, key, key_len, digest, plaintext,	\
129
+			  plaintext_len, signature, signature_len ) do {\
130
+	uint8_t ctx[ (pubkey)->ctxsize ];				\
131
+	uint8_t digestctx[ (digest)->ctxsize ];				\
132
+	uint8_t digestout[ (digest)->digestsize ];			\
133
+									\
134
+	digest_init ( (digest), digestctx );				\
135
+	digest_update ( (digest), digestctx, (plaintext),		\
136
+			(plaintext_len) );				\
137
+	digest_final ( (digest), digestctx, digestout );		\
138
+									\
139
+	ok ( pubkey_init ( (pubkey), ctx, (key), (key_len) ) == 0 );	\
140
+	ok ( pubkey_verify ( (pubkey), ctx, (digest), digestout,	\
141
+			     (signature), (signature_len) ) == 0 );	\
142
+	pubkey_final ( (pubkey), ctx );					\
143
+	} while ( 0 )
144
+
145
+/**
146
+ * Report public key verification test result
147
+ *
148
+ * @v pubkey		Public key algorithm
149
+ * @v key		Key
150
+ * @v key_len		Key length
151
+ * @v digest		Digest algorithm
152
+ * @v plaintext		Plaintext
153
+ * @v plaintext_len	Plaintext length
154
+ * @v signature		Signature
155
+ * @v signature_len	Signature length
156
+ */
157
+#define pubkey_verify_fail_ok( pubkey, key, key_len, digest, plaintext,	\
158
+			       plaintext_len, signature,		\
159
+			       signature_len ) do {			\
160
+	uint8_t ctx[ (pubkey)->ctxsize ];				\
161
+	uint8_t digestctx[ (digest)->ctxsize ];				\
162
+	uint8_t digestout[ (digest)->digestsize ];			\
163
+									\
164
+	digest_init ( (digest), digestctx );				\
165
+	digest_update ( (digest), digestctx, (plaintext),		\
166
+			(plaintext_len) );				\
167
+	digest_final ( (digest), digestctx, digestout );		\
168
+									\
169
+	ok ( pubkey_init ( (pubkey), ctx, (key), (key_len) ) == 0 );	\
170
+	ok ( pubkey_verify ( (pubkey), ctx, (digest), digestout,	\
171
+			     (signature), (signature_len) ) != 0 );	\
172
+	pubkey_final ( (pubkey), ctx );					\
173
+	} while ( 0 )
174
+
175
+#endif /* _PUBKEY_TEST_H */

+ 491
- 0
src/tests/rsa_test.c View File

@@ -0,0 +1,491 @@
1
+/*
2
+ * Copyright (C) 2012 Michael Brown <mbrown@fensystems.co.uk>.
3
+ *
4
+ * This program is free software; you can redistribute it and/or
5
+ * modify it under the terms of the GNU General Public License as
6
+ * published by the Free Software Foundation; either version 2 of the
7
+ * License, or any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful, but
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
+ * General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU General Public License
15
+ * along with this program; if not, write to the Free Software
16
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
+ */
18
+
19
+FILE_LICENCE ( GPL2_OR_LATER );
20
+
21
+/** @file
22
+ *
23
+ * RSA self-tests
24
+ *
25
+ * These test vectors are generated using openssl's genrsa, rsa,
26
+ * rsautl, and dgst tools.
27
+ */
28
+
29
+/* Forcibly enable assertions */
30
+#undef NDEBUG
31
+
32
+#include <ipxe/crypto.h>
33
+#include <ipxe/rsa.h>
34
+#include <ipxe/md5.h>
35
+#include <ipxe/sha1.h>
36
+#include <ipxe/sha256.h>
37
+#include <ipxe/test.h>
38
+#include "pubkey_test.h"
39
+
40
+/** Define inline private key data */
41
+#define PRIVATE(...) { __VA_ARGS__ }
42
+
43
+/** Define inline public key data */
44
+#define PUBLIC(...) { __VA_ARGS__ }
45
+
46
+/** Define inline plaintext data */
47
+#define PLAINTEXT(...) { __VA_ARGS__ }
48
+
49
+/** Define inline ciphertext data */
50
+#define CIPHERTEXT(...) { __VA_ARGS__ }
51
+
52
+/** Define inline signature data */
53
+#define SIGNATURE(...) { __VA_ARGS__ }
54
+
55
+/** An RSA encryption and decryption self-test */
56
+struct rsa_encrypt_decrypt_test {
57
+	/** Private key */
58
+	const void *private;
59
+	/** Private key length */
60
+	size_t private_len;
61
+	/** Public key */
62
+	const void *public;
63
+	/** Public key length */
64
+	size_t public_len;
65
+	/** Plaintext */
66
+	const void *plaintext;
67
+	/** Plaintext length */
68
+	size_t plaintext_len;
69
+	/** Ciphertext
70
+	 *
71
+	 * Note that the encryption process includes some random
72
+	 * padding, so a given plaintext will encrypt to multiple
73
+	 * different ciphertexts.
74
+	 */
75
+	const void *ciphertext;
76
+	/** Ciphertext length */
77
+	size_t ciphertext_len;
78
+};
79
+
80
+/**
81
+ * Define an RSA encryption and decryption test
82
+ *
83
+ * @v name		Test name
84
+ * @v PRIVATE		Private key
85
+ * @v PUBLIC		Public key
86
+ * @v PLAINTEXT		Plaintext
87
+ * @v CIPHERTEXT	Ciphertext
88
+ * @ret test		Encryption and decryption test
89
+ */
90
+#define RSA_ENCRYPT_DECRYPT_TEST( name, PRIVATE, PUBLIC, PLAINTEXT,	\
91
+				  CIPHERTEXT )				\
92
+	static const uint8_t name ## _private[] = PRIVATE;		\
93
+	static const uint8_t name ## _public[] = PUBLIC;		\
94
+	static const uint8_t name ## _plaintext[] = PLAINTEXT;		\
95
+	static const uint8_t name ## _ciphertext[] = CIPHERTEXT;	\
96
+	static struct rsa_encrypt_decrypt_test name = {			\
97
+		.private = name ## _private,				\
98
+		.private_len = sizeof ( name ## _private ),		\
99
+		.public = name ## _public,				\
100
+		.public_len = sizeof ( name ## _public ),		\
101
+		.plaintext = name ## _plaintext,			\
102
+		.plaintext_len = sizeof ( name ## _plaintext ),		\
103
+		.ciphertext = name ## _ciphertext,			\
104
+		.ciphertext_len = sizeof ( name ## _ciphertext ),	\
105
+	}
106
+
107
+/** An RSA signature self-test */
108
+struct rsa_signature_test {
109
+	/** Private key */
110
+	const void *private;
111
+	/** Private key length */
112
+	size_t private_len;
113
+	/** Public key */
114
+	const void *public;
115
+	/** Public key length */
116
+	size_t public_len;
117
+	/** Plaintext */
118
+	const void *plaintext;
119
+	/** Plaintext length */
120
+	size_t plaintext_len;
121
+	/** Digest algorithm */
122
+	struct digest_algorithm *digest;
123
+	/** Signature */
124
+	const void *signature;
125
+	/** Signature length */
126
+	size_t signature_len;
127
+};
128
+
129
+/**
130
+ * Define an RSA signature test
131
+ *
132
+ * @v name		Test name
133
+ * @v PRIVATE		Private key
134
+ * @v PUBLIC		Public key
135
+ * @v PLAINTEXT		Plaintext
136
+ * @v DIGEST		Digest algorithm
137
+ * @v SIGNATURE		Signature
138
+ * @ret test		Signature test
139
+ */
140
+#define RSA_SIGNATURE_TEST( name, PRIVATE, PUBLIC, PLAINTEXT, DIGEST,	\
141
+			    SIGNATURE )					\
142
+	static const uint8_t name ## _private[] = PRIVATE;		\
143
+	static const uint8_t name ## _public[] = PUBLIC;		\
144
+	static const uint8_t name ## _plaintext[] = PLAINTEXT;		\
145
+	static const uint8_t name ## _signature[] = SIGNATURE;		\
146
+	static struct rsa_signature_test name = {			\
147
+		.private = name ## _private,				\
148
+		.private_len = sizeof ( name ## _private ),		\
149
+		.public = name ## _public,				\
150
+		.public_len = sizeof ( name ## _public ),		\
151
+		.plaintext = name ## _plaintext,			\
152
+		.plaintext_len = sizeof ( name ## _plaintext ),		\
153
+		.digest = DIGEST,					\
154
+		.signature = name ## _signature,			\
155
+		.signature_len = sizeof ( name ## _signature ),		\
156
+	}
157
+
158
+/**
159
+ * Report RSA encryption and decryption test result
160
+ *
161
+ * @v test		RSA encryption and decryption test
162
+ */
163
+#define rsa_encrypt_decrypt_ok( test ) do {				\
164
+	pubkey_decrypt_ok ( &rsa_algorithm, (test)->private,		\
165
+			    (test)->private_len, (test)->ciphertext,	\
166
+			    (test)->ciphertext_len, (test)->plaintext,	\
167
+			    (test)->plaintext_len );			\
168
+	pubkey_encrypt_ok ( &rsa_algorithm, (test)->private,		\
169
+			    (test)->private_len, (test)->public,	\
170
+			    (test)->public_len, (test)->plaintext,	\
171
+			    (test)->plaintext_len );			\
172
+	pubkey_encrypt_ok ( &rsa_algorithm, (test)->public,		\
173
+			    (test)->public_len, (test)->private,	\
174
+			    (test)->private_len, (test)->plaintext,	\
175
+			    (test)->plaintext_len );			\
176
+	} while ( 0 )
177
+
178
+
179
+/**
180
+ * Report RSA signature test result
181
+ *
182
+ * @v test		RSA signature test
183
+ */
184
+#define rsa_signature_ok( test ) do {					\
185
+	uint8_t bad_signature[ (test)->signature_len ];			\
186
+	pubkey_sign_ok ( &rsa_algorithm, (test)->private,		\
187
+			 (test)->private_len, (test)->digest,		\
188
+			 (test)->plaintext, (test)->plaintext_len,	\
189
+			 (test)->signature, (test)->signature_len );	\
190
+	pubkey_verify_ok ( &rsa_algorithm, (test)->public,		\
191
+			   (test)->public_len, (test)->digest,		\
192
+			   (test)->plaintext, (test)->plaintext_len,	\
193
+			   (test)->signature, (test)->signature_len );	\
194
+	memset ( bad_signature, 0, sizeof ( bad_signature ) );		\
195
+	pubkey_verify_fail_ok ( &rsa_algorithm, (test)->public,		\
196
+				(test)->public_len, (test)->digest,	\
197
+				(test)->plaintext,			\
198
+				(test)->plaintext_len, bad_signature,	\
199
+				sizeof ( bad_signature ) );		\
200
+	} while ( 0 )
201
+
202
+/** "Hello world" encryption and decryption test */
203
+RSA_ENCRYPT_DECRYPT_TEST ( hw_test,
204
+	PRIVATE ( 0x30, 0x82, 0x01, 0x3b, 0x02, 0x01, 0x00, 0x02, 0x41, 0x00,
205
+		  0xd2, 0xf1, 0x04, 0x67, 0xf6, 0x2c, 0x96, 0x07, 0xa6, 0xbd,
206
+		  0x85, 0xac, 0xc1, 0x17, 0x5d, 0xe8, 0xf0, 0x93, 0x94, 0x0c,
207
+		  0x45, 0x67, 0x26, 0x67, 0xde, 0x7e, 0xfb, 0xa8, 0xda, 0xbd,
208
+		  0x07, 0xdf, 0xcf, 0x45, 0x04, 0x6d, 0xbd, 0x69, 0x8b, 0xfb,
209
+		  0xc1, 0x72, 0xc0, 0xfc, 0x03, 0x04, 0xf2, 0x82, 0xc4, 0x7b,
210
+		  0x6a, 0x3e, 0xec, 0x53, 0x7a, 0xe3, 0x4e, 0xa8, 0xc9, 0xf9,
211
+		  0x1f, 0x2a, 0x13, 0x0d, 0x02, 0x03, 0x01, 0x00, 0x01, 0x02,
212
+		  0x40, 0x49, 0xb8, 0x61, 0xc9, 0xd3, 0x87, 0x11, 0x87, 0xeb,
213
+		  0x06, 0x21, 0x49, 0x96, 0xd2, 0x0b, 0xc7, 0xf5, 0x0c, 0x1e,
214
+		  0x99, 0x8b, 0x47, 0xd9, 0x6c, 0x43, 0x9e, 0x2d, 0x65, 0x7d,
215
+		  0xcc, 0xc2, 0x8b, 0x1a, 0x6f, 0x2b, 0x55, 0xbe, 0xb3, 0x9f,
216
+		  0xd1, 0xe2, 0x9a, 0xde, 0x1d, 0xac, 0xec, 0x67, 0xec, 0xa5,
217
+		  0xbf, 0x9c, 0x30, 0xd6, 0xf9, 0x0a, 0x1a, 0x48, 0xf3, 0xc2,
218
+		  0x93, 0x3a, 0x17, 0x27, 0x21, 0x02, 0x21, 0x00, 0xfc, 0x8d,
219
+		  0xfb, 0xee, 0x8a, 0xaa, 0x45, 0x19, 0x4b, 0xf0, 0x68, 0xb0,
220
+		  0x02, 0x38, 0x3e, 0x03, 0x6b, 0x24, 0x77, 0x20, 0xbd, 0x5e,
221
+		  0x6c, 0x76, 0xdb, 0xc9, 0xe1, 0x43, 0xa3, 0x40, 0x62, 0x6f,
222
+		  0x02, 0x21, 0x00, 0xd5, 0xd1, 0xb4, 0x4d, 0x03, 0x40, 0x69,
223
+		  0x3f, 0x9a, 0xa7, 0x44, 0x15, 0x28, 0x1e, 0xa5, 0x5f, 0xcf,
224
+		  0x97, 0x21, 0x12, 0xb3, 0xe6, 0x1c, 0x9a, 0x8d, 0xb7, 0xb4,
225
+		  0x80, 0x3a, 0x9c, 0xb0, 0x43, 0x02, 0x20, 0x71, 0xf0, 0xa0,
226
+		  0xab, 0x82, 0xf5, 0xc4, 0x8c, 0xe0, 0x1c, 0xcb, 0x2e, 0x35,
227
+		  0x22, 0x28, 0xa0, 0x24, 0x33, 0x64, 0x67, 0x69, 0xe7, 0xf2,
228
+		  0xa9, 0x41, 0x09, 0x78, 0x4e, 0xaa, 0x95, 0x3e, 0x93, 0x02,
229
+		  0x21, 0x00, 0x85, 0xcc, 0x4d, 0xd9, 0x0b, 0x39, 0xd9, 0x22,
230
+		  0x75, 0xf2, 0x49, 0x46, 0x3b, 0xee, 0xc1, 0x69, 0x6d, 0x0b,
231
+		  0x93, 0x24, 0x92, 0xf2, 0x61, 0xdf, 0xcc, 0xe2, 0xb1, 0xce,
232
+		  0xb3, 0xde, 0xac, 0xe5, 0x02, 0x21, 0x00, 0x9c, 0x23, 0x6a,
233
+		  0x95, 0xa6, 0xfe, 0x1e, 0xd8, 0x0c, 0x3f, 0x6e, 0xe6, 0x0a,
234
+		  0xeb, 0x97, 0xd6, 0x36, 0x1c, 0x80, 0xc1, 0x02, 0x87, 0x0d,
235
+		  0x4d, 0xfe, 0x28, 0x02, 0x1e, 0xde, 0xe1, 0xcc, 0x72 ),
236
+	PUBLIC ( 0x30, 0x5c, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
237
+		 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x4b, 0x00,
238
+		 0x30, 0x48, 0x02, 0x41, 0x00, 0xd2, 0xf1, 0x04, 0x67, 0xf6,
239
+		 0x2c, 0x96, 0x07, 0xa6, 0xbd, 0x85, 0xac, 0xc1, 0x17, 0x5d,
240
+		 0xe8, 0xf0, 0x93, 0x94, 0x0c, 0x45, 0x67, 0x26, 0x67, 0xde,
241
+		 0x7e, 0xfb, 0xa8, 0xda, 0xbd, 0x07, 0xdf, 0xcf, 0x45, 0x04,
242
+		 0x6d, 0xbd, 0x69, 0x8b, 0xfb, 0xc1, 0x72, 0xc0, 0xfc, 0x03,
243
+		 0x04, 0xf2, 0x82, 0xc4, 0x7b, 0x6a, 0x3e, 0xec, 0x53, 0x7a,
244
+		 0xe3, 0x4e, 0xa8, 0xc9, 0xf9, 0x1f, 0x2a, 0x13, 0x0d, 0x02,
245
+		 0x03, 0x01, 0x00, 0x01 ),
246
+	PLAINTEXT ( 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x77, 0x6f, 0x72, 0x6c,
247
+		    0x64, 0x0a ),
248
+	CIPHERTEXT ( 0x39, 0xff, 0x5c, 0x54, 0x65, 0x3e, 0x6a, 0xab, 0xc0, 0x62,
249
+		     0x91, 0xb2, 0xbf, 0x1d, 0x73, 0x5b, 0xd5, 0x4c, 0xbd, 0x16,
250
+		     0x0f, 0x24, 0xc9, 0xf5, 0xa7, 0xdd, 0x94, 0xd6, 0xf8, 0xae,
251
+		     0xd3, 0xa0, 0x9f, 0x4d, 0xff, 0x8d, 0x81, 0x34, 0x47, 0xff,
252
+		     0x2a, 0x87, 0x96, 0xd3, 0x17, 0x5d, 0x93, 0x4d, 0x7b, 0x27,
253
+		     0x88, 0x4f, 0xec, 0x43, 0x9c, 0xed, 0xb3, 0xf2, 0x19, 0x89,
254
+		     0x38, 0x43, 0xf9, 0x41 ) );
255
+
256
+/** Random message MD5 signature test */
257
+RSA_SIGNATURE_TEST ( md5_test,
258
+	PRIVATE ( 0x30, 0x82, 0x01, 0x3b, 0x02, 0x01, 0x00, 0x02, 0x41, 0x00,
259
+		  0xf9, 0x3f, 0x78, 0x44, 0xe2, 0x0e, 0x25, 0xf1, 0x0e, 0x94,
260
+		  0xcd, 0xca, 0x6f, 0x9e, 0xea, 0x6d, 0xdf, 0xcd, 0xa0, 0x7c,
261
+		  0xe2, 0x21, 0xeb, 0xde, 0xa6, 0x01, 0x4b, 0xb0, 0x76, 0x4b,
262
+		  0xd8, 0x8b, 0x19, 0x83, 0xb4, 0xbe, 0x45, 0xde, 0x3d, 0x46,
263
+		  0x61, 0x0f, 0x11, 0xe2, 0x2c, 0xf5, 0xb0, 0x63, 0xa0, 0x84,
264
+		  0xc0, 0xaf, 0x4e, 0xbe, 0x6a, 0xd3, 0x84, 0x3f, 0xec, 0x42,
265
+		  0x17, 0xe9, 0x25, 0xe1, 0x02, 0x03, 0x01, 0x00, 0x01, 0x02,
266
+		  0x40, 0x62, 0x7d, 0x93, 0x1f, 0xdd, 0x17, 0xec, 0x24, 0x42,
267
+		  0x37, 0xc8, 0xce, 0x0a, 0xa7, 0x88, 0x49, 0x5c, 0x9b, 0x9b,
268
+		  0xa4, 0x5d, 0x93, 0x3b, 0xea, 0x62, 0x3c, 0xb6, 0xd5, 0x07,
269
+		  0x19, 0xd7, 0x79, 0xf0, 0x3b, 0xab, 0xa3, 0xa5, 0x43, 0x35,
270
+		  0x8d, 0x58, 0x40, 0xa0, 0x95, 0xc5, 0x63, 0x28, 0x28, 0xda,
271
+		  0x13, 0x28, 0xdf, 0xc9, 0x05, 0xdc, 0x69, 0x46, 0xff, 0x2a,
272
+		  0xfb, 0xe4, 0xd1, 0x23, 0xa5, 0x02, 0x21, 0x00, 0xfc, 0xef,
273
+		  0x3b, 0x9d, 0x9d, 0x69, 0xf3, 0x66, 0x0a, 0x2b, 0x52, 0xd6,
274
+		  0x61, 0x14, 0x90, 0x6e, 0x7d, 0x3c, 0x08, 0x4b, 0x98, 0x44,
275
+		  0x00, 0xf2, 0xa4, 0x16, 0x2d, 0xd1, 0xf9, 0xa0, 0x1e, 0x37,
276
+		  0x02, 0x21, 0x00, 0xfc, 0x44, 0xcc, 0x7c, 0xc0, 0x26, 0x9a,
277
+		  0x0a, 0x6e, 0xda, 0x17, 0x05, 0x7d, 0x66, 0x8d, 0x29, 0x1a,
278
+		  0x44, 0xbf, 0x33, 0x76, 0xae, 0x8d, 0xe8, 0xb5, 0xed, 0xb8,
279
+		  0x6f, 0xdc, 0xfe, 0x10, 0xa7, 0x02, 0x20, 0x76, 0x48, 0x8a,
280
+		  0x60, 0x93, 0x14, 0xd1, 0x36, 0x8e, 0xda, 0xe3, 0xca, 0x4d,
281
+		  0x6c, 0x08, 0x7f, 0x23, 0x21, 0xc7, 0xdf, 0x52, 0x3d, 0xbb,
282
+		  0x13, 0xbd, 0x98, 0x81, 0xa5, 0x08, 0x4f, 0xd0, 0xd1, 0x02,
283
+		  0x21, 0x00, 0xd9, 0xa3, 0x11, 0x37, 0xdf, 0x1e, 0x6e, 0x6e,
284
+		  0xe9, 0xcb, 0xc5, 0x68, 0xbb, 0x13, 0x2a, 0x5d, 0x77, 0x88,
285
+		  0x2f, 0xdc, 0x5a, 0x5b, 0xa5, 0x9a, 0x4a, 0xba, 0x58, 0x10,
286
+		  0x49, 0xfb, 0xf6, 0xa9, 0x02, 0x21, 0x00, 0x89, 0xe8, 0x47,
287
+		  0x5b, 0x20, 0x04, 0x3b, 0x0f, 0xb9, 0xe0, 0x1d, 0xab, 0xcf,
288
+		  0xe8, 0x72, 0xfd, 0x7d, 0x17, 0x85, 0xc8, 0xd8, 0xbd, 0x1a,
289
+		  0x92, 0xe0, 0xbc, 0x7a, 0xc7, 0x31, 0xbe, 0xef, 0xf4 ),
290
+	PUBLIC ( 0x30, 0x5c, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
291
+		 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x4b, 0x00,
292
+		 0x30, 0x48, 0x02, 0x41, 0x00, 0xf9, 0x3f, 0x78, 0x44, 0xe2,
293
+		 0x0e, 0x25, 0xf1, 0x0e, 0x94, 0xcd, 0xca, 0x6f, 0x9e, 0xea,
294
+		 0x6d, 0xdf, 0xcd, 0xa0, 0x7c, 0xe2, 0x21, 0xeb, 0xde, 0xa6,
295
+		 0x01, 0x4b, 0xb0, 0x76, 0x4b, 0xd8, 0x8b, 0x19, 0x83, 0xb4,
296
+		 0xbe, 0x45, 0xde, 0x3d, 0x46, 0x61, 0x0f, 0x11, 0xe2, 0x2c,
297
+		 0xf5, 0xb0, 0x63, 0xa0, 0x84, 0xc0, 0xaf, 0x4e, 0xbe, 0x6a,
298
+		 0xd3, 0x84, 0x3f, 0xec, 0x42, 0x17, 0xe9, 0x25, 0xe1, 0x02,
299
+		 0x03, 0x01, 0x00, 0x01 ),
300
+	PLAINTEXT ( 0x9d, 0x5b, 0x46, 0x42, 0x27, 0xc0, 0xf1, 0x4b, 0xe5, 0x9e,
301
+		    0xd3, 0x10, 0xa1, 0xeb, 0x16, 0xc3, 0xc6, 0x8f, 0x1a, 0x18,
302
+		    0x86, 0xc3, 0x92, 0x15, 0x2d, 0x65, 0xa0, 0x40, 0xe1, 0x3e,
303
+		    0x29, 0x79, 0x7c, 0xd4, 0x08, 0xef, 0x53, 0xeb, 0x08, 0x07,
304
+		    0x39, 0x21, 0xb3, 0x40, 0xff, 0x4b, 0xc7, 0x76, 0xb9, 0x12,
305
+		    0x32, 0x41, 0xcc, 0x5a, 0x86, 0x5c, 0x2e, 0x0b, 0x05, 0xd8,
306
+		    0x56, 0xd4, 0xdf, 0x6f, 0x2c, 0xf0, 0xbf, 0x4b, 0x6f, 0x68,
307
+		    0xde, 0x39, 0x4a, 0x3e, 0xae, 0x44, 0xb9, 0xc6, 0x24, 0xb3,
308
+		    0x83, 0x2e, 0x9f, 0xf5, 0x6d, 0x61, 0xc3, 0x8e, 0xe8, 0x8f,
309
+		    0xa6, 0x87, 0x58, 0x3f, 0x36, 0x13, 0xf4, 0x7e, 0xf0, 0x20,
310
+		    0x47, 0x87, 0x3f, 0x21, 0x6e, 0x51, 0x3c, 0xf1, 0xef, 0xca,
311
+		    0x9f, 0x77, 0x9c, 0x91, 0x4f, 0xd4, 0x56, 0xc0, 0x39, 0x11,
312
+		    0xab, 0x15, 0x2c, 0x5e, 0xad, 0x40, 0x09, 0xe6, 0xde, 0xe5,
313
+		    0x77, 0x60, 0x19, 0xd4, 0x0d, 0x77, 0x76, 0x24, 0x8b, 0xe6,
314
+		    0xdd, 0xa5, 0x8d, 0x4a, 0x55, 0x3a, 0xdf, 0xf8, 0x29, 0xfb,
315
+		    0x47, 0x8a, 0xfe, 0x98, 0x34, 0xf6, 0x30, 0x7f, 0x09, 0x03,
316
+		    0x26, 0x05, 0xd5, 0x46, 0x18, 0x96, 0xca, 0x96, 0x5b, 0x66,
317
+		    0xf2, 0x8d, 0xfc, 0xfc, 0x37, 0xf7, 0xc7, 0x6d, 0x6c, 0xd8,
318
+		    0x24, 0x0c, 0x6a, 0xec, 0x82, 0x5c, 0x72, 0xf1, 0xfc, 0x05,
319
+		    0xed, 0x8e, 0xe8, 0xd9, 0x8b, 0x8b, 0x67, 0x02, 0x95 ),
320
+	&md5_algorithm,
321
+	SIGNATURE ( 0xdb, 0x56, 0x3d, 0xea, 0xae, 0x81, 0x4b, 0x3b, 0x2e, 0x8e,
322
+		    0xb8, 0xee, 0x13, 0x61, 0xc6, 0xe7, 0xd7, 0x50, 0xcd, 0x0d,
323
+		    0x34, 0x3a, 0xfe, 0x9a, 0x8d, 0xf8, 0xfb, 0xd6, 0x7e, 0xbd,
324
+		    0xdd, 0xb3, 0xf9, 0xfb, 0xe0, 0xf8, 0xe7, 0x71, 0x03, 0xe6,
325
+		    0x55, 0xd5, 0xf4, 0x02, 0x3c, 0xb5, 0xbc, 0x95, 0x2b, 0x66,
326
+		    0x56, 0xec, 0x2f, 0x8e, 0xa7, 0xae, 0xd9, 0x80, 0xb3, 0xaa,
327
+		    0xac, 0x45, 0x00, 0xa8 ) );
328
+
329
+/** Random message SHA-1 signature test */
330
+RSA_SIGNATURE_TEST ( sha1_test,
331
+	PRIVATE ( 0x30, 0x82, 0x01, 0x3b, 0x02, 0x01, 0x00, 0x02, 0x41, 0x00,
332
+		  0xe0, 0x3a, 0x8d, 0x35, 0xe1, 0x92, 0x2f, 0xea, 0x0d, 0x82,
333
+		  0x60, 0x2e, 0xb6, 0x0b, 0x02, 0xd3, 0xf4, 0x39, 0xfb, 0x06,
334
+		  0x43, 0x8e, 0xa1, 0x7c, 0xc5, 0xae, 0x0d, 0xc7, 0xee, 0x83,
335
+		  0xb3, 0x63, 0x20, 0x92, 0x34, 0xe2, 0x94, 0x3d, 0xdd, 0xbb,
336
+		  0x6c, 0x64, 0x69, 0x68, 0x25, 0x24, 0x81, 0x4b, 0x4d, 0x48,
337
+		  0x5a, 0xd2, 0x29, 0x14, 0xeb, 0x38, 0xdd, 0x3e, 0xb5, 0x57,
338
+		  0x45, 0x9b, 0xed, 0x33, 0x02, 0x03, 0x01, 0x00, 0x01, 0x02,
339
+		  0x40, 0x3d, 0xa9, 0x1c, 0x47, 0xe2, 0xdd, 0xf6, 0x7b, 0x20,
340
+		  0x77, 0xe7, 0xc7, 0x30, 0x9c, 0x5a, 0x8c, 0xba, 0xae, 0x6f,
341
+		  0x0f, 0x4b, 0xe8, 0x9f, 0x13, 0xd6, 0xb0, 0x84, 0x6d, 0xa4,
342
+		  0x73, 0x67, 0x12, 0xa9, 0x7c, 0x75, 0xaf, 0x62, 0x92, 0x7b,
343
+		  0x80, 0xaf, 0x39, 0x7d, 0x01, 0xb3, 0x43, 0xc8, 0x0d, 0x17,
344
+		  0x7f, 0x82, 0x59, 0x46, 0xb8, 0xe5, 0x4e, 0xba, 0x5e, 0x71,
345
+		  0x5c, 0xba, 0x62, 0x06, 0x91, 0x02, 0x21, 0x00, 0xf7, 0xaa,
346
+		  0xb6, 0x9c, 0xc8, 0xad, 0x68, 0xa8, 0xd7, 0x25, 0xb1, 0xb5,
347
+		  0x91, 0xd4, 0xc7, 0xd6, 0x69, 0x51, 0x5d, 0x04, 0xed, 0xd8,
348
+		  0xc6, 0xea, 0x69, 0xd2, 0x24, 0xbe, 0x5e, 0x7c, 0x89, 0xa5,
349
+		  0x02, 0x21, 0x00, 0xe7, 0xc5, 0xf4, 0x01, 0x35, 0xe0, 0x16,
350
+		  0xb5, 0x13, 0x86, 0x14, 0x5a, 0x6a, 0x8d, 0x03, 0x90, 0xae,
351
+		  0x7d, 0x3a, 0xc1, 0xfe, 0x8c, 0xa0, 0x4a, 0xb4, 0x94, 0x50,
352
+		  0x58, 0xa4, 0xc6, 0x73, 0xf7, 0x02, 0x21, 0x00, 0xe2, 0xda,
353
+		  0x16, 0x6c, 0x63, 0x90, 0x1a, 0xc6, 0x54, 0x53, 0x2d, 0x84,
354
+		  0x8f, 0x70, 0x24, 0x1f, 0x6b, 0xd6, 0x5f, 0xea, 0x8c, 0xe5,
355
+		  0xbb, 0xc5, 0xa9, 0x6a, 0x17, 0xc7, 0xdb, 0x8a, 0x1d, 0x15,
356
+		  0x02, 0x21, 0x00, 0xe4, 0x2a, 0x7e, 0xe4, 0x76, 0x2a, 0x2d,
357
+		  0x90, 0x83, 0x30, 0xda, 0x76, 0x8c, 0x30, 0x58, 0x13, 0x25,
358
+		  0x83, 0x88, 0xc5, 0x93, 0x96, 0xd2, 0xf1, 0xd8, 0x45, 0xad,
359
+		  0xb7, 0x26, 0x37, 0x6b, 0xcf, 0x02, 0x20, 0x73, 0x58, 0x1f,
360
+		  0x0a, 0xcd, 0x0c, 0x83, 0x27, 0xcc, 0x15, 0xa2, 0x1e, 0x07,
361
+		  0x32, 0x1b, 0xa3, 0xc6, 0xa6, 0xb8, 0x83, 0x97, 0x48, 0x45,
362
+		  0x50, 0x6c, 0x37, 0x45, 0xa5, 0x54, 0x2a, 0x59, 0x3c ),
363
+	PUBLIC ( 0x30, 0x5c, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
364
+		 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x4b, 0x00,
365
+		 0x30, 0x48, 0x02, 0x41, 0x00, 0xe0, 0x3a, 0x8d, 0x35, 0xe1,
366
+		 0x92, 0x2f, 0xea, 0x0d, 0x82, 0x60, 0x2e, 0xb6, 0x0b, 0x02,
367
+		 0xd3, 0xf4, 0x39, 0xfb, 0x06, 0x43, 0x8e, 0xa1, 0x7c, 0xc5,
368
+		 0xae, 0x0d, 0xc7, 0xee, 0x83, 0xb3, 0x63, 0x20, 0x92, 0x34,
369
+		 0xe2, 0x94, 0x3d, 0xdd, 0xbb, 0x6c, 0x64, 0x69, 0x68, 0x25,
370
+		 0x24, 0x81, 0x4b, 0x4d, 0x48, 0x5a, 0xd2, 0x29, 0x14, 0xeb,
371
+		 0x38, 0xdd, 0x3e, 0xb5, 0x57, 0x45, 0x9b, 0xed, 0x33, 0x02,
372
+		 0x03, 0x01, 0x00, 0x01 ),
373
+	PLAINTEXT ( 0xf7, 0x42, 0x01, 0x57, 0x6b, 0x70, 0xcc, 0x4a, 0xdc, 0xed,
374
+		    0x12, 0x83, 0x3f, 0xef, 0x27, 0xc1, 0x3c, 0x85, 0xdd, 0x5e,
375
+		    0x0a, 0x34, 0x98, 0xf9, 0x21, 0xd3, 0x24, 0x2a, 0x5a, 0xb2,
376
+		    0xdf, 0x60, 0x21, 0x28, 0x7c, 0x5b, 0x7a, 0xbe, 0xcb, 0xea,
377
+		    0xbc, 0xd6, 0x0e, 0xae, 0x94, 0x64, 0x21, 0xda, 0x28, 0x66,
378
+		    0x2f, 0x71, 0x48, 0xe5, 0xea, 0x59, 0x38, 0x28, 0x3e, 0xed,
379
+		    0x3b, 0x95, 0x4f, 0x3d, 0x72, 0x2a, 0x00, 0xf3, 0x95, 0x4d,
380
+		    0xf0, 0x02, 0x71, 0x63, 0x5a, 0xbc, 0x84, 0xd1, 0x81, 0x3f,
381
+		    0x16, 0xcd, 0x28, 0x3d, 0x47, 0xa2, 0xee, 0xa1, 0x2f, 0x84,
382
+		    0x8a, 0x22, 0x02, 0x88, 0xd7, 0x83, 0x06, 0x4a, 0x9f, 0xea,
383
+		    0x0f, 0x15, 0x48, 0x43, 0x58, 0x6d, 0x39, 0x78, 0x5a, 0x43,
384
+		    0x3f, 0xed, 0x6f, 0x68, 0xde, 0x9c, 0xfe, 0xd3, 0x67, 0x74,
385
+		    0x08, 0x46, 0x7d, 0x20, 0x22, 0x60, 0x8c, 0x37, 0x35, 0x46,
386
+		    0x56, 0x19, 0x3c, 0xfa, 0xa5, 0x40, 0xac, 0x44, 0x90, 0x8a,
387
+		    0xa5, 0x80, 0xb2, 0x32, 0xbc, 0xb4, 0x3f, 0x3e, 0x5e, 0xd4,
388
+		    0x51, 0xa9, 0x2e, 0xd9, 0x7f, 0x5e, 0x32, 0xb1, 0x24, 0x35,
389
+		    0x88, 0x71, 0x3a, 0x01, 0x86, 0x5c, 0xa2, 0xe2, 0x2d, 0x02,
390
+		    0x30, 0x91, 0x1c, 0xaa, 0x6c, 0x24, 0x42, 0x1b, 0x1a, 0xba,
391
+		    0x30, 0x40, 0x49, 0x83, 0xd9, 0xd7, 0x66, 0x7e, 0x5c, 0x1a,
392
+		    0x4b, 0x7f, 0xa6, 0x8e, 0x8a, 0xd6, 0x0c, 0x65, 0x75 ),
393
+	&sha1_algorithm,
394
+	SIGNATURE ( 0xa5, 0x5a, 0x8a, 0x67, 0x81, 0x76, 0x7e, 0xad, 0x99, 0x22,
395
+		    0xf1, 0x47, 0x64, 0xd2, 0xfb, 0x81, 0x45, 0xeb, 0x85, 0x56,
396
+		    0xf8, 0x7d, 0xb8, 0xec, 0x41, 0x17, 0x84, 0xf7, 0x2b, 0xbb,
397
+		    0x2b, 0x8f, 0xb6, 0xb8, 0x8f, 0xc6, 0xab, 0x39, 0xbc, 0xa3,
398
+		    0x72, 0xb3, 0x63, 0x45, 0x5a, 0xe0, 0xac, 0xf8, 0x1c, 0x83,
399
+		    0x48, 0x84, 0x89, 0x8a, 0x6b, 0xdf, 0x93, 0xa0, 0xc3, 0x0b,
400
+		    0x0e, 0x3d, 0x80, 0x80 ) );
401
+
402
+/** Random message SHA-256 signature test */
403
+RSA_SIGNATURE_TEST ( sha256_test,
404
+	PRIVATE ( 0x30, 0x82, 0x01, 0x3a, 0x02, 0x01, 0x00, 0x02, 0x41, 0x00,
405
+		  0xa5, 0xe9, 0xdb, 0xa9, 0x1a, 0x6e, 0xd6, 0x4c, 0x25, 0x50,
406
+		  0xfe, 0x61, 0x77, 0x08, 0x7a, 0x80, 0x36, 0xcb, 0x88, 0x49,
407
+		  0x5c, 0xe8, 0xaa, 0x15, 0xf8, 0xb3, 0xd6, 0x78, 0x51, 0x46,
408
+		  0x86, 0x3a, 0x5f, 0xd5, 0x9f, 0xab, 0xfe, 0x74, 0x8c, 0x53,
409
+		  0x0d, 0xb5, 0x3c, 0x7d, 0x2c, 0x35, 0x88, 0x3f, 0xde, 0xa2,
410
+		  0xce, 0x46, 0x94, 0x30, 0xa9, 0x76, 0xee, 0x25, 0xc5, 0x5d,
411
+		  0xa6, 0xa6, 0x3a, 0xa5, 0x02, 0x03, 0x01, 0x00, 0x01, 0x02,
412
+		  0x40, 0x14, 0x4b, 0xbc, 0x4c, 0x3e, 0x68, 0x8a, 0x9c, 0x7c,
413
+		  0x00, 0x21, 0x6e, 0x28, 0xd2, 0x87, 0xb1, 0xc1, 0x82, 0x3a,
414
+		  0x64, 0xc7, 0x11, 0xcb, 0x24, 0xae, 0xec, 0xc8, 0xf2, 0xa4,
415
+		  0xf6, 0x9c, 0x9a, 0xbb, 0x05, 0x94, 0x80, 0x9b, 0xc1, 0x21,
416
+		  0x83, 0x36, 0x23, 0xba, 0x04, 0x20, 0x23, 0x06, 0x48, 0xa7,
417
+		  0xa4, 0xe6, 0x31, 0x8e, 0xa1, 0x73, 0xe5, 0x6b, 0x83, 0x4c,
418
+		  0x3a, 0xb8, 0xd8, 0x22, 0x61, 0x02, 0x21, 0x00, 0xd4, 0xdf,
419
+		  0xcb, 0x21, 0x4a, 0x9a, 0x35, 0x52, 0x02, 0x99, 0xcc, 0x40,
420
+		  0x83, 0x65, 0x30, 0x1f, 0x9d, 0x13, 0xd6, 0xd1, 0x79, 0x10,
421
+		  0xce, 0x5b, 0xeb, 0x25, 0xa2, 0x39, 0x4e, 0xdf, 0x1c, 0x29,
422
+		  0x02, 0x21, 0x00, 0xc7, 0x86, 0x8f, 0xd9, 0x88, 0xe9, 0x98,
423
+		  0x4b, 0x5c, 0x50, 0x06, 0x94, 0x05, 0x59, 0x31, 0x25, 0xa7,
424
+		  0xa8, 0xe6, 0x95, 0x2b, 0xe3, 0x74, 0x93, 0x51, 0xa8, 0x8e,
425
+		  0x3d, 0xe2, 0xe0, 0xfa, 0x1d, 0x02, 0x20, 0x6e, 0xe3, 0x81,
426
+		  0x31, 0xff, 0x65, 0xa3, 0x1e, 0xec, 0x61, 0xe7, 0x67, 0x37,
427
+		  0xcb, 0x0f, 0x2d, 0x78, 0xaa, 0xab, 0xfd, 0x84, 0x5e, 0x3f,
428
+		  0xd0, 0xdc, 0x06, 0x47, 0xa2, 0x28, 0xb6, 0xca, 0x39, 0x02,
429
+		  0x20, 0x13, 0x7d, 0x9f, 0x9b, 0xbe, 0x76, 0x23, 0x3c, 0x69,
430
+		  0x5e, 0x1f, 0xe6, 0x61, 0xc7, 0x5e, 0xb7, 0xb0, 0xf3, 0x1c,
431
+		  0xe3, 0x41, 0x90, 0x4c, 0x98, 0xff, 0x87, 0x19, 0xae, 0x0d,
432
+		  0xf5, 0xb0, 0x39, 0x02, 0x21, 0x00, 0xb7, 0xeb, 0xcd, 0x01,
433
+		  0x2e, 0x23, 0x42, 0x4f, 0x0c, 0x6f, 0xde, 0xc8, 0x4f, 0xa7,
434
+		  0x69, 0x09, 0x12, 0x34, 0xb6, 0x95, 0x4d, 0xb8, 0x7f, 0x16,
435
+		  0xd0, 0x48, 0x17, 0x4a, 0x9e, 0x6e, 0x5e, 0xe2 ),
436
+	PUBLIC ( 0x30, 0x5c, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
437
+		 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x4b, 0x00,
438
+		 0x30, 0x48, 0x02, 0x41, 0x00, 0xa5, 0xe9, 0xdb, 0xa9, 0x1a,
439
+		 0x6e, 0xd6, 0x4c, 0x25, 0x50, 0xfe, 0x61, 0x77, 0x08, 0x7a,
440
+		 0x80, 0x36, 0xcb, 0x88, 0x49, 0x5c, 0xe8, 0xaa, 0x15, 0xf8,
441
+		 0xb3, 0xd6, 0x78, 0x51, 0x46, 0x86, 0x3a, 0x5f, 0xd5, 0x9f,
442
+		 0xab, 0xfe, 0x74, 0x8c, 0x53, 0x0d, 0xb5, 0x3c, 0x7d, 0x2c,
443
+		 0x35, 0x88, 0x3f, 0xde, 0xa2, 0xce, 0x46, 0x94, 0x30, 0xa9,
444
+		 0x76, 0xee, 0x25, 0xc5, 0x5d, 0xa6, 0xa6, 0x3a, 0xa5, 0x02,
445
+		 0x03, 0x01, 0x00, 0x01 ),
446
+	PLAINTEXT ( 0x60, 0xe7, 0xba, 0x9d, 0x5a, 0xe3, 0x2d, 0xfa, 0x5f, 0x47,
447
+		    0xdb, 0x93, 0x24, 0x2c, 0xc4, 0xe2, 0x61, 0xf3, 0x89, 0x4d,
448
+		    0x67, 0xad, 0xc8, 0xae, 0xf8, 0xe2, 0xfb, 0x52, 0x0f, 0x8d,
449
+		    0x18, 0x7e, 0x30, 0xd8, 0x8d, 0x94, 0x07, 0x92, 0x70, 0x91,
450
+		    0xaf, 0x3b, 0x92, 0xa6, 0x0f, 0x7a, 0x9b, 0x46, 0x85, 0x8c,
451
+		    0x2a, 0x5a, 0x78, 0x5d, 0x1e, 0x13, 0xbf, 0xe6, 0x12, 0xbd,
452
+		    0xb1, 0xbb, 0x92, 0x6d, 0x11, 0xed, 0xe1, 0xe4, 0x6e, 0x88,
453
+		    0x4d, 0x0b, 0x51, 0xd6, 0xfd, 0x6a, 0xb2, 0x9b, 0xd3, 0xfd,
454
+		    0x56, 0xec, 0xd9, 0xd6, 0xb8, 0xc5, 0xfd, 0x0c, 0xf7, 0x55,
455
+		    0x5f, 0xc5, 0x6f, 0xbc, 0xbb, 0x78, 0x2f, 0x50, 0x08, 0x65,
456
+		    0x0f, 0x12, 0xca, 0x5a, 0xea, 0x52, 0xd0, 0x94, 0x76, 0x17,
457
+		    0xe4, 0xba, 0x97, 0xba, 0x11, 0xbf, 0x05, 0x7e, 0xa1, 0xfd,
458
+		    0x7d, 0xb5, 0xf1, 0x3a, 0x7e, 0x6f, 0xa1, 0xaa, 0x97, 0x66,
459
+		    0x5d, 0x72, 0x76, 0x45, 0x40, 0xb5, 0x22, 0x71, 0x43, 0xe8,
460
+		    0x77, 0x76, 0xc8, 0x1b, 0xd2, 0xd1, 0x33, 0x05, 0x64, 0xa9,
461
+		    0xc2, 0xa8, 0x40, 0x40, 0x21, 0xdd, 0xcf, 0x07, 0x7e, 0xf2,
462
+		    0x4b, 0x80, 0x3d, 0x0f, 0x67, 0xf6, 0xbd, 0xc2, 0xc7, 0xe3,
463
+		    0x91, 0x71, 0xd6, 0x2d, 0xa1, 0xae, 0x81, 0x0c, 0xed, 0x54,
464
+		    0x48, 0x79, 0x8a, 0x78, 0x05, 0x74, 0x4d, 0x4f, 0xf0, 0xe0,
465
+		    0x3c, 0x41, 0x5c, 0x04, 0x0b, 0x68, 0x57, 0xc5, 0xd6 ),
466
+	&sha256_algorithm,
467
+	SIGNATURE ( 0x02, 0x2e, 0xc5, 0x2a, 0x2b, 0x7f, 0xb4, 0x80, 0xca, 0x9d,
468
+		    0x96, 0x5b, 0xaf, 0x1f, 0x72, 0x5b, 0x6e, 0xf1, 0x69, 0x7f,
469
+		    0x4d, 0x41, 0xd5, 0x9f, 0x00, 0xdc, 0x47, 0xf4, 0x68, 0x8f,
470
+		    0xda, 0xfc, 0xd1, 0x23, 0x96, 0x11, 0x1d, 0xc0, 0x1b, 0x1d,
471
+		    0x36, 0x66, 0x2a, 0xf9, 0x21, 0x51, 0xcb, 0xb9, 0x7d, 0x24,
472
+		    0x7d, 0x38, 0x37, 0xc4, 0xea, 0xdd, 0x3a, 0x6f, 0xa8, 0x65,
473
+		    0x60, 0x73, 0x77, 0x3c ) );
474
+
475
+/**
476
+ * Perform RSA self-tests
477
+ *
478
+ */
479
+static void rsa_test_exec ( void ) {
480
+
481
+	rsa_encrypt_decrypt_ok ( &hw_test );
482
+	rsa_signature_ok ( &md5_test );
483
+	rsa_signature_ok ( &sha1_test );
484
+	rsa_signature_ok ( &sha256_test );
485
+}
486
+
487
+/** RSA self-test */
488
+struct self_test rsa_test __self_test = {
489
+	.name = "rsa",
490
+	.exec = rsa_test_exec,
491
+};

+ 1
- 0
src/tests/tests.c View File

@@ -34,3 +34,4 @@ REQUIRE_OBJECT ( aes_cbc_test );
34 34
 REQUIRE_OBJECT ( hmac_drbg_test );
35 35
 REQUIRE_OBJECT ( hash_df_test );
36 36
 REQUIRE_OBJECT ( bigint_test );
37
+REQUIRE_OBJECT ( rsa_test );

Loading…
Cancel
Save