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.

112 lines
2.3 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. crclient.c
  5. Abstract:
  6. Local Security Authority - Client Cipher Routines
  7. These routines interface the LSA client side with the Cipher
  8. Routines. They perform RPC-style memory allocation.
  9. Author:
  10. Scott Birrell (ScottBi) December 13, 1991
  11. Environment:
  12. Revision History:
  13. --*/
  14. #include <lsaclip.h>
  15. NTSTATUS
  16. LsapCrClientGetSessionKey(
  17. IN LSA_HANDLE ObjectHandle,
  18. OUT PLSAP_CR_CIPHER_KEY *SessionKey
  19. )
  20. /*++
  21. Routine Description:
  22. This function obtains the Session Key, allocates an Cipher Key
  23. structure and returns the key.
  24. Arguments:
  25. ObjectHandle - Handle from an LsaOpen<ObjectType> call.
  26. SessionKey - Receives a pointer to a structure containing the
  27. Session Key in which the memory has been allocated via
  28. MIDL_user_allocate().
  29. Return Value:
  30. NTSTATUS - Standard Nt Result Code
  31. STATUS_INSUFFICIENT_RESOURCES - Insufficient system resources
  32. (e.g memory) to complete the call.
  33. --*/
  34. {
  35. NTSTATUS Status = STATUS_SUCCESS;
  36. PLSAP_CR_CIPHER_KEY OutputSessionKey = NULL;
  37. ULONG OutputSessionKeyBufferLength;
  38. //
  39. // Allocate memory for the Session Key buffer and LSAP_CR_CIPHER_KEY
  40. // structure.
  41. //
  42. OutputSessionKeyBufferLength = sizeof (USER_SESSION_KEY);
  43. Status = STATUS_INSUFFICIENT_RESOURCES;
  44. OutputSessionKey = MIDL_user_allocate(
  45. OutputSessionKeyBufferLength +
  46. sizeof (LSAP_CR_CIPHER_KEY)
  47. );
  48. if (OutputSessionKey == NULL) {
  49. goto ClientGetSessionKeyError;
  50. }
  51. //
  52. // Fill in the Cipher key structure, making the buffer point to
  53. // just beyond the header.
  54. //
  55. OutputSessionKey->Length = OutputSessionKeyBufferLength;
  56. OutputSessionKey->MaximumLength = OutputSessionKeyBufferLength;
  57. OutputSessionKey->Buffer = (PUCHAR) (OutputSessionKey + 1);
  58. Status = RtlGetUserSessionKeyClient(
  59. ObjectHandle,
  60. (PUSER_SESSION_KEY) OutputSessionKey->Buffer
  61. );
  62. if (!NT_SUCCESS(Status)) {
  63. goto ClientGetSessionKeyError;
  64. }
  65. ClientGetSessionKeyFinish:
  66. *SessionKey = OutputSessionKey;
  67. return(Status);
  68. ClientGetSessionKeyError:
  69. goto ClientGetSessionKeyFinish;
  70. }