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.

126 lines
3.1 KiB

  1. /*-----------------------------------------------------------------------------
  2. * Copyright (C) Microsoft Corporation, 1995 - 1996.
  3. * All rights reserved.
  4. *
  5. * Owner : ramas
  6. * Date : 4/16/96
  7. * description : Main Crypto functions for SSL3
  8. *----------------------------------------------------------------------------*/
  9. #include <spbase.h>
  10. #include <ssl3key.h>
  11. #include <ssl2msg.h>
  12. #include <ssl3msg.h>
  13. #include <ssl2prot.h>
  14. //+---------------------------------------------------------------------------
  15. //
  16. // Function: Ssl3MakeWriteSessionKeys
  17. //
  18. // Synopsis:
  19. //
  20. // Arguments: [pContext] -- Schannel context.
  21. //
  22. // History: 10-08-97 jbanes Added server-side CAPI integration.
  23. //
  24. // Notes:
  25. //
  26. //----------------------------------------------------------------------------
  27. SP_STATUS
  28. Ssl3MakeWriteSessionKeys(PSPContext pContext)
  29. {
  30. BOOL fClient;
  31. // Determine if we're a client or a server.
  32. fClient = (0 != (pContext->RipeZombie->fProtocol & SP_PROT_SSL3_CLIENT));
  33. //
  34. // Derive write key.
  35. //
  36. if(pContext->hWriteKey)
  37. {
  38. if(!CryptDestroyKey(pContext->hWriteKey))
  39. {
  40. SP_LOG_RESULT(GetLastError());
  41. }
  42. }
  43. pContext->hWriteProv = pContext->RipeZombie->hMasterProv;
  44. pContext->hWriteKey = pContext->hPendingWriteKey;
  45. pContext->hPendingWriteKey = 0;
  46. //
  47. // Derive the write MAC key.
  48. //
  49. if(pContext->hWriteMAC)
  50. {
  51. if(!CryptDestroyKey(pContext->hWriteMAC))
  52. {
  53. SP_LOG_RESULT(GetLastError());
  54. }
  55. }
  56. pContext->hWriteMAC = pContext->hPendingWriteMAC;
  57. pContext->hPendingWriteMAC = 0;
  58. DebugLog((DEB_TRACE, "Write Keys are Computed\n"));
  59. return PCT_ERR_OK;
  60. }
  61. //+---------------------------------------------------------------------------
  62. //
  63. // Function: Ssl3MakeReadSessionKeys
  64. //
  65. // Synopsis:
  66. //
  67. // Arguments: [pContext] -- Schannel context.
  68. //
  69. // History: 10-03-97 jbanes Added server-side CAPI integration.
  70. //
  71. // Notes:
  72. //
  73. //----------------------------------------------------------------------------
  74. SP_STATUS
  75. Ssl3MakeReadSessionKeys(PSPContext pContext)
  76. {
  77. BOOL fClient;
  78. // Determine if we're a client or a server.
  79. fClient = (pContext->RipeZombie->fProtocol & SP_PROT_SSL3_CLIENT);
  80. //
  81. // Derive the read key.
  82. //
  83. if(pContext->hReadKey)
  84. {
  85. if(!CryptDestroyKey(pContext->hReadKey))
  86. {
  87. SP_LOG_RESULT(GetLastError());
  88. }
  89. }
  90. pContext->hReadProv = pContext->RipeZombie->hMasterProv;
  91. pContext->hReadKey = pContext->hPendingReadKey;
  92. pContext->hPendingReadKey = 0;
  93. //
  94. // Derive the read MAC key.
  95. //
  96. if(pContext->hReadMAC)
  97. {
  98. if(!CryptDestroyKey(pContext->hReadMAC))
  99. {
  100. SP_LOG_RESULT(GetLastError());
  101. }
  102. }
  103. pContext->hReadMAC = pContext->hPendingReadMAC;
  104. pContext->hPendingReadMAC = 0;
  105. DebugLog((DEB_TRACE, "Read Keys are Computed\n"));
  106. return PCT_ERR_OK;
  107. }