Browse Source

Make context sizes available for statically-allocated structures

tags/v0.9.3
Michael Brown 18 years ago
parent
commit
cc8f9e4b7f
4 changed files with 20 additions and 12 deletions
  1. 1
    1
      src/crypto/axtls_sha1.c
  2. 1
    11
      src/crypto/md5.c
  3. 14
    0
      src/include/gpxe/md5.h
  4. 4
    0
      src/include/gpxe/sha1.h

+ 1
- 1
src/crypto/axtls_sha1.c View File

17
 
17
 
18
 struct crypto_algorithm sha1_algorithm = {
18
 struct crypto_algorithm sha1_algorithm = {
19
 	.name		= "sha1",
19
 	.name		= "sha1",
20
-	.ctxsize	= sizeof ( SHA1_CTX ),
20
+	.ctxsize	= SHA1_CTX_SIZE,
21
 	.blocksize	= 64,
21
 	.blocksize	= 64,
22
 	.digestsize	= SHA1_SIZE,
22
 	.digestsize	= SHA1_SIZE,
23
 	.init		= sha1_init,
23
 	.init		= sha1_init,

+ 1
- 11
src/crypto/md5.c View File

26
 #include <gpxe/crypto.h>
26
 #include <gpxe/crypto.h>
27
 #include <gpxe/md5.h>
27
 #include <gpxe/md5.h>
28
 
28
 
29
-#define MD5_DIGEST_SIZE		16
30
-#define MD5_BLOCK_WORDS		16
31
-#define MD5_HASH_WORDS		4
32
-
33
-struct md5_ctx {
34
-	u32 hash[MD5_HASH_WORDS];
35
-	u32 block[MD5_BLOCK_WORDS];
36
-	u64 byte_count;
37
-};
38
-
39
 #define __md5step __attribute__ (( regparm ( 3 ) ))
29
 #define __md5step __attribute__ (( regparm ( 3 ) ))
40
 
30
 
41
 struct md5_step {
31
 struct md5_step {
236
 
226
 
237
 struct crypto_algorithm md5_algorithm = {
227
 struct crypto_algorithm md5_algorithm = {
238
 	.name		= "md5",
228
 	.name		= "md5",
239
-	.ctxsize	= sizeof ( struct md5_ctx ),
229
+	.ctxsize	= MD5_CTX_SIZE,
240
 	.blocksize	= ( MD5_BLOCK_WORDS * 4 ),
230
 	.blocksize	= ( MD5_BLOCK_WORDS * 4 ),
241
 	.digestsize	= MD5_DIGEST_SIZE,
231
 	.digestsize	= MD5_DIGEST_SIZE,
242
 	.init		= md5_init,
232
 	.init		= md5_init,

+ 14
- 0
src/include/gpxe/md5.h View File

3
 
3
 
4
 struct crypto_algorithm;
4
 struct crypto_algorithm;
5
 
5
 
6
+#include <stdint.h>
7
+
8
+#define MD5_DIGEST_SIZE		16
9
+#define MD5_BLOCK_WORDS		16
10
+#define MD5_HASH_WORDS		4
11
+
12
+struct md5_ctx {
13
+	u32 hash[MD5_HASH_WORDS];
14
+	u32 block[MD5_BLOCK_WORDS];
15
+	u64 byte_count;
16
+};
17
+
18
+#define MD5_CTX_SIZE sizeof ( struct md5_ctx )
19
+
6
 extern struct crypto_algorithm md5_algorithm;
20
 extern struct crypto_algorithm md5_algorithm;
7
 
21
 
8
 #endif /* _GPXE_MD5_H */
22
 #endif /* _GPXE_MD5_H */

+ 4
- 0
src/include/gpxe/sha1.h View File

1
 #ifndef _GPXE_SHA1_H
1
 #ifndef _GPXE_SHA1_H
2
 #define _GPXE_SHA1_H
2
 #define _GPXE_SHA1_H
3
 
3
 
4
+#include "crypto/axtls/crypto.h"
5
+
4
 struct crypto_algorithm;
6
 struct crypto_algorithm;
5
 
7
 
8
+#define SHA1_CTX_SIZE sizeof ( SHA1_CTX )
9
+
6
 extern struct crypto_algorithm sha1_algorithm;
10
 extern struct crypto_algorithm sha1_algorithm;
7
 
11
 
8
 #endif /* _GPXE_SHA1_H */
12
 #endif /* _GPXE_SHA1_H */

Loading…
Cancel
Save