aKEY Registration Key System
Key Generation
Copyright © 2000-2002 by Jørgen Ibsen, All Rights Reserved.
1 Introduction
The following is a description of the aKEY key-generation
functionality.
2 Key-generation Functions
void *aKEY_create_key( int size,
int seed ); |
Creates a new key object and returns a pointer (handle) to it.
- Parameters:
-
size - size of initially allocated data.
seed - seed value for PRNG in key-generator.
- Returns:
-
a pointer (handle) to a new key object, or
NULL on error.
|
|
int aKEY_add_block( void *key,
int type,
char *data,
int length ); |
Adds a type -block to key , containing
length bytes from data[] .
- Parameters:
-
key - pointer to the key object.
type - type of block to add.
data - data to add.
length - the length of the data.
- Returns:
-
non-zero value on success.
|
|
int aKEY_sign_key( void *key ); |
Signs the key data part of key , adding header and
key signature part to it.
- Parameters:
-
key - pointer to the key object.
- Returns:
-
non-zero value on success.
|
|
char *aKEY_encode_key( void *key ); |
Encodes key using the MIME base64
content-transfer-encoding
(RFC-2045,
section 6.8), returning a pointer to the encoded key.
- Parameters:
-
key - pointer to the key object.
- Returns:
-
a pointer to the encoded key (ASCIIZ string), or
NULL on error.
|
|
void aKEY_destroy_key( void *key ); |
Destroys the key object referenced by key , freeing
resources.
- Parameters:
-
key - pointer to the key object.
|
|
void aKEY_stir_randpool( char *data,
int length ); |
Stirs the buffer of random bytes maintained by the key generation
code using length bytes from data[] .
- Parameters:
-
data - pointer to data.
length - the length of the data.
|
|
3 Example
// create a new key
void *key = aKEY_create_key(time(NULL));
char regname[] = "Joergen Ibsen";
// add a user data block containing the registration name
aKEY_add_block(key, BLOCK_USER_DATA, regname, sizeof(regname));
// sign key
aKEY_sign_key(key);
// encode key
char *keyout = aKEY_encode_key(key);
// output key
printf("--- BEGIN REGISTRATION KEY ---\n");
printf("Registration key for MyProgram. Do not distribute or modify!\n\n");
printf("%s", keyout);
printf("--- END REGISTRATION KEY ---\n");
// destroy key (free resources)
aKEY_destroy_key(key);
Copyright © 2000-2002 by Jørgen Ibsen. All Rights Reserved.
Products and company names mentioned may be the trademarks of their respective owners.