PageRenderTime 23ms CodeModel.GetById 14ms app.highlight 6ms RepoModel.GetById 2ms app.codeStats 0ms

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