ESAPI-C 1.0
The OWASP Enterprise Security API for C

properties.h File Reference

Encrypted Properties module header. More...

#include "uthash.h"
#include "esapi.h"

Go to the source code of this file.

Data Structures

struct  Map_t
 A hashable key-value pair for an access reference map. More...

Defines

#define MAX_PROPERTY_LINE_LENGTH   4096
 The EncryptedProperties module represents a properties file where all the data is encrypted before it is added, and decrypted when it retrieved.
#define KEY_LEN   64
 The maximum allowed size for a property key.

Typedefs

typedef struct Map_t map_t
 A hashable key-value pair.

Functions

char * get_property (map_t *, struct esapi_ctx *, const char *)
 Get the plaintext property value for the given key from the given encrypted properties map.
char * get_property_or_default (map_t *, struct esapi_ctx *, const char *, const char *)
 Get the plaintext property value for the given key from the given encrypted properties map.
char * set_property (map_t **, struct esapi_ctx *, const char *, const char *)
 Set the given property key-value pair in the given encrypted properties map.
char ** keys (map_t *)
 Get a list of all keys in the given encrypted properties map.
map_tload_properties (const char *)
 Read encrypted properties from the given file.
void store_properties (map_t *, const char *)
 Write encrypted properties to the given file.

Detailed Description

Encrypted Properties module header.

Definition in file properties.h.


Define Documentation

#define MAX_PROPERTY_LINE_LENGTH   4096

The EncryptedProperties module represents a properties file where all the data is encrypted before it is added, and decrypted when it retrieved.

This interface can be implemented in a number of ways, the simplest being wrapping some hashing container library and overloading the behavior of the getProperty() and setProperty() functions. In all cases, the master encryption key is given by the Encryptor.MasterKey property in ESAPI.properties file.

Since:
January 30, 2011

Definition at line 23 of file properties.h.

Referenced by load_properties(), and store_properties().


Function Documentation

char* get_property ( map_t ,
struct esapi_ctx ,
const char *   
)

Get the plaintext property value for the given key from the given encrypted properties map.

The property value is Base64 decoded and decrypted for the caller.

Returns:
A character array containing a plaintext property value, or NULL if the property was not found.

Definition at line 38 of file properties.c.

References esapi_decrypt(), and esapi_log_error().

Referenced by get_property_or_default().

char* get_property_or_default ( map_t ,
struct esapi_ctx ,
const char *  ,
const char *   
)

Get the plaintext property value for the given key from the given encrypted properties map.

If the property is not found, return the given default value.

Returns:
A character array containing a plaintext property value.

Definition at line 58 of file properties.c.

References get_property().

char** keys ( map_t )

Get a list of all keys in the given encrypted properties map.

Returns:
An array of character arrays each containing a property key.

Definition at line 105 of file properties.c.

References keys().

Referenced by keys().

map_t* load_properties ( const char *  )

Read encrypted properties from the given file.

Returns:
A head map_t structure pointer for the loaded properties.

Definition at line 134 of file properties.c.

References MAX_PROPERTY_LINE_LENGTH.

char* set_property ( map_t **  ,
struct esapi_ctx ,
const char *  ,
const char *   
)

Set the given property key-value pair in the given encrypted properties map.

The value is encrypted and Base64 encoded before it is added to the map.

Returns:
A character array containing the plaintext property value that was set, or NULL on a failure.

Definition at line 69 of file properties.c.

References esapi_encrypt(), and esapi_log_error().

 All Data Structures Files Functions Variables Typedefs Defines