aKEY Registration Key System
Key Checking
Copyright © 2000-2002 by Jørgen Ibsen, All Rights Reserved.
1 Introduction
The following is a description of the aKEY key-checking
functionality.
2 Key-checking Functions
int aKEY_decode_key( char *encoded_key,
char *key,
int length ); |
Decodes the key material from encoded_key[] into
key[] , reading and writing at most length
bytes.
The function locates the armor start marker ('===='), and
then attempts to decode using the MIME base64 content-transfer-encoding
(RFC-2045,
section 6.8).
- Parameters:
-
encoded_key - pointer to the encoded key.
key - pointer to where the decoded key should be stored.
length - the length of the encoded key.
- Returns:
-
the length of the decoded key material, or zero on error.
|
|
int aKEY_check_key( char *key,
int length ); |
Checks the signature of the decoded key in key[] , reading
at most length bytes.
- Parameters:
-
key - pointer to the decoded key.
length - the length of the decoded key.
- Returns:
-
non-zero if the key is valid.
|
|
char *aKEY_get_user_data( char *key ); |
Finds the user data block within the decoded key in key[] ,
and returns a pointer to it.
- Parameters:
-
key - pointer to the decoded key.
- Returns:
-
pointer to the user data within
key[] , or NULL if not found.
|
|
void *aKEY_get_first_block( char *key ); |
Returns a pointer to the first block within the decoded key in
key[] .
- Parameters:
-
key - pointer to the decoded key.
- Returns:
-
pointer to the first block within
key[] , or NULL on error.
|
|
void *aKEY_get_next_block( void *current_block ); |
Returns a pointer to the next block after the one pointed to
by current_block , or NULL if the end block
was reached.
- Parameters:
-
current_block - pointer to the current block.
- Returns:
-
pointer to the next block after
current_block , or NULL on reaching the end block.
|
|
3 Example
char *udata = NULL;
// decode key from encoded_key[] to key[]
int dsize = aKEY_decode_key(encoded_key, key, encoded_key_size);
if (dsize)
{
// check if key is valid
int res = aKEY_check_key(key, dsize);
if (res)
{
// get a pointer to the user data
udata = aKEY_get_user_data(key);
}
}
// here, key was valid if udata != NULL
if (udata != NULL)
{
printf("- registered to: %s\n", udata);
} else {
printf("- not registered\n");
}
Copyright © 2000-2002 by Jørgen Ibsen. All Rights Reserved.
Products and company names mentioned may be the trademarks of their respective owners.