浏览代码

[crypto] Split crypto_algorithm into {digest,cipher,pubkey}_algorithm

The various types of cryptographic algorithm are fundamentally
different, and it was probably a mistake to try to handle them via a
single common type.

pubkey_algorithm is a placeholder type for now.
tags/v0.9.7
Michael Brown 15 年前
父节点
当前提交
a3219b24a8

+ 3
- 3
src/crypto/axtls_aes.c 查看文件

@@ -59,12 +59,12 @@ static void aes_cbc_decrypt ( void *ctx, const void *data, void *dst,
59 59
 	AES_cbc_decrypt ( &aesctx->ctx, data, dst, len );
60 60
 }
61 61
 
62
-struct crypto_algorithm aes_cbc_algorithm = {
62
+struct cipher_algorithm aes_cbc_algorithm = {
63 63
 	.name		= "aes_cbc",
64 64
 	.ctxsize	= sizeof ( struct aes_cbc_context ),
65 65
 	.blocksize	= 16,
66 66
 	.setkey		= aes_cbc_setkey,
67 67
 	.setiv		= aes_cbc_setiv,
68
-	.encode		= aes_cbc_encrypt,
69
-	.decode		= aes_cbc_decrypt,
68
+	.encrypt	= aes_cbc_encrypt,
69
+	.decrypt	= aes_cbc_decrypt,
70 70
 };

+ 3
- 4
src/crypto/axtls_sha1.c 查看文件

@@ -6,8 +6,7 @@ static void sha1_init ( void *ctx ) {
6 6
 	SHA1Init ( ctx );
7 7
 }
8 8
 
9
-static void sha1_update ( void *ctx, const void *data, void *dst __unused,
10
-			  size_t len ) {
9
+static void sha1_update ( void *ctx, const void *data, size_t len ) {
11 10
 	SHA1Update ( ctx, data, len );
12 11
 }
13 12
 
@@ -15,12 +14,12 @@ static void sha1_final ( void *ctx, void *out ) {
15 14
 	SHA1Final ( ctx, out );
16 15
 }
17 16
 
18
-struct crypto_algorithm sha1_algorithm = {
17
+struct digest_algorithm sha1_algorithm = {
19 18
 	.name		= "sha1",
20 19
 	.ctxsize	= SHA1_CTX_SIZE,
21 20
 	.blocksize	= 64,
22 21
 	.digestsize	= SHA1_DIGEST_SIZE,
23 22
 	.init		= sha1_init,
24
-	.encode		= sha1_update,
23
+	.update		= sha1_update,
25 24
 	.final		= sha1_final,
26 25
 };

+ 1
- 1
src/crypto/chap.c 查看文件

@@ -42,7 +42,7 @@
42 42
  * eventually be freed by a call to chap_finish().
43 43
  */
44 44
 int chap_init ( struct chap_response *chap,
45
-		struct crypto_algorithm *digest ) {
45
+		struct digest_algorithm *digest ) {
46 46
 	size_t state_len;
47 47
 	void *state;
48 48
 

+ 6
- 6
src/crypto/cipher.c 查看文件

@@ -2,23 +2,23 @@
2 2
 #include <errno.h>
3 3
 #include <gpxe/crypto.h>
4 4
 
5
-int cipher_encrypt ( struct crypto_algorithm *crypto,
5
+int cipher_encrypt ( struct cipher_algorithm *cipher,
6 6
 		     void *ctx, const void *src, void *dst,
7 7
 		     size_t len ) {
8
-	if ( ( len & ( crypto->blocksize - 1 ) ) ) {
8
+	if ( ( len & ( cipher->blocksize - 1 ) ) ) {
9 9
 		return -EINVAL;
10 10
 	}
11
-	crypto->encode ( ctx, src, dst, len );
11
+	cipher->encrypt ( ctx, src, dst, len );
12 12
 	return 0;
13 13
 }
14 14
 
15
-int cipher_decrypt ( struct crypto_algorithm *crypto,
15
+int cipher_decrypt ( struct cipher_algorithm *cipher,
16 16
 		     void *ctx, const void *src, void *dst,
17 17
 		     size_t len ) {
18
-	if ( ( len & ( crypto->blocksize - 1 ) ) ) {
18
+	if ( ( len & ( cipher->blocksize - 1 ) ) ) {
19 19
 		return -EINVAL;
20 20
 	}
21
-	crypto->decode ( ctx, src, dst, len );
21
+	cipher->decrypt ( ctx, src, dst, len );
22 22
 	return 0;
23 23
 }
24 24
 

+ 39
- 23
src/crypto/crypto_null.c 查看文件

@@ -25,45 +25,61 @@
25 25
 #include <string.h>
26 26
 #include <gpxe/crypto.h>
27 27
 
28
-static void null_init ( void *ctx __unused ) {
28
+static void digest_null_init ( void *ctx __unused ) {
29 29
 	/* Do nothing */
30 30
 }
31 31
 
32
-static int null_setkey ( void *ctx __unused, const void *key __unused,
33
-			 size_t keylen __unused ) {
32
+static void digest_null_update ( void *ctx __unused, const void *src __unused,
33
+				 size_t len __unused ) {
34 34
 	/* Do nothing */
35
-	return 0;
36 35
 }
37 36
 
38
-static void null_setiv ( void *ctx __unused, const void *iv __unused ) {
37
+static void digest_null_final ( void *ctx __unused, void *out __unused ) {
39 38
 	/* Do nothing */
40 39
 }
41 40
 
42
-static void null_encode ( void *ctx __unused, const void *src,
43
-			  void *dst, size_t len ) {
44
-	if ( dst )
45
-		memcpy ( dst, src, len );
46
-}
41
+struct digest_algorithm digest_null = {
42
+	.name = "null",
43
+	.ctxsize = 0,
44
+	.blocksize = 1,
45
+	.digestsize = 0,
46
+	.init = digest_null_init,
47
+	.update = digest_null_update,
48
+	.final = digest_null_final,
49
+};
47 50
 
48
-static void null_decode ( void *ctx __unused, const void *src,
49
-			  void *dst, size_t len ) {
50
-	if ( dst )
51
-		memcpy ( dst, src, len );
51
+static int cipher_null_setkey ( void *ctx __unused, const void *key __unused,
52
+				size_t keylen __unused ) {
53
+	/* Do nothing */
54
+	return 0;
52 55
 }
53 56
 
54
-static void null_final ( void *ctx __unused, void *out __unused ) {
57
+static void cipher_null_setiv ( void *ctx __unused,
58
+				const void *iv __unused ) {
55 59
 	/* Do nothing */
56 60
 }
57 61
 
58
-struct crypto_algorithm crypto_null = {
62
+static void cipher_null_encrypt ( void *ctx __unused, const void *src,
63
+				  void *dst, size_t len ) {
64
+	memcpy ( dst, src, len );
65
+}
66
+
67
+static void cipher_null_decrypt ( void *ctx __unused, const void *src,
68
+				  void *dst, size_t len ) {
69
+	memcpy ( dst, src, len );
70
+}
71
+
72
+struct cipher_algorithm cipher_null = {
59 73
 	.name = "null",
60 74
 	.ctxsize = 0,
61 75
 	.blocksize = 1,
62
-	.digestsize = 0,
63
-	.init = null_init,
64
-	.setkey = null_setkey,
65
-	.setiv = null_setiv,
66
-	.encode = null_encode,
67
-	.decode = null_decode,
68
-	.final = null_final,
76
+	.setkey = cipher_null_setkey,
77
+	.setiv = cipher_null_setiv,
78
+	.encrypt = cipher_null_encrypt,
79
+	.decrypt = cipher_null_decrypt,
80
+};
81
+
82
+struct pubkey_algorithm pubkey_null = {
83
+	.name = "null",
84
+	.ctxsize = 0,
69 85
 };

+ 3
- 3
src/crypto/hmac.c 查看文件

@@ -35,7 +35,7 @@
35 35
  * @v key		Key
36 36
  * @v key_len		Length of key
37 37
  */
38
-static void hmac_reduce_key ( struct crypto_algorithm *digest,
38
+static void hmac_reduce_key ( struct digest_algorithm *digest,
39 39
 			      void *key, size_t *key_len ) {
40 40
 	uint8_t digest_ctx[digest->ctxsize];
41 41
 
@@ -58,7 +58,7 @@ static void hmac_reduce_key ( struct crypto_algorithm *digest,
58 58
  * will be replaced with its own digest, and key_len will be updated
59 59
  * accordingly).
60 60
  */
61
-void hmac_init ( struct crypto_algorithm *digest, void *digest_ctx,
61
+void hmac_init ( struct digest_algorithm *digest, void *digest_ctx,
62 62
 		 void *key, size_t *key_len ) {
63 63
 	unsigned char k_ipad[digest->blocksize];
64 64
 	unsigned int i;
@@ -93,7 +93,7 @@ void hmac_init ( struct crypto_algorithm *digest, void *digest_ctx,
93 93
  * will be replaced with its own digest, and key_len will be updated
94 94
  * accordingly).
95 95
  */
96
-void hmac_final ( struct crypto_algorithm *digest, void *digest_ctx,
96
+void hmac_final ( struct digest_algorithm *digest, void *digest_ctx,
97 97
 		  void *key, size_t *key_len, void *hmac ) {
98 98
 	unsigned char k_opad[digest->blocksize];
99 99
 	unsigned int i;

+ 3
- 4
src/crypto/md5.c 查看文件

@@ -167,8 +167,7 @@ static void md5_init(void *context)
167 167
 	mctx->byte_count = 0;
168 168
 }
169 169
 
170
-static void md5_update(void *context, const void *data, void *dst __unused,
171
-		       size_t len)
170
+static void md5_update(void *context, const void *data, size_t len)
172 171
 {
173 172
 	struct md5_ctx *mctx = context;
174 173
 	const u32 avail = sizeof(mctx->block) - (mctx->byte_count & 0x3f);
@@ -224,12 +223,12 @@ static void md5_final(void *context, void *out)
224 223
 	memset(mctx, 0, sizeof(*mctx));
225 224
 }
226 225
 
227
-struct crypto_algorithm md5_algorithm = {
226
+struct digest_algorithm md5_algorithm = {
228 227
 	.name		= "md5",
229 228
 	.ctxsize	= MD5_CTX_SIZE,
230 229
 	.blocksize	= ( MD5_BLOCK_WORDS * 4 ),
231 230
 	.digestsize	= MD5_DIGEST_SIZE,
232 231
 	.init		= md5_init,
233
-	.encode		= md5_update,
232
+	.update		= md5_update,
234 233
 	.final		= md5_final,
235 234
 };

+ 2
- 2
src/include/gpxe/aes.h 查看文件

@@ -1,8 +1,8 @@
1 1
 #ifndef _GPXE_AES_H
2 2
 #define _GPXE_AES_H
3 3
 
4
-struct crypto_algorithm;
4
+struct cipher_algorithm;
5 5
 
6
-extern struct crypto_algorithm aes_cbc_algorithm;
6
+extern struct cipher_algorithm aes_cbc_algorithm;
7 7
 
8 8
 #endif /* _GPXE_AES_H */

+ 3
- 3
src/include/gpxe/chap.h 查看文件

@@ -10,12 +10,12 @@
10 10
 #include <stdint.h>
11 11
 #include <gpxe/md5.h>
12 12
 
13
-struct crypto_algorithm;
13
+struct digest_algorithm;
14 14
 
15 15
 /** A CHAP response */
16 16
 struct chap_response {
17 17
 	/** Digest algorithm used for the response */
18
-	struct crypto_algorithm *digest;
18
+	struct digest_algorithm *digest;
19 19
 	/** Context used by the digest algorithm */
20 20
 	uint8_t *digest_context;
21 21
 	/** CHAP response */
@@ -25,7 +25,7 @@ struct chap_response {
25 25
 };
26 26
 
27 27
 extern int chap_init ( struct chap_response *chap,
28
-		       struct crypto_algorithm *digest );
28
+		       struct digest_algorithm *digest );
29 29
 extern void chap_update ( struct chap_response *chap, const void *data,
30 30
 			  size_t len );
31 31
 extern void chap_respond ( struct chap_response *chap );

+ 68
- 43
src/include/gpxe/crypto.h 查看文件

@@ -10,21 +10,46 @@
10 10
 #include <stdint.h>
11 11
 #include <stddef.h>
12 12
 
13
-/** A cryptographic algorithm */
14
-struct crypto_algorithm {
13
+/** A message digest algorithm */
14
+struct digest_algorithm {
15 15
 	/** Algorithm name */
16 16
 	const char *name;
17 17
 	/** Context size */
18 18
 	size_t ctxsize;
19 19
 	/** Block size */
20 20
 	size_t blocksize;
21
-	/** Final output size */
21
+	/** Digest size */
22 22
 	size_t digestsize;
23
-	/** Initialise algorithm
23
+	/** Initialise digest
24 24
 	 *
25 25
 	 * @v ctx		Context
26 26
 	 */
27 27
 	void ( * init ) ( void *ctx );
28
+	/** Update digest with new data
29
+	 *
30
+	 * @v ctx		Context
31
+	 * @v src		Data to digest
32
+	 * @v len		Length of data
33
+	 *
34
+	 * @v len is not necessarily a multiple of @c blocksize.
35
+	 */
36
+	void ( * update ) ( void *ctx, const void *src, size_t len );
37
+	/** Finalise digest
38
+	 *
39
+	 * @v ctx		Context
40
+	 * @v out		Buffer for digest output
41
+	 */
42
+	void ( * final ) ( void *ctx, void *out );
43
+};
44
+
45
+/** A cipher algorithm */
46
+struct cipher_algorithm {
47
+	/** Algorithm name */
48
+	const char *name;
49
+	/** Context size */
50
+	size_t ctxsize;
51
+	/** Block size */
52
+	size_t blocksize;
28 53
 	/** Set key
29 54
 	 *
30 55
 	 * @v ctx		Context
@@ -38,79 +63,79 @@ struct crypto_algorithm {
38 63
 	 * @v ctx		Context
39 64
 	 * @v iv		Initialisation vector
40 65
 	 */
41
-	void ( *setiv ) ( void *ctx, const void *iv );
42
-	/** Encode data
66
+	void ( * setiv ) ( void *ctx, const void *iv );
67
+	/** Encrypt data
43 68
 	 *
44 69
 	 * @v ctx		Context
45
-	 * @v src		Data to encode
46
-	 * @v dst		Encoded data, or NULL
70
+	 * @v src		Data to encrypt
71
+	 * @v dst		Buffer for encrypted data
47 72
 	 * @v len		Length of data
48 73
 	 * @ret rc		Return status code
49 74
 	 *
50
-	 * For a cipher algorithm, the enciphered data should be
51
-	 * placed in @c dst.  For a digest algorithm, only the digest
52
-	 * state should be updated, and @c dst will be NULL.
53
-	 *
54 75
 	 * @v len is guaranteed to be a multiple of @c blocksize.
55 76
 	 */
56
-	void ( * encode ) ( void *ctx, const void *src, void *dst,
57
-			    size_t len );
58
-	/** Decode data
77
+	void ( * encrypt ) ( void *ctx, const void *src, void *dst,
78
+			     size_t len );
79
+	/** Decrypt data
59 80
 	 *
60 81
 	 * @v ctx		Context
61
-	 * @v src		Data to decode
62
-	 * @v dst		Decoded data
82
+	 * @v src		Data to decrypt
83
+	 * @v dst		Buffer for decrypted data
63 84
 	 * @v len		Length of data
64 85
 	 * @ret rc		Return status code
65 86
 	 *
66 87
 	 * @v len is guaranteed to be a multiple of @c blocksize.
67 88
 	 */
68
-	void ( * decode ) ( void *ctx, const void *src, void *dst,
69
-			    size_t len );
70
-	/** Finalise algorithm
71
-	 *
72
-	 * @v ctx		Context
73
-	 * @v out		Algorithm final output
74
-	 */
75
-	void ( * final ) ( void *ctx, void *out );
89
+	void ( * decrypt ) ( void *ctx, const void *src, void *dst,
90
+			     size_t len );
91
+};
92
+
93
+/** A public key algorithm */
94
+struct pubkey_algorithm {
95
+	/** Algorithm name */
96
+	const char *name;
97
+	/** Context size */
98
+	size_t ctxsize;
76 99
 };
77 100
 
78
-static inline void digest_init ( struct crypto_algorithm *crypto,
101
+static inline void digest_init ( struct digest_algorithm *digest,
79 102
 				 void *ctx ) {
80
-	crypto->init ( ctx );
103
+	digest->init ( ctx );
81 104
 }
82 105
 
83
-static inline void digest_update ( struct crypto_algorithm *crypto,
106
+static inline void digest_update ( struct digest_algorithm *digest,
84 107
 				   void *ctx, const void *data, size_t len ) {
85
-	crypto->encode ( ctx, data, NULL, len );
108
+	digest->update ( ctx, data, len );
86 109
 }
87 110
 
88
-static inline void digest_final ( struct crypto_algorithm *crypto,
111
+static inline void digest_final ( struct digest_algorithm *digest,
89 112
 				  void *ctx, void *out ) {
90
-	crypto->final ( ctx, out );
113
+	digest->final ( ctx, out );
91 114
 }
92 115
 
93
-static inline void cipher_setiv ( struct crypto_algorithm *crypto,
94
-				  void *ctx, const void *iv ) {
95
-	crypto->setiv ( ctx, iv );
96
-}
97
-
98
-static inline int cipher_setkey ( struct crypto_algorithm *crypto,
116
+static inline int cipher_setkey ( struct cipher_algorithm *cipher,
99 117
 				  void *ctx, const void *key, size_t keylen ) {
100
-	return crypto->setkey ( ctx, key, keylen );
118
+	return cipher->setkey ( ctx, key, keylen );
101 119
 }
102 120
 
103
-static inline int is_stream_cipher ( struct crypto_algorithm *crypto ) {
104
-	return ( crypto->blocksize == 1 );
121
+static inline void cipher_setiv ( struct cipher_algorithm *cipher,
122
+				  void *ctx, const void *iv ) {
123
+	cipher->setiv ( ctx, iv );
105 124
 }
106 125
 
107
-extern struct crypto_algorithm crypto_null;
126
+static inline int is_stream_cipher ( struct cipher_algorithm *cipher ) {
127
+	return ( cipher->blocksize == 1 );
128
+}
108 129
 
109
-extern int cipher_encrypt ( struct crypto_algorithm *crypto,
130
+extern int cipher_encrypt ( struct cipher_algorithm *cipher,
110 131
 			    void *ctx, const void *src, void *dst,
111 132
 			    size_t len );
112
-extern int cipher_decrypt ( struct crypto_algorithm *crypto,
133
+extern int cipher_decrypt ( struct cipher_algorithm *cipher,
113 134
 			    void *ctx, const void *src, void *dst,
114 135
 			    size_t len );
115 136
 
137
+extern struct digest_algorithm digest_null;
138
+extern struct cipher_algorithm cipher_null;
139
+extern struct pubkey_algorithm pubkey_null;
140
+
116 141
 #endif /* _GPXE_CRYPTO_H */

+ 3
- 3
src/include/gpxe/hmac.h 查看文件

@@ -16,15 +16,15 @@
16 16
  * @v data		Data
17 17
  * @v len		Length of data
18 18
  */
19
-static inline void hmac_update ( struct crypto_algorithm *digest,
19
+static inline void hmac_update ( struct digest_algorithm *digest,
20 20
 				 void *digest_ctx, const void *data,
21 21
 				 size_t len ) {
22 22
 	digest_update ( digest, digest_ctx, data, len );
23 23
 }
24 24
 
25
-extern void hmac_init ( struct crypto_algorithm *digest, void *digest_ctx,
25
+extern void hmac_init ( struct digest_algorithm *digest, void *digest_ctx,
26 26
 			void *key, size_t *key_len );
27
-extern void hmac_final ( struct crypto_algorithm *digest, void *digest_ctx,
27
+extern void hmac_final ( struct digest_algorithm *digest, void *digest_ctx,
28 28
 			 void *key, size_t *key_len, void *hmac );
29 29
 
30 30
 #endif /* _GPXE_HMAC_H */

+ 2
- 2
src/include/gpxe/md5.h 查看文件

@@ -1,7 +1,7 @@
1 1
 #ifndef _GPXE_MD5_H
2 2
 #define _GPXE_MD5_H
3 3
 
4
-struct crypto_algorithm;
4
+struct digest_algorithm;
5 5
 
6 6
 #include <stdint.h>
7 7
 
@@ -17,6 +17,6 @@ struct md5_ctx {
17 17
 
18 18
 #define MD5_CTX_SIZE sizeof ( struct md5_ctx )
19 19
 
20
-extern struct crypto_algorithm md5_algorithm;
20
+extern struct digest_algorithm md5_algorithm;
21 21
 
22 22
 #endif /* _GPXE_MD5_H */

+ 2
- 2
src/include/gpxe/rsa.h 查看文件

@@ -1,9 +1,9 @@
1 1
 #ifndef _GPXE_RSA_H
2 2
 #define _GPXE_RSA_H
3 3
 
4
-struct crypto_algorithm;
4
+struct pubkey_algorithm;
5 5
 
6
-extern struct crypto_algorithm rsa_algorithm;
6
+extern struct pubkey_algorithm rsa_algorithm;
7 7
 
8 8
 #include "crypto/axtls/crypto.h"
9 9
 

+ 2
- 2
src/include/gpxe/sha1.h 查看文件

@@ -3,11 +3,11 @@
3 3
 
4 4
 #include "crypto/axtls/crypto.h"
5 5
 
6
-struct crypto_algorithm;
6
+struct digest_algorithm;
7 7
 
8 8
 #define SHA1_CTX_SIZE sizeof ( SHA1_CTX )
9 9
 #define SHA1_DIGEST_SIZE SHA1_SIZE
10 10
 
11
-extern struct crypto_algorithm sha1_algorithm;
11
+extern struct digest_algorithm sha1_algorithm;
12 12
 
13 13
 #endif /* _GPXE_SHA1_H */

+ 3
- 3
src/include/gpxe/tls.h 查看文件

@@ -91,11 +91,11 @@ enum tls_tx_state {
91 91
 /** A TLS cipher specification */
92 92
 struct tls_cipherspec {
93 93
 	/** Public-key encryption algorithm */
94
-	struct crypto_algorithm *pubkey;
94
+	struct pubkey_algorithm *pubkey;
95 95
 	/** Bulk encryption cipher algorithm */
96
-	struct crypto_algorithm *cipher;
96
+	struct cipher_algorithm *cipher;
97 97
 	/** MAC digest algorithm */
98
-	struct crypto_algorithm *digest;
98
+	struct digest_algorithm *digest;
99 99
 	/** Key length */
100 100
 	size_t key_len;
101 101
 	/** Dynamically-allocated storage */

+ 17
- 17
src/net/tls.c 查看文件

@@ -136,7 +136,7 @@ static void tls_generate_random ( void *data, size_t len ) {
136 136
  * @v digest_ctx	Digest context
137 137
  * @v args		( data, len ) pairs of data, terminated by NULL
138 138
  */
139
-static void tls_hmac_update_va ( struct crypto_algorithm *digest,
139
+static void tls_hmac_update_va ( struct digest_algorithm *digest,
140 140
 				 void *digest_ctx, va_list args ) {
141 141
 	void *data;
142 142
 	size_t len;
@@ -159,7 +159,7 @@ static void tls_hmac_update_va ( struct crypto_algorithm *digest,
159 159
  * @v seeds		( data, len ) pairs of seed data, terminated by NULL
160 160
  */
161 161
 static void tls_p_hash_va ( struct tls_session *tls,
162
-			    struct crypto_algorithm *digest,
162
+			    struct digest_algorithm *digest,
163 163
 			    void *secret, size_t secret_len,
164 164
 			    void *out, size_t out_len,
165 165
 			    va_list seeds ) {
@@ -409,9 +409,9 @@ static void tls_clear_cipher ( struct tls_session *tls __unused,
409 409
 			       struct tls_cipherspec *cipherspec ) {
410 410
 	free ( cipherspec->dynamic );
411 411
 	memset ( cipherspec, 0, sizeof ( cipherspec ) );
412
-	cipherspec->pubkey = &crypto_null;
413
-	cipherspec->cipher = &crypto_null;
414
-	cipherspec->digest = &crypto_null;
412
+	cipherspec->pubkey = &pubkey_null;
413
+	cipherspec->cipher = &cipher_null;
414
+	cipherspec->digest = &digest_null;
415 415
 }
416 416
 
417 417
 /**
@@ -427,9 +427,9 @@ static void tls_clear_cipher ( struct tls_session *tls __unused,
427 427
  */
428 428
 static int tls_set_cipher ( struct tls_session *tls,
429 429
 			    struct tls_cipherspec *cipherspec,
430
-			    struct crypto_algorithm *pubkey,
431
-			    struct crypto_algorithm *cipher,
432
-			    struct crypto_algorithm *digest,
430
+			    struct pubkey_algorithm *pubkey,
431
+			    struct cipher_algorithm *cipher,
432
+			    struct digest_algorithm *digest,
433 433
 			    size_t key_len ) {
434 434
 	size_t total;
435 435
 	void *dynamic;
@@ -473,9 +473,9 @@ static int tls_set_cipher ( struct tls_session *tls,
473 473
  */
474 474
 static int tls_select_cipher ( struct tls_session *tls,
475 475
 			       unsigned int cipher_suite ) {
476
-	struct crypto_algorithm *pubkey = &crypto_null;
477
-	struct crypto_algorithm *cipher = &crypto_null;
478
-	struct crypto_algorithm *digest = &crypto_null;
476
+	struct pubkey_algorithm *pubkey = &pubkey_null;
477
+	struct cipher_algorithm *cipher = &cipher_null;
478
+	struct digest_algorithm *digest = &digest_null;
479 479
 	unsigned int key_len = 0;
480 480
 	int rc;
481 481
 
@@ -524,9 +524,9 @@ static int tls_change_cipher ( struct tls_session *tls,
524 524
 
525 525
 	/* Sanity check */
526 526
 	if ( /* FIXME (when pubkey is not hard-coded to RSA):
527
-	      * ( pending->pubkey == &crypto_null ) || */
528
-	     ( pending->cipher == &crypto_null ) ||
529
-	     ( pending->digest == &crypto_null ) ) {
527
+	      * ( pending->pubkey == &pubkey_null ) || */
528
+	     ( pending->cipher == &cipher_null ) ||
529
+	     ( pending->digest == &digest_null ) ) {
530 530
 		DBGC ( tls, "TLS %p refusing to use null cipher\n", tls );
531 531
 		return -ENOTSUP;
532 532
 	}
@@ -567,8 +567,8 @@ static void tls_add_handshake ( struct tls_session *tls,
567 567
  * far.
568 568
  */
569 569
 static void tls_verify_handshake ( struct tls_session *tls, void *out ) {
570
-	struct crypto_algorithm *md5 = &md5_algorithm;
571
-	struct crypto_algorithm *sha1 = &sha1_algorithm;
570
+	struct digest_algorithm *md5 = &md5_algorithm;
571
+	struct digest_algorithm *sha1 = &sha1_algorithm;
572 572
 	uint8_t md5_ctx[md5->ctxsize];
573 573
 	uint8_t sha1_ctx[sha1->ctxsize];
574 574
 	void *md5_digest = out;
@@ -1060,7 +1060,7 @@ static void tls_hmac ( struct tls_session *tls __unused,
1060 1060
 		       struct tls_cipherspec *cipherspec,
1061 1061
 		       uint64_t seq, struct tls_header *tlshdr,
1062 1062
 		       const void *data, size_t len, void *hmac ) {
1063
-	struct crypto_algorithm *digest = cipherspec->digest;
1063
+	struct digest_algorithm *digest = cipherspec->digest;
1064 1064
 	uint8_t digest_ctx[digest->ctxsize];
1065 1065
 
1066 1066
 	hmac_init ( digest, digest_ctx, cipherspec->mac_secret,

正在加载...
取消
保存