Bladeren bron

Make context sizes available for statically-allocated structures

tags/v0.9.3
Michael Brown 18 jaren geleden
bovenliggende
commit
cc8f9e4b7f
4 gewijzigde bestanden met toevoegingen van 20 en 12 verwijderingen
  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 Bestand weergeven

@@ -17,7 +17,7 @@ static void sha1_final ( void *ctx, void *out ) {
17 17
 
18 18
 struct crypto_algorithm sha1_algorithm = {
19 19
 	.name		= "sha1",
20
-	.ctxsize	= sizeof ( SHA1_CTX ),
20
+	.ctxsize	= SHA1_CTX_SIZE,
21 21
 	.blocksize	= 64,
22 22
 	.digestsize	= SHA1_SIZE,
23 23
 	.init		= sha1_init,

+ 1
- 11
src/crypto/md5.c Bestand weergeven

@@ -26,16 +26,6 @@
26 26
 #include <gpxe/crypto.h>
27 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 29
 #define __md5step __attribute__ (( regparm ( 3 ) ))
40 30
 
41 31
 struct md5_step {
@@ -236,7 +226,7 @@ static void md5_final(void *context, void *out)
236 226
 
237 227
 struct crypto_algorithm md5_algorithm = {
238 228
 	.name		= "md5",
239
-	.ctxsize	= sizeof ( struct md5_ctx ),
229
+	.ctxsize	= MD5_CTX_SIZE,
240 230
 	.blocksize	= ( MD5_BLOCK_WORDS * 4 ),
241 231
 	.digestsize	= MD5_DIGEST_SIZE,
242 232
 	.init		= md5_init,

+ 14
- 0
src/include/gpxe/md5.h Bestand weergeven

@@ -3,6 +3,20 @@
3 3
 
4 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 20
 extern struct crypto_algorithm md5_algorithm;
7 21
 
8 22
 #endif /* _GPXE_MD5_H */

+ 4
- 0
src/include/gpxe/sha1.h Bestand weergeven

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

Laden…
Annuleren
Opslaan