Main Page   Compound List   File List   Compound Members   File Members   Related Pages  

crypto.h File Reference

Low-level encryption layer. More...

#include "gale/misc.h"

Functions

struct gale_data gale_crypto_hash (struct gale_data)
 Compute a cryptographically secure hash of some data. More...

struct gale_data gale_crypto_random (int len)
 Generate cryptographically random data. More...

struct gale_group gale_crypto_generate (struct gale_text id)
 Generate a new key. More...

struct gale_group gale_crypto_public (struct gale_group)
 Extract the public components of a key. More...

int gale_crypto_seal (int num, const struct gale_group *keys, struct gale_group *data)
 Encrypt some data. More...

const struct gale_textgale_crypto_target (struct gale_group encrypted)
 List the keys that can decrypt an encrypted group. More...

int gale_crypto_open (struct gale_group key,struct gale_group *data)
 Decrypt some data. More...

int gale_crypto_sign (int num, const struct gale_group *keys, struct gale_group *data)
 Digitally sign some data. More...

const struct gale_textgale_crypto_sender (struct gale_group signed_group)
 List the keys that may have signed a group. More...

const struct gale_datagale_crypto_bundled (struct gale_group signed_group)
 Extract keys which have been bundled with a signed group. More...

struct gale_group gale_crypto_original (struct gale_group signed_group)
 Extract the original content from a signed group. More...

int gale_crypto_verify (int num, const struct gale_group *keys, struct gale_group signed_group)
 Verify that a group has been signed. More...

const struct gale_datagale_crypto_sign_raw (int num, const struct gale_group *keys, struct gale_data data)
 Low-level signature operation. More...

int gale_crypto_verify_raw (int num, const struct gale_group *keys, const struct gale_data *sigs, struct gale_data data)
 Low-level signature verification. More...


Detailed Description

Low-level encryption layer.


Function Documentation

const struct gale_data * gale_crypto_bundled ( struct gale_group signed_group )
 

Extract keys which have been bundled with a signed group.

Parameters:
signed_group   The signed group.
Returns:
An array of cached keys, terminated by null_data. It is up to the caller to process and validate these keys.
See also:
gale_crypto_sign(), gale_crypto_verify()

struct gale_group gale_crypto_generate ( struct gale_text id )
 

Generate a new key.

Parameters:
id   The name to embed in the key.
Returns:
The newly generated key, containing public and private data.
See also:
gale_crypto_public()

struct gale_data gale_crypto_hash ( struct gale_data )
 

Compute a cryptographically secure hash of some data.

Parameters:
len   A block of data to hash.
Returns:
A block of data containing a secure hash of the data.

int gale_crypto_open ( struct gale_group key,
struct gale_group * cipher )
 

Decrypt some data.

Parameters:
key   Key to use for decryption. Use gale_crypto_target() to find the keys you can use, pick one you own, and supply private key data.
data   Encrypted group. Will be replaced by decrypted group.
Returns:
Nonzero iff the operation succeeded.
See also:
gale_crypto_seal(), gale_crypto_target()

struct gale_group gale_crypto_original ( struct gale_group signed_group )
 

Extract the original content from a signed group.

Parameters:
signed_group   The signed group.
Returns:
The data contained within the signed group. If the group was not signed, the original group is returned.
See also:
gale_crypto_sign(), gale_crypto_verify()
Warning:
Successful extraction of data does not indicate authenticity. You must use gale_crypto_verify() to check the signature.

struct gale_group gale_crypto_public ( struct gale_group )
 

Extract the public components of a key.

Parameters:
key   A key which may contain private data.
Returns:
The same key with all private data expunged.
See also:
gale_crypto_generate()

struct gale_data gale_crypto_random ( int len )
 

Generate cryptographically random data.

Parameters:
len   The amount of data to generate.
Returns:
A block of high-entropy random data of length len.

int gale_crypto_seal ( int key_count,
const struct gale_group * target,
struct gale_group * data )
 

Encrypt some data.

Parameters:
key_count   Number of keys in the target array.
target   Array of keys. Anyone who owns any of these keys will be able to decrypt the data. These keys must include public key data.
data   Group to encrypt. Will be replaced by an encrypted group.
Returns:
Nonzero iff the operation succeeded.
See also:
gale_crypto_target(), gale_crypto_open()

const struct gale_text * gale_crypto_sender ( struct gale_group signed_group )
 

List the keys that may have signed a group.

Parameters:
signed_group   The signed group.
Returns:
An array of key names, terminated by null_text.
See also:
gale_crypto_sign(), gale_crypto_verify()
Warning:
This list of keys is not authoritative; the signatures have not yet been validated. Use gale_crypto_verify() for that.

int gale_crypto_sign ( int key_count,
const struct gale_group * keys,
struct gale_group * data )
 

Digitally sign some data.

Parameters:
key_count   Number of keys in the target array.
target   Array of keys. The keys must include private key data. Keys which contain key.source data fragments will be stored along with the signature.
data   Group to sign. Will be replaced by a signed group.
Returns:
Nonzero iff the operation succeeded.
See also:
gale_crypto_sender(), gale_crypto_verify(), gale_crypto_sign_raw()

const struct gale_data * gale_crypto_sign_raw ( int key_count,
const struct gale_group * source,
struct gale_data data )
 

Low-level signature operation.

Parameters:
key_count   Number of keys in the source array.
source   Array of keys. The keys must include private key data.
data   Data to sign.
Returns:
Array of signatures, one for each key, or NULL if the operation failed.
See also:
gale_crypto_verify_raw(), gale_crypto_sign()

const struct gale_text * gale_crypto_target ( struct gale_group encrypted )
 

List the keys that can decrypt an encrypted group.

Parameters:
encrypted   Encrypted group to examine.
Returns:
NULL iff the group is not encrypted. Otherwise, an array of key names, terminated by null_text.
See also:
gale_crypto_seal(), gale_crypto_open()

int gale_crypto_verify ( int key_count,
const struct gale_group * keys,
struct gale_group signed_group )
 

Verify that a group has been signed.

Parameters:
key_count   Number of keys in the keys array.
keys   Array of keys to test. The keys must include public key data.
signed_group   The signed group.
See also:
gale_crypto_sign(), gale_crypto_sender(), gale_crypto_bundled(), gale_crypto_verify_raw()
Returns:
Nonzero iff the operation succeeded and the data was in fact signed by all the keys in the list.

int gale_crypto_verify_raw ( int key_count,
const struct gale_group * keys,
const struct gale_data * sigs,
struct gale_data data )
 

Low-level signature verification.

Parameters:
key_count   Number of keys in the keys array and number fo signatures in the sigs array.
keys   Array of keys. The keys must include public key data.
sigs   Array of signatures, as returned from gale_crypto_sign_raw().
data   Data to verify against signatures.
Returns:
Nonzero iff the all signatures are valid.


Generated at Sun Sep 7 13:55:26 2003 for Gale by doxygen1.2.1 written by Dimitri van Heesch, © 1997-2000