Source code of Windows XP (NT5)
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.

130 lines
3.3 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(!SchCryptDestroyKey(pContext->hWriteKey,
  39. pContext->RipeZombie->dwCapiFlags))
  40. {
  41. SP_LOG_RESULT(GetLastError());
  42. }
  43. }
  44. pContext->hWriteProv = pContext->RipeZombie->hMasterProv;
  45. pContext->hWriteKey = pContext->hPendingWriteKey;
  46. pContext->hPendingWriteKey = 0;
  47. //
  48. // Derive the write MAC key.
  49. //
  50. if(pContext->hWriteMAC)
  51. {
  52. if(!SchCryptDestroyKey(pContext->hWriteMAC,
  53. pContext->RipeZombie->dwCapiFlags))
  54. {
  55. SP_LOG_RESULT(GetLastError());
  56. }
  57. }
  58. pContext->hWriteMAC = pContext->hPendingWriteMAC;
  59. pContext->hPendingWriteMAC = 0;
  60. DebugLog((DEB_TRACE, "Write Keys are Computed\n"));
  61. return PCT_ERR_OK;
  62. }
  63. //+---------------------------------------------------------------------------
  64. //
  65. // Function: Ssl3MakeReadSessionKeys
  66. //
  67. // Synopsis:
  68. //
  69. // Arguments: [pContext] -- Schannel context.
  70. //
  71. // History: 10-03-97 jbanes Added server-side CAPI integration.
  72. //
  73. // Notes:
  74. //
  75. //----------------------------------------------------------------------------
  76. SP_STATUS
  77. Ssl3MakeReadSessionKeys(PSPContext pContext)
  78. {
  79. BOOL fClient;
  80. // Determine if we're a client or a server.
  81. fClient = (pContext->RipeZombie->fProtocol & SP_PROT_SSL3_CLIENT);
  82. //
  83. // Derive the read key.
  84. //
  85. if(pContext->hReadKey)
  86. {
  87. if(!SchCryptDestroyKey(pContext->hReadKey,
  88. pContext->RipeZombie->dwCapiFlags))
  89. {
  90. SP_LOG_RESULT(GetLastError());
  91. }
  92. }
  93. pContext->hReadProv = pContext->RipeZombie->hMasterProv;
  94. pContext->hReadKey = pContext->hPendingReadKey;
  95. pContext->hPendingReadKey = 0;
  96. //
  97. // Derive the read MAC key.
  98. //
  99. if(pContext->hReadMAC)
  100. {
  101. if(!SchCryptDestroyKey(pContext->hReadMAC,
  102. pContext->RipeZombie->dwCapiFlags))
  103. {
  104. SP_LOG_RESULT(GetLastError());
  105. }
  106. }
  107. pContext->hReadMAC = pContext->hPendingReadMAC;
  108. pContext->hPendingReadMAC = 0;
  109. DebugLog((DEB_TRACE, "Read Keys are Computed\n"));
  110. return PCT_ERR_OK;
  111. }