Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
3.9 KiB

  1. // -*- mode: C++; tab-width: 4; indent-tabs-mode: nil -*- (for GNU Emacs)
  2. //
  3. // Copyright (c) 1985-2000 Microsoft Corporation
  4. //
  5. // This file is part of the Microsoft Research IPv6 Network Protocol Stack.
  6. // You should have received a copy of the Microsoft End-User License Agreement
  7. // for this software along with this release; see the file "license.txt".
  8. // If not, please see http://www.research.microsoft.com/msripv6/license.htm,
  9. // or write to Microsoft Research, One Microsoft Way, Redmond, WA 98052-6399.
  10. //
  11. // Abstract:
  12. //
  13. // Security Algorithms for Internet Protocol Version 6.
  14. //
  15. #include "oscfg.h"
  16. #include "ndis.h"
  17. #include "ip6imp.h"
  18. #include "ip6def.h"
  19. #include "ipsec.h"
  20. #include "security.h"
  21. #include "null.h"
  22. #include "hmacmd5.h"
  23. #include "hmacsha1.h"
  24. C_ASSERT(NULL_CONTEXT_SIZE <= MAX_CONTEXT_SIZE);
  25. C_ASSERT(sizeof(MD5_CTX) <= MAX_CONTEXT_SIZE);
  26. C_ASSERT(sizeof(A_SHA_CTX) <= MAX_CONTEXT_SIZE);
  27. C_ASSERT(NULL_RESULT_SIZE <= MAX_RESULT_SIZE);
  28. C_ASSERT(HMACMD5_RESULT_SIZE <= MAX_RESULT_SIZE);
  29. C_ASSERT(HMACMD596_RESULT_SIZE <= MAX_RESULT_SIZE);
  30. C_ASSERT(HMACSHA1_RESULT_SIZE <= MAX_RESULT_SIZE);
  31. C_ASSERT(HMACSHA196_RESULT_SIZE <= MAX_RESULT_SIZE);
  32. //* AlgorithmsInit - Initialize the algorithm table.
  33. //
  34. void
  35. AlgorithmsInit()
  36. {
  37. //
  38. // Null algorithm (for testing).
  39. //
  40. AlgorithmTable[ALGORITHM_NULL].KeySize = NULL_KEY_SIZE;
  41. AlgorithmTable[ALGORITHM_NULL].ContextSize = NULL_CONTEXT_SIZE;
  42. AlgorithmTable[ALGORITHM_NULL].ResultSize = NULL_RESULT_SIZE;
  43. AlgorithmTable[ALGORITHM_NULL].PrepareKey = NullKeyPrep;
  44. AlgorithmTable[ALGORITHM_NULL].Initialize = NullInit;
  45. AlgorithmTable[ALGORITHM_NULL].Operate = NullOp;
  46. AlgorithmTable[ALGORITHM_NULL].Finalize = NullFinal;
  47. //
  48. // Message Digest Version 5.
  49. //
  50. AlgorithmTable[ALGORITHM_HMAC_MD5].KeySize = HMACMD5_KEY_SIZE;
  51. AlgorithmTable[ALGORITHM_HMAC_MD5].ContextSize = sizeof(MD5_CTX);
  52. AlgorithmTable[ALGORITHM_HMAC_MD5].ResultSize = HMACMD5_RESULT_SIZE;
  53. AlgorithmTable[ALGORITHM_HMAC_MD5].PrepareKey = HMAC_MD5KeyPrep;
  54. AlgorithmTable[ALGORITHM_HMAC_MD5].Initialize = HMAC_MD5Init;
  55. AlgorithmTable[ALGORITHM_HMAC_MD5].Operate = HMAC_MD5Op;
  56. AlgorithmTable[ALGORITHM_HMAC_MD5].Finalize = HMAC_MD5Final;
  57. //
  58. // HMAC-MD5-96.
  59. //
  60. AlgorithmTable[ALGORITHM_HMAC_MD5_96].KeySize = HMACMD5_KEY_SIZE;
  61. AlgorithmTable[ALGORITHM_HMAC_MD5_96].ContextSize = sizeof(MD5_CTX);
  62. AlgorithmTable[ALGORITHM_HMAC_MD5_96].ResultSize = HMACMD596_RESULT_SIZE;
  63. AlgorithmTable[ALGORITHM_HMAC_MD5_96].PrepareKey = HMAC_MD5KeyPrep;
  64. AlgorithmTable[ALGORITHM_HMAC_MD5_96].Initialize = HMAC_MD5Init;
  65. AlgorithmTable[ALGORITHM_HMAC_MD5_96].Operate = HMAC_MD5Op;
  66. AlgorithmTable[ALGORITHM_HMAC_MD5_96].Finalize = HMAC_MD5_96Final;
  67. //
  68. // Secure Hash Algorithm.
  69. //
  70. AlgorithmTable[ALGORITHM_HMAC_SHA1].KeySize = HMACSHA1_KEY_SIZE;
  71. AlgorithmTable[ALGORITHM_HMAC_SHA1].ContextSize = sizeof(A_SHA_CTX);
  72. AlgorithmTable[ALGORITHM_HMAC_SHA1].ResultSize = HMACSHA1_RESULT_SIZE;
  73. AlgorithmTable[ALGORITHM_HMAC_SHA1].PrepareKey = HMAC_SHA1KeyPrep;
  74. AlgorithmTable[ALGORITHM_HMAC_SHA1].Initialize = HMAC_SHA1Init;
  75. AlgorithmTable[ALGORITHM_HMAC_SHA1].Operate = HMAC_SHA1Op;
  76. AlgorithmTable[ALGORITHM_HMAC_SHA1].Finalize = HMAC_SHA1Final;
  77. //
  78. // HMAC-SHA1-96.
  79. //
  80. AlgorithmTable[ALGORITHM_HMAC_SHA1_96].KeySize = HMACSHA1_KEY_SIZE;
  81. AlgorithmTable[ALGORITHM_HMAC_SHA1_96].ContextSize = sizeof(A_SHA_CTX);
  82. AlgorithmTable[ALGORITHM_HMAC_SHA1_96].ResultSize = HMACSHA196_RESULT_SIZE;
  83. AlgorithmTable[ALGORITHM_HMAC_SHA1_96].PrepareKey = HMAC_SHA1KeyPrep;
  84. AlgorithmTable[ALGORITHM_HMAC_SHA1_96].Initialize = HMAC_SHA1Init;
  85. AlgorithmTable[ALGORITHM_HMAC_SHA1_96].Operate = HMAC_SHA1Op;
  86. AlgorithmTable[ALGORITHM_HMAC_SHA1_96].Finalize = HMAC_SHA1_96Final;
  87. }