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.

81 lines
2.6 KiB

  1. //+-----------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (c) Microsoft Corporation 2000
  6. //
  7. // File: nonce.h
  8. //
  9. // Contents: Constants for the Nonce Generator/Validator
  10. //
  11. // History:
  12. // KDamour 21Mar00 Created
  13. //
  14. //------------------------------------------------------------------------
  15. #ifndef NTDIGEST_NONCE_H
  16. #define NTDIGEST_NONCE_H
  17. // NONCE FORMAT
  18. // rand-data = rand[16]
  19. // nonce_binary = time-stamp rand-data H(time-stamp ":" rand-data ":" nonce_private_key)
  20. // nonce = hex(nonce_binary)
  21. // SIZE implies number of ASCII chars
  22. // BYTESIZE is the number of bytes of Data (binary)
  23. #define NONCE_PRIVATE_KEY_BYTESIZE 16 // Generate 128 bit random private key
  24. #define RANDDATA_BYTESIZE 16 // # of random bytes at beginning of nonce
  25. #define TIMESTAMP_BYTESIZE sizeof(FILETIME) // size of timestamp in nonce binary 8 bytes
  26. #define PRECALC_HASH_BASEFORMS 3 // Number of forms for each username:realm:password combo
  27. #define PRECALC_HASH_ALLFORMS 7 // Number of forms with non-zero length Realm
  28. // For Hex encoding need 2chars per byte encoded
  29. #define NONCE_SIZE ((2*TIMESTAMP_BYTESIZE) + (2*RANDDATA_BYTESIZE) + (2*MD5_HASH_BYTESIZE))
  30. #define NONCE_TIME_LOC 0
  31. #define NONCE_RANDDATA_LOC (2 * TIMESTAMP_BYTESIZE)
  32. #define NONCE_HASH_LOC (NONCE_RANDDATA_LOC + (2 * RANDDATA_BYTESIZE))
  33. #define OPAQUE_RANDATA_SIZE 16 // Make 128bits of rand data for reference
  34. #define OPAQUE_SIZE (OPAQUE_RANDATA_SIZE * 2)
  35. #define MAX_URL_SIZE 512
  36. #ifndef SECURITY_KERNEL
  37. #include <wincrypt.h>
  38. // Handle into the CryptoAPI
  39. extern HCRYPTPROV g_hCryptProv;
  40. extern WORD g_SupportedCrypto;
  41. NTSTATUS NTAPI NonceInitialize(VOID);
  42. NTSTATUS NTAPI NonceCreate(OUT PSTRING pstrNonce);
  43. // Primary function to call to check validity of a nonce
  44. NTSTATUS NonceIsValid(PSTRING pstrNonce);
  45. // Helper function for NonceIsValid to check if Hash is correct
  46. BOOL NonceIsTampered(PSTRING pstrNonce);
  47. BOOL HashData(BYTE *pbData, DWORD cbData, BYTE *pbHash );
  48. // Create the Hash for the Nonce Parameters
  49. NTSTATUS NTAPI NonceHash( IN LPBYTE pbTime, IN DWORD cbTime,
  50. IN LPBYTE pbRandom, IN DWORD cbRandom,
  51. IN LPBYTE pbKey, IN DWORD cbKey,
  52. OUT LPBYTE pbHash);
  53. NTSTATUS NTAPI OpaqueCreate(IN OUT PSTRING pstrOpaque);
  54. // Set the bitmask for the supported crypto CSP installed
  55. NTSTATUS NTAPI SetSupportedCrypto(VOID);
  56. #endif // SECURITY_KERNEL
  57. #endif