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.

131 lines
2.7 KiB

  1. /*++
  2. Copyright (c) 1989-1997 Microsoft Corporation
  3. Module Name:
  4. block.c
  5. Abstract:
  6. Block encryption functions implementation :
  7. RtlEncryptBlock
  8. RtlEncrypStdBlock
  9. Author:
  10. David Chalmers (Davidc) 10-21-91
  11. Revision History:
  12. Scott Field (sfield) 03-Nov-97
  13. Removed critical section around crypto calls.
  14. Adam Barr (adamba) 15-Dec-97
  15. Modified from private\security\lsa\crypt\dll
  16. --*/
  17. #include <rdrssp.h>
  18. NTSTATUS
  19. RtlEncryptBlock(
  20. IN PCLEAR_BLOCK ClearBlock,
  21. IN PBLOCK_KEY BlockKey,
  22. OUT PCYPHER_BLOCK CypherBlock
  23. )
  24. /*++
  25. Routine Description:
  26. Takes a block of data and encrypts it with a key producing
  27. an encrypted block of data.
  28. Arguments:
  29. ClearBlock - The block of data that is to be encrypted.
  30. BlockKey - The key to use to encrypt data
  31. CypherBlock - Encrypted data is returned here
  32. Return Values:
  33. STATUS_SUCCESS - The data was encrypted successfully. The encrypted
  34. data block is in CypherBlock
  35. STATUS_UNSUCCESSFUL - Something failed. The CypherBlock is undefined.
  36. --*/
  37. {
  38. unsigned Result;
  39. Result = DES_ECB_LM(ENCR_KEY,
  40. (const char *)BlockKey,
  41. (unsigned char *)ClearBlock,
  42. (unsigned char *)CypherBlock
  43. );
  44. if (Result == CRYPT_OK) {
  45. return(STATUS_SUCCESS);
  46. } else {
  47. KdPrint(("RDRSSP: RtlEncryptBlock failed %x\n\r", Result));
  48. return(STATUS_UNSUCCESSFUL);
  49. }
  50. }
  51. NTSTATUS
  52. RtlEncryptStdBlock(
  53. IN PBLOCK_KEY BlockKey,
  54. OUT PCYPHER_BLOCK CypherBlock
  55. )
  56. /*++
  57. Routine Description:
  58. Takes a block key encrypts the standard text block with it.
  59. The resulting encrypted block is returned.
  60. This is a One-Way-Function - the key cannot be recovered from the
  61. encrypted data block.
  62. Arguments:
  63. BlockKey - The key to use to encrypt the standard text block.
  64. CypherBlock - The encrypted data is returned here
  65. Return Values:
  66. STATUS_SUCCESS - The encryption was successful.
  67. The result is in CypherBlock
  68. STATUS_UNSUCCESSFUL - Something failed. The CypherBlock is undefined.
  69. --*/
  70. {
  71. unsigned Result;
  72. char StdEncrPwd[] = "KGS!@#$%";
  73. Result = DES_ECB_LM(ENCR_KEY,
  74. (const char *)BlockKey,
  75. (unsigned char *)StdEncrPwd,
  76. (unsigned char *)CypherBlock
  77. );
  78. if (Result == CRYPT_OK) {
  79. return(STATUS_SUCCESS);
  80. } else {
  81. #if DBG
  82. DbgPrint("EncryptStd failed\n\r");
  83. #endif
  84. return(STATUS_UNSUCCESSFUL);
  85. }
  86. }