diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2009-10-21 16:45:02 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-12-11 15:23:12 -0500 |
commit | ef3e746815954ada673fab6545679e7418d1b1d3 (patch) | |
tree | b1ff7a197a87134ecde346a13d7f7fc72bd44c0f /drivers/staging/rt2860 | |
parent | 46ff62398cdabb87522c0564d1ebfa397132abe4 (diff) |
Staging: rt28x0: remove unused SHA256 code
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/rt2860')
-rw-r--r-- | drivers/staging/rt2860/common/crypt_sha2.c | 257 | ||||
-rw-r--r-- | drivers/staging/rt2860/crypt_hmac.h | 11 | ||||
-rw-r--r-- | drivers/staging/rt2860/crypt_sha2.h | 28 |
3 files changed, 0 insertions, 296 deletions
diff --git a/drivers/staging/rt2860/common/crypt_sha2.c b/drivers/staging/rt2860/common/crypt_sha2.c index cb3f7c27b62..d4b23966cb6 100644 --- a/drivers/staging/rt2860/common/crypt_sha2.c +++ b/drivers/staging/rt2860/common/crypt_sha2.c | |||
@@ -47,42 +47,7 @@ static const UINT32 SHA1_K[4] = { | |||
47 | static const UINT32 SHA1_DefaultHashValue[5] = { | 47 | static const UINT32 SHA1_DefaultHashValue[5] = { |
48 | 0x67452301UL, 0xefcdab89UL, 0x98badcfeUL, 0x10325476UL, 0xc3d2e1f0UL | 48 | 0x67452301UL, 0xefcdab89UL, 0x98badcfeUL, 0x10325476UL, 0xc3d2e1f0UL |
49 | }; | 49 | }; |
50 | #endif /* SHA1_SUPPORT */ | ||
51 | |||
52 | |||
53 | #ifdef SHA256_SUPPORT | ||
54 | /* SHA256 functions */ | ||
55 | #define Zsigma_256_0(x) (ROTR32(x,2) ^ ROTR32(x,13) ^ ROTR32(x,22)) | ||
56 | #define Zsigma_256_1(x) (ROTR32(x,6) ^ ROTR32(x,11) ^ ROTR32(x,25)) | ||
57 | #define Sigma_256_0(x) (ROTR32(x,7) ^ ROTR32(x,18) ^ SHR(x,3)) | ||
58 | #define Sigma_256_1(x) (ROTR32(x,17) ^ ROTR32(x,19) ^ SHR(x,10)) | ||
59 | /* SHA256 constants */ | ||
60 | static const UINT32 SHA256_K[64] = { | ||
61 | 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL, | ||
62 | 0x3956c25bUL, 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL, | ||
63 | 0xd807aa98UL, 0x12835b01UL, 0x243185beUL, 0x550c7dc3UL, | ||
64 | 0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL, 0xc19bf174UL, | ||
65 | 0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL, | ||
66 | 0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL, | ||
67 | 0x983e5152UL, 0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL, | ||
68 | 0xc6e00bf3UL, 0xd5a79147UL, 0x06ca6351UL, 0x14292967UL, | ||
69 | 0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL, 0x53380d13UL, | ||
70 | 0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL, | ||
71 | 0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL, | ||
72 | 0xd192e819UL, 0xd6990624UL, 0xf40e3585UL, 0x106aa070UL, | ||
73 | 0x19a4c116UL, 0x1e376c08UL, 0x2748774cUL, 0x34b0bcb5UL, | ||
74 | 0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL, 0x682e6ff3UL, | ||
75 | 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL, | ||
76 | 0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL | ||
77 | }; | ||
78 | static const UINT32 SHA256_DefaultHashValue[8] = { | ||
79 | 0x6a09e667UL, 0xbb67ae85UL, 0x3c6ef372UL, 0xa54ff53aUL, | ||
80 | 0x510e527fUL, 0x9b05688cUL, 0x1f83d9abUL, 0x5be0cd19UL | ||
81 | }; | ||
82 | #endif /* SHA256_SUPPORT */ | ||
83 | 50 | ||
84 | |||
85 | #ifdef SHA1_SUPPORT | ||
86 | /* | 51 | /* |
87 | ======================================================================== | 52 | ======================================================================== |
88 | Routine Description: | 53 | Routine Description: |
@@ -310,226 +275,4 @@ VOID RT_SHA1 ( | |||
310 | } /* End of RT_SHA1 */ | 275 | } /* End of RT_SHA1 */ |
311 | #endif /* SHA1_SUPPORT */ | 276 | #endif /* SHA1_SUPPORT */ |
312 | 277 | ||
313 | |||
314 | #ifdef SHA256_SUPPORT | ||
315 | /* | ||
316 | ======================================================================== | ||
317 | Routine Description: | ||
318 | Initial SHA256_CTX_STRUC | ||
319 | |||
320 | Arguments: | ||
321 | pSHA_CTX Pointer to SHA256_CTX_STRUC | ||
322 | |||
323 | Return Value: | ||
324 | None | ||
325 | |||
326 | Note: | ||
327 | None | ||
328 | ======================================================================== | ||
329 | */ | ||
330 | VOID SHA256_Init ( | ||
331 | IN SHA256_CTX_STRUC *pSHA_CTX) | ||
332 | { | ||
333 | NdisMoveMemory(pSHA_CTX->HashValue, SHA256_DefaultHashValue, | ||
334 | sizeof(SHA256_DefaultHashValue)); | ||
335 | NdisZeroMemory(pSHA_CTX->Block, SHA256_BLOCK_SIZE); | ||
336 | pSHA_CTX->MessageLen = 0; | ||
337 | pSHA_CTX->BlockLen = 0; | ||
338 | } /* End of SHA256_Init */ | ||
339 | |||
340 | |||
341 | /* | ||
342 | ======================================================================== | ||
343 | Routine Description: | ||
344 | SHA256 computation for one block (512 bits) | ||
345 | |||
346 | Arguments: | ||
347 | pSHA_CTX Pointer to SHA256_CTX_STRUC | ||
348 | |||
349 | Return Value: | ||
350 | None | ||
351 | |||
352 | Note: | ||
353 | None | ||
354 | ======================================================================== | ||
355 | */ | ||
356 | VOID SHA256_Hash ( | ||
357 | IN SHA256_CTX_STRUC *pSHA_CTX) | ||
358 | { | ||
359 | UINT32 W_i,t; | ||
360 | UINT32 W[64]; | ||
361 | UINT32 a,b,c,d,e,f,g,h,T1,T2; | ||
362 | |||
363 | /* Prepare the message schedule, {W_i}, 0 < t < 15 */ | ||
364 | NdisMoveMemory(W, pSHA_CTX->Block, SHA256_BLOCK_SIZE); | ||
365 | for (W_i = 0; W_i < 16; W_i++) | ||
366 | W[W_i] = cpu2be32(W[W_i]); /* Endian Swap */ | ||
367 | /* End of for */ | ||
368 | |||
369 | /* SHA256 hash computation */ | ||
370 | /* Initialize the working variables */ | ||
371 | a = pSHA_CTX->HashValue[0]; | ||
372 | b = pSHA_CTX->HashValue[1]; | ||
373 | c = pSHA_CTX->HashValue[2]; | ||
374 | d = pSHA_CTX->HashValue[3]; | ||
375 | e = pSHA_CTX->HashValue[4]; | ||
376 | f = pSHA_CTX->HashValue[5]; | ||
377 | g = pSHA_CTX->HashValue[6]; | ||
378 | h = pSHA_CTX->HashValue[7]; | ||
379 | |||
380 | /* 64 rounds */ | ||
381 | for (t = 0;t < 64;t++) { | ||
382 | if (t > 15) /* Prepare the message schedule, {W_i}, 16 < t < 63 */ | ||
383 | W[t] = Sigma_256_1(W[t-2]) + W[t-7] + Sigma_256_0(W[t-15]) + W[t-16]; | ||
384 | /* End of if */ | ||
385 | T1 = h + Zsigma_256_1(e) + Ch(e,f,g) + SHA256_K[t] + W[t]; | ||
386 | T2 = Zsigma_256_0(a) + Maj(a,b,c); | ||
387 | h = g; | ||
388 | g = f; | ||
389 | f = e; | ||
390 | e = d + T1; | ||
391 | d = c; | ||
392 | c = b; | ||
393 | b = a; | ||
394 | a = T1 + T2; | ||
395 | } /* End of for */ | ||
396 | |||
397 | /* Compute the i^th intermediate hash value H^(i) */ | ||
398 | pSHA_CTX->HashValue[0] += a; | ||
399 | pSHA_CTX->HashValue[1] += b; | ||
400 | pSHA_CTX->HashValue[2] += c; | ||
401 | pSHA_CTX->HashValue[3] += d; | ||
402 | pSHA_CTX->HashValue[4] += e; | ||
403 | pSHA_CTX->HashValue[5] += f; | ||
404 | pSHA_CTX->HashValue[6] += g; | ||
405 | pSHA_CTX->HashValue[7] += h; | ||
406 | |||
407 | NdisZeroMemory(pSHA_CTX->Block, SHA256_BLOCK_SIZE); | ||
408 | pSHA_CTX->BlockLen = 0; | ||
409 | } /* End of SHA256_Hash */ | ||
410 | |||
411 | |||
412 | /* | ||
413 | ======================================================================== | ||
414 | Routine Description: | ||
415 | The message is appended to block. If block size > 64 bytes, the SHA256_Hash | ||
416 | will be called. | ||
417 | |||
418 | Arguments: | ||
419 | pSHA_CTX Pointer to SHA256_CTX_STRUC | ||
420 | message Message context | ||
421 | messageLen The length of message in bytes | ||
422 | |||
423 | Return Value: | ||
424 | None | ||
425 | |||
426 | Note: | ||
427 | None | ||
428 | ======================================================================== | ||
429 | */ | ||
430 | VOID SHA256_Append ( | ||
431 | IN SHA256_CTX_STRUC *pSHA_CTX, | ||
432 | IN const UINT8 Message[], | ||
433 | IN UINT MessageLen) | ||
434 | { | ||
435 | UINT appendLen = 0; | ||
436 | UINT diffLen = 0; | ||
437 | |||
438 | while (appendLen != MessageLen) { | ||
439 | diffLen = MessageLen - appendLen; | ||
440 | if ((pSHA_CTX->BlockLen + diffLen) < SHA256_BLOCK_SIZE) { | ||
441 | NdisMoveMemory(pSHA_CTX->Block + pSHA_CTX->BlockLen, | ||
442 | Message + appendLen, diffLen); | ||
443 | pSHA_CTX->BlockLen += diffLen; | ||
444 | appendLen += diffLen; | ||
445 | } | ||
446 | else | ||
447 | { | ||
448 | NdisMoveMemory(pSHA_CTX->Block + pSHA_CTX->BlockLen, | ||
449 | Message + appendLen, SHA256_BLOCK_SIZE - pSHA_CTX->BlockLen); | ||
450 | appendLen += (SHA256_BLOCK_SIZE - pSHA_CTX->BlockLen); | ||
451 | pSHA_CTX->BlockLen = SHA256_BLOCK_SIZE; | ||
452 | SHA256_Hash(pSHA_CTX); | ||
453 | } /* End of if */ | ||
454 | } /* End of while */ | ||
455 | pSHA_CTX->MessageLen += MessageLen; | ||
456 | } /* End of SHA256_Append */ | ||
457 | |||
458 | |||
459 | /* | ||
460 | ======================================================================== | ||
461 | Routine Description: | ||
462 | 1. Append bit 1 to end of the message | ||
463 | 2. Append the length of message in rightmost 64 bits | ||
464 | 3. Transform the Hash Value to digest message | ||
465 | |||
466 | Arguments: | ||
467 | pSHA_CTX Pointer to SHA256_CTX_STRUC | ||
468 | |||
469 | Return Value: | ||
470 | digestMessage Digest message | ||
471 | |||
472 | Note: | ||
473 | None | ||
474 | ======================================================================== | ||
475 | */ | ||
476 | VOID SHA256_End ( | ||
477 | IN SHA256_CTX_STRUC *pSHA_CTX, | ||
478 | OUT UINT8 DigestMessage[]) | ||
479 | { | ||
480 | UINT index; | ||
481 | UINT64 message_length_bits; | ||
482 | |||
483 | /* Append bit 1 to end of the message */ | ||
484 | NdisFillMemory(pSHA_CTX->Block + pSHA_CTX->BlockLen, 1, 0x80); | ||
485 | |||
486 | /* 55 = 64 - 8 - 1: append 1 bit(1 byte) and message length (8 bytes) */ | ||
487 | if (pSHA_CTX->BlockLen > 55) | ||
488 | SHA256_Hash(pSHA_CTX); | ||
489 | /* End of if */ | ||
490 | |||
491 | /* Append the length of message in rightmost 64 bits */ | ||
492 | message_length_bits = pSHA_CTX->MessageLen*8; | ||
493 | message_length_bits = cpu2be64(message_length_bits); | ||
494 | NdisMoveMemory(&pSHA_CTX->Block[56], &message_length_bits, 8); | ||
495 | SHA256_Hash(pSHA_CTX); | ||
496 | |||
497 | /* Return message digest, transform the UINT32 hash value to bytes */ | ||
498 | for (index = 0; index < 8;index++) | ||
499 | pSHA_CTX->HashValue[index] = cpu2be32(pSHA_CTX->HashValue[index]); | ||
500 | /* End of for */ | ||
501 | NdisMoveMemory(DigestMessage, pSHA_CTX->HashValue, SHA256_DIGEST_SIZE); | ||
502 | } /* End of SHA256_End */ | ||
503 | |||
504 | |||
505 | /* | ||
506 | ======================================================================== | ||
507 | Routine Description: | ||
508 | SHA256 algorithm | ||
509 | |||
510 | Arguments: | ||
511 | message Message context | ||
512 | messageLen The length of message in bytes | ||
513 | |||
514 | Return Value: | ||
515 | digestMessage Digest message | ||
516 | |||
517 | Note: | ||
518 | None | ||
519 | ======================================================================== | ||
520 | */ | ||
521 | VOID RT_SHA256 ( | ||
522 | IN const UINT8 Message[], | ||
523 | IN UINT MessageLen, | ||
524 | OUT UINT8 DigestMessage[]) | ||
525 | { | ||
526 | SHA256_CTX_STRUC sha_ctx; | ||
527 | |||
528 | NdisZeroMemory(&sha_ctx, sizeof(SHA256_CTX_STRUC)); | ||
529 | SHA256_Init(&sha_ctx); | ||
530 | SHA256_Append(&sha_ctx, Message, MessageLen); | ||
531 | SHA256_End(&sha_ctx, DigestMessage); | ||
532 | } /* End of RT_SHA256 */ | ||
533 | #endif /* SHA256_SUPPORT */ | ||
534 | |||
535 | /* End of crypt_sha2.c */ | 278 | /* End of crypt_sha2.c */ |
diff --git a/drivers/staging/rt2860/crypt_hmac.h b/drivers/staging/rt2860/crypt_hmac.h index 9314ff7547b..717b8a26fd1 100644 --- a/drivers/staging/rt2860/crypt_hmac.h +++ b/drivers/staging/rt2860/crypt_hmac.h | |||
@@ -57,17 +57,6 @@ VOID HMAC_SHA1 ( | |||
57 | IN UINT MACLen); | 57 | IN UINT MACLen); |
58 | #endif /* SHA1_SUPPORT */ | 58 | #endif /* SHA1_SUPPORT */ |
59 | 59 | ||
60 | #ifdef SHA256_SUPPORT | ||
61 | #define HMAC_SHA256_SUPPORT | ||
62 | VOID HMAC_SHA256 ( | ||
63 | IN const UINT8 Key[], | ||
64 | IN UINT KeyLen, | ||
65 | IN const UINT8 Message[], | ||
66 | IN UINT MessageLen, | ||
67 | OUT UINT8 MAC[], | ||
68 | IN UINT MACLen); | ||
69 | #endif /* SHA256_SUPPORT */ | ||
70 | |||
71 | #ifdef MD5_SUPPORT | 60 | #ifdef MD5_SUPPORT |
72 | #define HMAC_MD5_SUPPORT | 61 | #define HMAC_MD5_SUPPORT |
73 | VOID HMAC_MD5 ( | 62 | VOID HMAC_MD5 ( |
diff --git a/drivers/staging/rt2860/crypt_sha2.h b/drivers/staging/rt2860/crypt_sha2.h index 055efb15a45..5b95965e4d1 100644 --- a/drivers/staging/rt2860/crypt_sha2.h +++ b/drivers/staging/rt2860/crypt_sha2.h | |||
@@ -50,7 +50,6 @@ | |||
50 | 50 | ||
51 | /* Algorithm options */ | 51 | /* Algorithm options */ |
52 | #define SHA1_SUPPORT | 52 | #define SHA1_SUPPORT |
53 | #define SHA256_SUPPORT | ||
54 | 53 | ||
55 | #ifdef SHA1_SUPPORT | 54 | #ifdef SHA1_SUPPORT |
56 | #define SHA1_BLOCK_SIZE 64 /* 512 bits = 64 bytes */ | 55 | #define SHA1_BLOCK_SIZE 64 /* 512 bits = 64 bytes */ |
@@ -79,31 +78,4 @@ VOID RT_SHA1 ( | |||
79 | OUT UINT8 DigestMessage[]); | 78 | OUT UINT8 DigestMessage[]); |
80 | #endif /* SHA1_SUPPORT */ | 79 | #endif /* SHA1_SUPPORT */ |
81 | 80 | ||
82 | #ifdef SHA256_SUPPORT | ||
83 | #define SHA256_BLOCK_SIZE 64 /* 512 bits = 64 bytes */ | ||
84 | #define SHA256_DIGEST_SIZE 32 /* 256 bits = 32 bytes */ | ||
85 | typedef struct _SHA256_CTX_STRUC { | ||
86 | UINT32 HashValue[8]; /* 8 = (SHA256_DIGEST_SIZE / 32) */ | ||
87 | UINT64 MessageLen; /* total size */ | ||
88 | UINT8 Block[SHA256_BLOCK_SIZE]; | ||
89 | UINT BlockLen; | ||
90 | } SHA256_CTX_STRUC, *PSHA256_CTX_STRUC; | ||
91 | |||
92 | VOID SHA256_Init ( | ||
93 | IN SHA256_CTX_STRUC *pSHA_CTX); | ||
94 | VOID SHA256_Hash ( | ||
95 | IN SHA256_CTX_STRUC *pSHA_CTX); | ||
96 | VOID SHA256_Append ( | ||
97 | IN SHA256_CTX_STRUC *pSHA_CTX, | ||
98 | IN const UINT8 Message[], | ||
99 | IN UINT MessageLen); | ||
100 | VOID SHA256_End ( | ||
101 | IN SHA256_CTX_STRUC *pSHA_CTX, | ||
102 | OUT UINT8 DigestMessage[]); | ||
103 | VOID RT_SHA256 ( | ||
104 | IN const UINT8 Message[], | ||
105 | IN UINT MessageLen, | ||
106 | OUT UINT8 DigestMessage[]); | ||
107 | #endif /* SHA256_SUPPORT */ | ||
108 | |||
109 | #endif /* __CRYPT_SHA2_H__ */ | 81 | #endif /* __CRYPT_SHA2_H__ */ |