ESAPI-C 1.0
The OWASP Enterprise Security API for C

crypto.h File Reference

Cryptographic module header. More...

#include <gcrypt.h>
#include "esapi.h"

Go to the source code of this file.

Defines

#define GCRYPT_NO_DEPRECATED   1
 Do not include defintions for deprecated features.
#define GCRYPT_NO_MPI_MACROS   1
 Do not define the shorthand macros.

Functions

char * esapi_encrypt (struct esapi_ctx *, const char *)
 Encrypts the provided plaintext characters using the cipher transformation specified by the property Encryptor.CipherTransformation and the master encryption key as specified by the property Encryptor.MasterKey as defined in the ESAPI.properties file.
char * esapi_decrypt (struct esapi_ctx *, const char *)
 Decrypts the provided cyphertext string using the master encryption key as specified by the property Encryptor.MasterKey as defined in the ESAPI.properties file.
char * esapi_hash (struct esapi_ctx *, const char *)
 Returns a string representation of the hash of the provided plaintext and salt.
gcry_sexp_t * esapi_sign (struct esapi_ctx *, void *, int)
 Returns a signature of the given message.
void esapi_fill_random_token (struct esapi_ctx *, char *, int)
 Generate a random secret key using a cryptographic algorithm and entropy source appropriate for the generation of short term unique keys.
void esapi_fill_crypto_key (struct esapi_ctx *, char *, int)
 Generate a random secret key using a cryptographic algorithm and entropy source appropriate for the generation of long term cryptographic keys.
void esapi_crypto_init (struct esapi_ctx *)
 Initializes the cryptographic engine.
int esapi_verify_signature (struct esapi_ctx *, void *, int, gcry_sexp_t *)
 Incomplete function implementation.
gcry_sexp_t convert_to_asymmetric_key (void *, int)

Detailed Description

Cryptographic module header.

This module provides some convenience methods for encryption, decryption, etc.

All the cryptographic operations use the default cryptographic properties as defined in ESAPI.properties; e.g., default cipher transformation, default key size, default IV type (where applicable), etc.

Since:
January 30, 2011

Definition in file crypto.h.


Function Documentation

void esapi_crypto_init ( struct esapi_ctx )

Initializes the cryptographic engine.

This function must be called before calling any of the other functions in this module.

Parameters:
ctxA properly initialized ESAPI context structure returned by

Definition at line 200 of file crypto.c.

char* esapi_decrypt ( struct esapi_ctx ,
const char *   
)

Decrypts the provided cyphertext string using the master encryption key as specified by the property Encryptor.MasterKey as defined in the ESAPI.properties file.

Parameters:
ciphertextA Base64 encoded cyphertext character array to be decrypted.
Returns:
A character array containing the plaintext resulting from decrypting the specified ciphertext, or NULL on any failure to encrypt.

Definition at line 117 of file crypto.c.

Referenced by get_property().

char* esapi_encrypt ( struct esapi_ctx ,
const char *   
)

Encrypts the provided plaintext characters using the cipher transformation specified by the property Encryptor.CipherTransformation and the master encryption key as specified by the property Encryptor.MasterKey as defined in the ESAPI.properties file.

Parameters:
plaintextA character array containing the plaintext to be encrypted.
Returns:
A character array containing the resulting Base64 encoded cyphertext, or NULL on any failure to encrypt.

Definition at line 33 of file crypto.c.

Referenced by set_property().

void esapi_fill_crypto_key ( struct esapi_ctx ,
char *  ,
int   
)

Generate a random secret key using a cryptographic algorithm and entropy source appropriate for the generation of long term cryptographic keys.

Parameters:
ctxA properly initialized ESAPI context structure returned by

buffA character array to hold the resulting key
lenThe requested length of the key

Definition at line 285 of file crypto.c.

void esapi_fill_random_token ( struct esapi_ctx ,
char *  ,
int   
)

Generate a random secret key using a cryptographic algorithm and entropy source appropriate for the generation of short term unique keys.

Parameters:
ctxA properly initialized ESAPI context structure returned by

buffA character array to hold the resulting key
lenThe requested length of the key

Definition at line 296 of file crypto.c.

Referenced by esapi_get_unique_reference().

char* esapi_hash ( struct esapi_ctx ,
const char *   
)

Returns a string representation of the hash of the provided plaintext and salt.

The salt helps to protect against a rainbow table attack by mixing in some extra data with the plaintext. Some good choices for a salt might be an account name or some other string that is known to the application but not to an attacker. See this article for more information about hashing as it pertains to password schemes.

Parameters:
ctxA valid esapi_ctx from which properly initialized cryptographic engine settings may be retrieved.
plaintextthe plaintext String to encrypt
saltthe salt to add to the plaintext String before hashing
Returns:
A character array containing the Base64 encoded encrypted hash of the given plaintext, or NULL on any failure.

Definition at line 255 of file crypto.c.

gcry_sexp_t* esapi_sign ( struct esapi_ctx ,
void *  ,
int   
)

Returns a signature of the given message.

Parameters:
ctxA valid esapi_ctx from which properly initialized cryptographic engine settings may be retrieved.
msgA character array containing the message
lenThe length of the message
Returns:
A pointer to a gcry_sexp_t containing the signature

Definition at line 310 of file crypto.c.

int esapi_verify_signature ( struct esapi_ctx ctx,
void *  msg,
int  m_len,
gcry_sexp_t *  sig 
)

Incomplete function implementation.

Todo:
Fix to pass valid gcry_sexp_t parameters.

Definition at line 354 of file crypto.c.

 All Data Structures Files Functions Variables Typedefs Defines