Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

token.h File Reference


Detailed Description

Token management.

Author:
Raphael Manfredi
Date:
2003

#include <glib.h>
#include "lib/host_addr.h"

Go to the source code of this file.

Defines

#define TOKEN_VERSION_SIZE   (4 + 3 + 20) /**< stamp + seed + SHA1 */
 stamp + seed + SHA1

#define TOKEN_START_DATE   1045868400 /**< When we started using tokens */
 When we started using tokens.


Enumerations

enum  tok_error_t {
  TOK_OK = 0, TOK_BAD_LENGTH, TOK_BAD_STAMP, TOK_BAD_INDEX,
  TOK_INVALID, TOK_BAD_ENCODING, TOK_BAD_KEYS, TOK_BAD_VERSION,
  TOK_OLD_VERSION, TOK_BAD_LEVEL_ENCODING, TOK_BAD_LEVEL_LENGTH, TOK_SHORT_LEVEL,
  TOK_INVALID_LEVEL, TOK_MISSING_LEVEL
}
 Error codes for token validation. More...


Functions

const gchar * tok_strerror (tok_error_t errnum)
gchar * tok_version (void)
 Get a version token, base64-encoded.

gchar * tok_short_version (void)
 Get a version token for the short version string, base64-encoded.

tok_error_t tok_version_valid (const gchar *version, const gchar *tokenb64, gint len, host_addr_t addr)
 Validate a base64-encoded version token `tokenb64' of `len' bytes.

gboolean tok_is_ancient (time_t now)
 Check whether the version is too ancient to be able to generate a proper token string identifiable by remote parties.


Define Documentation

#define TOKEN_START_DATE   1045868400 /**< When we started using tokens */
 

When we started using tokens.

#define TOKEN_VERSION_SIZE   (4 + 3 + 20) /**< stamp + seed + SHA1 */
 

stamp + seed + SHA1


Enumeration Type Documentation

enum tok_error_t
 

Error codes for token validation.

Enumeration values:
TOK_OK  OK.
TOK_BAD_LENGTH  Bad length.
TOK_BAD_STAMP  Bad timestamp.
TOK_BAD_INDEX  Bad key index.
TOK_INVALID  Invalid.
TOK_BAD_ENCODING  Not base64-encoded.
TOK_BAD_KEYS  Keys not found.
TOK_BAD_VERSION  Bad version string.
TOK_OLD_VERSION  Version older than expected.
TOK_BAD_LEVEL_ENCODING  Level not base64-encoded.
TOK_BAD_LEVEL_LENGTH  Bad level length.
TOK_SHORT_LEVEL  Level too short.
TOK_INVALID_LEVEL  Level mismatch.
TOK_MISSING_LEVEL  Missing level.


Function Documentation

gboolean tok_is_ancient time_t  now  ) 
 

Check whether the version is too ancient to be able to generate a proper token string identifiable by remote parties.

gchar* tok_short_version void   ) 
 

Get a version token for the short version string, base64-encoded.

Returns:
a pointer to static data.

const gchar* tok_strerror tok_error_t  errnum  ) 
 

Returns:
human-readable error string corresponding to error code `errnum'.

gchar* tok_version void   ) 
 

Get a version token, base64-encoded.

Returns:
a pointer to static data.
Note:
Token versions are only used to identify GTKG servents as such with a higher level of confidence than just reading the version string alone. It is not meant to be used for strict authentication management, since the algorithm and the keys are exposed publicly.

tok_error_t tok_version_valid const gchar *  version,
const gchar *  tokenb64,
gint  len,
host_addr_t  addr
 

Validate a base64-encoded version token `tokenb64' of `len' bytes.

The `ip' is given only for clock update operations.

Returns:
error code, or TOK_OK if token is valid.


Generated on Sun Feb 12 10:50:08 2006 for Gtk-Gnutella by doxygen 1.3.6