/bncsutil/src/bncsutil/decodekey.h

http://ghostcb.googlecode.com/ · C++ Header · 120 lines · 24 code · 17 blank · 79 comment · 0 complexity · e766998e477966929379d2fb70991662 MD5 · raw file

  1. /**
  2. * BNCSutil
  3. * Battle.Net Utility Library
  4. *
  5. * Copyright (C) 2004-2006 Eric Naeseth
  6. *
  7. * CD-Key Decoder C Wrappers
  8. * October 17, 2004
  9. *
  10. * This library is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU Lesser General Public
  12. * License as published by the Free Software Foundation; either
  13. * version 2.1 of the License, or (at your option) any later version.
  14. *
  15. * This library is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * Lesser General Public License for more details.
  19. *
  20. * A copy of the GNU Lesser General Public License is included in the BNCSutil
  21. * distribution in the file COPYING. If you did not receive this copy,
  22. * write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  23. * Boston, MA 02111-1307 USA
  24. */
  25. #ifndef DECODEKEY_H
  26. #define DECODEKEY_H
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. /**
  31. * Decodes a CD-key, retrieves its relevant values, and calculates a hash
  32. * suitable for SID_AUTH_CHECK (0x51) in one function call. Returns 1 on
  33. * success or 0 on failure. A call to kd_init does NOT need to be made before
  34. * calling this function. Available since BNCSutil 1.1.0.
  35. */
  36. MEXP(int) kd_quick(const char* cd_key, uint32_t client_token,
  37. uint32_t server_token, uint32_t* public_value,
  38. uint32_t* product, char* hash_buffer, size_t buffer_len);
  39. /**
  40. * Initializes the CD-key decoding C wrappers.
  41. * Returns 1 on success or 0 on failure.
  42. */
  43. MEXP(int) kd_init();
  44. /**
  45. * Creates a new CD-key decoder. Returns its ID on success
  46. * or -1 on failure or invalid CD-key.
  47. */
  48. MEXP(int) kd_create(const char* cdkey, int keyLength);
  49. /**
  50. * Frees the specified CD-key decoder.
  51. * Returns 1 on success or 0 on failure.
  52. */
  53. MEXP(int) kd_free(int decoder);
  54. /**
  55. * Gets the length of the private value for the given decoder.
  56. * Returns the length or 0 on failure.
  57. */
  58. MEXP(int) kd_val2Length(int decoder);
  59. /**
  60. * Gets the product value for the given decoder.
  61. * Returns the length or 0 on failure.
  62. */
  63. MEXP(int) kd_product(int decoder);
  64. /**
  65. * Gets the public value for the given decoder.
  66. * Returns the length or 0 on failure.
  67. */
  68. MEXP(int) kd_val1(int decoder);
  69. /**
  70. * Gets the rivate value for the given decoder.
  71. * Only use this function if kd_val2Length <= 4.
  72. * Returns the length or 0 on failure.
  73. */
  74. MEXP(int) kd_val2(int decoder);
  75. /**
  76. * Gets the length of the private value for the given decoder.
  77. * Only use this function if kd_val2Length > 4.
  78. * Returns the length or 0 on failure.
  79. */
  80. MEXP(int) kd_longVal2(int decoder, char* out);
  81. /**
  82. * Calculates the hash of the key values for SID_AUTH_CHECK (0x51).
  83. * Returns the hash length or 0 on failure.
  84. */
  85. MEXP(int) kd_calculateHash(int decoder, uint32_t clientToken,
  86. uint32_t serverToken);
  87. /**
  88. * Places the key hash in "out". The "out" buffer must be
  89. * at least the length returned from kd_calculateHash.
  90. * Returns the hash length or 0 on failure.
  91. */
  92. MEXP(int) kd_getHash(int decoder, char* out);
  93. /**
  94. * [!] kd_isValid has been deprecated. kd_create checks
  95. * whether the key was valid before returning, and
  96. * destroys the decoder and returns an error code
  97. * if it was invalid.
  98. */
  99. MEXP(int) kd_isValid(int decoder);
  100. #ifdef __cplusplus
  101. } // extern "C"
  102. #endif
  103. #endif // DECODEKEY_H