Main Page   Data Structures   File List   Data Fields   Globals  

pk.h File Reference

Public-key cryptography support. More...

#include <cyfer/cyfer.h>

Go to the source code of this file.

Data Structures

struct  CYFER_Pk_t
 A structure describing supported public-key algorithms. More...


Defines

#define CYFER_PK_NONE   0
#define CYFER_PK_RSA   1
#define CYFER_PK_ELGAMAL   2
#define CYFER_PK_LUC   3

Typedefs

typedef void CYFER_PK_CTX
 Public-key algorithm context.


Functions

CYFER_Pk_tCYFER_Pk_Get_Supported (void)
 Returns a list of supported public-key algorithms.

int CYFER_Pk_Select (const char *name, bool *enc, bool *sig)
 Selects public-key algorithm to use.

CYFER_PK_CTXCYFER_Pk_Init (int type)
 Creates and initializes algorithm context.

void CYFER_Pk_Generate_Key (CYFER_PK_CTX *ctx, size_t keylen)
 Generates new public/private key pair.

void CYFER_Pk_Size (CYFER_PK_CTX *ctx, size_t *pt_len, size_t *ct_len)
 Returns plaintext and ciphertext block sizes.

void CYFER_Pk_KeySize (CYFER_PK_CTX *ctx, size_t *privlen, size_t *publen)
 Returns private and public key lengths.

void CYFER_Pk_Export_Key (CYFER_PK_CTX *ctx, unsigned char *priv, unsigned char *pub)
 Exports private and/or public key.

bool CYFER_Pk_Import_Key (CYFER_PK_CTX *ctx, unsigned char *priv, size_t privlen, unsigned char *pub, size_t publen)
 Imports private and/or public key.

void CYFER_Pk_Encrypt (CYFER_PK_CTX *ctx, const unsigned char *input, unsigned char *output)
 Encrypts a block of data.

void CYFER_Pk_Decrypt (CYFER_PK_CTX *ctx, const unsigned char *input, unsigned char *output)
 Decrypts a block of data.

void CYFER_Pk_Sign (CYFER_PK_CTX *ctx, const unsigned char *input, unsigned char *output)
 Signs a block of data.

bool CYFER_Pk_Verify (CYFER_PK_CTX *ctx, const unsigned char *signature, const unsigned char *message)
 Verifies signature for a block of data.

void CYFER_Pk_Finish (CYFER_PK_CTX *ctx)
 Finalizes the algorithm, destroys and frees the context.


Detailed Description

Public-key cryptography support.


Define Documentation

#define CYFER_PK_ELGAMAL   2
 

#define CYFER_PK_LUC   3
 

#define CYFER_PK_NONE   0
 

#define CYFER_PK_RSA   1
 


Typedef Documentation

typedef void CYFER_PK_CTX
 

Public-key algorithm context.


Function Documentation

void CYFER_Pk_Decrypt CYFER_PK_CTX   ctx,
const unsigned char *    input,
unsigned char *    output
 

Decrypts a block of data.

Parameters:
ctx Algorithm context
input Input data block
output [output] Output data buffer

void CYFER_Pk_Encrypt CYFER_PK_CTX   ctx,
const unsigned char *    input,
unsigned char *    output
 

Encrypts a block of data.

Parameters:
ctx Algorithm context
input Input data block
output [output] Output data buffer

void CYFER_Pk_Export_Key CYFER_PK_CTX   ctx,
unsigned char *    priv,
unsigned char *    pub
 

Exports private and/or public key.

Parameters:
ctx Algorithm context
priv [output] Buffer for private key data
pub [output] Buffer for public key data
Note:
The keys themselves big integers stored in MPI (multi precision integer) format compatible with PKCS standards.

It is possible to export one key by providing NULL as the buffer for the other one.

void CYFER_Pk_Finish CYFER_PK_CTX   ctx
 

Finalizes the algorithm, destroys and frees the context.

Parameters:
ctx Algorithm context

void CYFER_Pk_Generate_Key CYFER_PK_CTX   ctx,
size_t    keylen
 

Generates new public/private key pair.

Parameters:
ctx Algorithm context
keylen Key length (in bits)

CYFER_Pk_t* CYFER_Pk_Get_Supported void   
 

Returns a list of supported public-key algorithms.

bool CYFER_Pk_Import_Key CYFER_PK_CTX   ctx,
unsigned char *    priv,
size_t    privlen,
unsigned char *    pub,
size_t    publen
 

Imports private and/or public key.

Parameters:
ctx Algorithm context
priv Private key data
privlen Private key length
pub Public key data
publen Public key length
Note:
It is possible to import one key by providing NULL as the data pointer for the other one.

The keys themselves big integers stored in MPI (multi precision integer) format compatible with PKCS standards.

Returns:
True if the keys are successfully imported, false on error

CYFER_PK_CTX* CYFER_Pk_Init int    type
 

Creates and initializes algorithm context.

Parameters:
type An integer representing algorithm to use
Returns:
An initialized hash context, or NULL in case of error

void CYFER_Pk_KeySize CYFER_PK_CTX   ctx,
size_t *    privlen,
size_t *    publen
 

Returns private and public key lengths.

Parameters:
ctx Algorithm context
privlen [output] Private key length
publen [output] Public key length

int CYFER_Pk_Select const char *    name,
bool *    enc,
bool *    sig
 

Selects public-key algorithm to use.

Parameters:
name Algorithm name
enc [output] True if algorithm can be used for encryption
sig [output] True if algorithm can be used for signatures
Returns:
An integer representing the selected algorithm

void CYFER_Pk_Sign CYFER_PK_CTX   ctx,
const unsigned char *    input,
unsigned char *    output
 

Signs a block of data.

Parameters:
ctx Algorithm context
input Input data block
output [output] Signature buffer

void CYFER_Pk_Size CYFER_PK_CTX   ctx,
size_t *    pt_len,
size_t *    ct_len
 

Returns plaintext and ciphertext block sizes.

Parameters:
ctx Algorithm context
pt_len [output] Length of plaintext block (in bytes)
ct_len [output] Length of ciphertext block (in bytes)

bool CYFER_Pk_Verify CYFER_PK_CTX   ctx,
const unsigned char *    signature,
const unsigned char *    message
 

Verifies signature for a block of data.

Parameters:
ctx Algorithm context
signature Signature block to verify
message Original data block
Returns:
True if the signature matches the data, false otherwise


Generated on Sun Sep 26 13:53:58 2004 for Cyfer by doxygen1.3-rc3