CXI
Loading...
Searching...
No Matches
Public Member Functions | List of all members
PropertyList Class Reference

Constructs and parses key property lists, see Key Properties. More...

Public Member Functions

 PropertyList (void)
 Default Constructor: creates empty property list.
 
 PropertyList (unsigned char *p_data, unsigned int l_data)
 
 PropertyList (const ByteArray &data)
 
 PropertyList (const PropertyList &pl)
 
virtual ~PropertyList (void)
 
void clear (void)
 
void parse (const unsigned char *p_data, unsigned int l_data)
 
void parse (const ByteArray &pl)
 
void merge (const PropertyList &pl)
 
ByteArray serialize (void) const
 
const Propertyget (int idx) const
 
int getAlgo (void) const
 
int getSize (void) const
 
char * getCurve (void)
 
char * getGroup (void)
 
char * getName (void)
 
int getExport (void) const
 
int getUsage (void) const
 
int getSpecifier (void) const
 
char * getLabel (void)
 
int getBlockLength (void) const
 
int getType (void) const
 
char * getDate (void)
 
char * getDateGen (void)
 
char * getDateExp (void)
 
time_t getTime (void)
 
time_t getTimeGen (void)
 
time_t getTimeExp (void)
 
ByteArray getUName (void)
 
const PropertygetMechs (void) const
 
int getFipsUsage (void) const
 
void set (int idx, const Property &property)
 
void setAlgo (int algo)
 
void setSize (int size)
 
void setCurve (const char *curve)
 
void setGroup (const char *group)
 
void setName (const char *name)
 
void setExport (int expo)
 
void setUsage (int usage)
 
void setSpecifier (int spec)
 
void setLabel (const char *label)
 
void setType (int type)
 
void setDate (const char *date)
 
void setDateGen (const char *date)
 
void setDateExp (const char *date)
 
void setTime (time_t timer)
 
void setTimeGen (time_t timer)
 
void setTimeExp (time_t timer)
 
void setMechs (int *mechs, int len)
 
void setFipsUsage (int usage)
 
const PropertyListoperator= (const PropertyList &pl)
 
const PropertyListoperator|= (const PropertyList &pl)
 

Detailed Description

Constructs and parses key property lists, see Key Properties.

This class provides methods to ...

The following example illustrates the usage of the PropertyList class:

// import plain key into CryptoServer
PropertyList keyTemplate;
keyTemplate.setGroup("My Key Group");
keyTemplate.setName("DES Key");
keyTemplate.setExport(CXI_KEY_EXPORT_ALLOW_PLAIN); // don't do this in reality
keyTemplate.setTime(time(NULL));
Key desKey = cxi->key_import(CXI_KEY_FLAG_OVERWRITE,
keyTemplate,
keyBlob,
NULL);
Encapsulates key handles or key blobs of type 'Backup Blob', see Format of Key Blobs.
Definition: sw/cxi_api_c/def/key.h:19
Constructs and parses key property lists, see Key Properties.
Definition: sw/cxi_api_c/def/propertylist.h:19
void setGroup(const char *group)
Definition: propertylist.cpp:517
void setExport(int expo)
Definition: propertylist.cpp:537
void setName(const char *name)
Definition: propertylist.cpp:510
void setTime(time_t timer)
Definition: propertylist.cpp:657
#define CXI_KEY_BLOB_SIMPLE
Simple blob format (Utimaco)
Definition: fw/cxi/def/cxi_defs.h:288
#define CXI_KEY_EXPORT_ALLOW_PLAIN
Allow clear text key export.
Definition: fw/cxi/def/cxi_defs.h:214
#define CXI_KEY_TYPE_SECRET
Secrect key object.
Definition: fw/cxi/def/cxi_defs.h:271
Definition: cxi.cpp:173

Constructor & Destructor Documentation

◆ PropertyList() [1/3]

PropertyList ( unsigned char *  p_data,
unsigned int  l_data 
)

Overloaded Constructor: creates property list from given serialized data.

Parameters
p_datapointer to serialized property list
l_datalength of serialized property list

◆ PropertyList() [2/3]

PropertyList ( const ByteArray data)

Overloaded Constructor: creates property list from given serialized data.

Parameters
dataserialized property list

◆ PropertyList() [3/3]

PropertyList ( const PropertyList pl)

Copy Constructor: creates property list from given property list.

Parameters
plsource property list

◆ ~PropertyList()

~PropertyList ( void  )
virtual

Destructor: frees internal resources.

Member Function Documentation

◆ clear()

void clear ( void  )

Clears all property values.

◆ parse() [1/2]

void parse ( const unsigned char *  p_data,
unsigned int  l_data 
)

Extracts property values from given serialized property list.

Parameters
p_datapointer to serialized property list [TLV coding]
l_datalength of serialized property list

◆ parse() [2/2]

void parse ( const ByteArray pl)

Extracts property values from given serialized property list.

Parameters
plserialized property list [byte array]

◆ merge()

void merge ( const PropertyList pl)

Merges property values of given property list. Existing property values are overwritten.

Parameters
plproperty list to merged

◆ serialize()

ByteArray serialize ( void  ) const

Serializes property list.

Returns
byte array containg serialized property list [TLV coding]

◆ get()

const Property & get ( int  idx) const

Returns the specified property value.

Parameters
idxproperty specifier, see Key Properties
Returns
raw property value

◆ getAlgo()

int getAlgo ( void  ) const

Returns the key algorithm.

Returns
key algorithm (CXI_KEY_ALGO_XXX), see Algorithm Specifier

◆ getSize()

int getSize ( void  ) const

Returns the key size.

Returns
key size in bits

◆ getCurve()

char * getCurve ( void  )

Returns the name of the elliptic curve.

Returns
curve name [zero terminated C-string] or NULL pointer if the key's property list doesn't contain this value.

◆ getGroup()

char * getGroup ( void  )

Returns the key group as C-string.

Returns
group [zero terminated C-string] or NULL pointer if the key's property list doesn't contain this value.
Note
If the key group is stored as Unicode string the returned string is preceded by '{U}'.

◆ getName()

char * getName ( void  )

Returns the key name.

Returns
name [zero terminated C-string] or NULL pointer if the key's property list doesn't contain this value.
Note
If the key name is stored as Unicode string the string is preceded by '{U}'.

◆ getExport()

int getExport ( void  ) const

Returns the key export property.

Returns
key export property (CXI_KEY_EXPORT_XXX), see Export Policy Specifier

◆ getUsage()

int getUsage ( void  ) const

Returns the key usage property.

Returns
key usage property (CXI_KEY_USAGE_XXX), see Usage Specifier

◆ getSpecifier()

int getSpecifier ( void  ) const

Returns the key specifier property.

Returns
specifier or -1 if the key's property list doesn't contain this value.
Note
This value is optional and may be used to distinguish between keys with the same name and group, e.g. to specify a key version.

◆ getLabel()

char * getLabel ( void  )

Returns the key label.

Returns
label [zero terminated C-string] or NULL pointer if the key's property list doesn't contain this value.
Note
If the key label is stored as Unicode String the string is preceded by '{U}'.

◆ getBlockLength()

int getBlockLength ( void  ) const

Returns the block length of the key.

Returns
block length of the key in bytes.

◆ getType()

int getType ( void  ) const

Returns the key type.

Returns
key type (CXI_KEY_TYPE_XXX), see Key Types

◆ getDate()

char * getDate ( void  )

Returns the key generation date.

Returns
date [zero terminated C-string] or NULL pointer if the key's property list doesn't contain this value.
Note
This function has been superseeded by PropertyList::getDateGen.

◆ getDateGen()

char * getDateGen ( void  )

Returns the key generation date.

Returns
date [zero terminated C-string] or NULL pointer if the key's property list doesn't contain this value.

◆ getDateExp()

char * getDateExp ( void  )

Returns the key expiration date.

Returns
date [zero terminated C-string] or NULL pointer if the key's property list doesn't contain this value.

◆ getTime()

time_t getTime ( void  )

Returns the key generation date.

Returns
UNIX time [seconds since 1/1/70] or zero if the key's property list doesn't contain this value.
Note
This function has been superseeded by PropertyList::getTimeGen.

◆ getTimeGen()

time_t getTimeGen ( void  )

Returns the key generation date.

Returns
UNIX time [seconds since 1/1/70] or zero if the key's property list doesn't contain this value.

◆ getTimeExp()

time_t getTimeExp ( void  )

Returns the key expiration date.

Returns
UNIX time [seconds since 1/1/70] or zero if the key's property list doesn't contain this value.

◆ getUName()

ByteArray getUName ( void  )

Returns the unique key name.

Returns
unique key name, which is the MD5 hash over group, name and specifier.
Exceptions
cxi::Exceptionin case the property list doesn't contain the unique name or the unique name can't be calculated.

◆ getMechs()

const Property & getMechs ( void  ) const

Returns allowed mechanisms for key.

Returns
key mechanisms as raw property value

◆ getFipsUsage()

int getFipsUsage ( void  ) const

Returns fips specific usage and padding flag

Returns
fips usage property

◆ set()

void set ( int  idx,
const Property property 
)

Sets the specified property value.

Parameters
idxproperty specifier, see Key Properties
propertyproperty value to be set

◆ setAlgo()

void setAlgo ( int  algo)

Sets the key algorithm.

Parameters
algokey algorithm (CXI_KEY_ALGO_XXX), see Algorithm Specifier

◆ setSize()

void setSize ( int  size)

Sets the key size.

Parameters
sizekey size in bits

◆ setCurve()

void setCurve ( const char *  curve)

Sets the name of the elliptic curve.

Parameters
curvename [zero terminated C-string]

◆ setGroup()

void setGroup ( const char *  group)

Sets the key group.

Parameters
groupgroup [zero terminated C-string]
Note
If the group is preceded by '{U}', the string is internally converted to Unicode.

◆ setName()

void setName ( const char *  name)

Sets the key name.

Parameters
namekey name [zero terminated C-string]
Note
If the name is preceded by '{U}', the string is converted to Unicode.

◆ setExport()

void setExport ( int  expo)

Sets the key export property.

Parameters
expoexport propery value [integer] (CXI_KEY_EXPORT_XXX), see Export Policy Specifier.

◆ setUsage()

void setUsage ( int  usage)

Sets the key usage property.

Parameters
usageusage propery value [integer] (CXI_KEY_USAGE_XXX), see Usage Specifier

◆ setSpecifier()

void setSpecifier ( int  spec)

Sets the key specifier.

Parameters
specspecifier [integer]
Note
This optional value can be used to distinguish between keys with the same name and group, e.g. to specify a key version.

◆ setLabel()

void setLabel ( const char *  label)

Sets the key label.

Parameters
labellabel [zero terminated C-string]
Note
If the given string is preceded by {U}, it will be converted to Unicode.

◆ setType()

void setType ( int  type)

Sets the key type.

Parameters
typekey type [integer]

◆ setDate()

void setDate ( const char *  date)

Sets the key generation or expiration date property.

Parameters
date(zero terminated C-string: [CC]YYMMDDHHMMSSZ)

◆ setDateGen()

void setDateGen ( const char *  date)

Sets the key generation date property.

Parameters
date(zero terminated C-string: [CC]YYMMDDHHMMSSZ)

◆ setDateExp()

void setDateExp ( const char *  date)

Sets the key expiration date property.

Parameters
date(zero terminated C-string: [CC]YYMMDDHHMMSSZ)

◆ setTime()

void setTime ( time_t  timer)

Sets the key generation or expiration date property

Parameters
timerUNIX time [seconds since 1/1/70]
Note
This function has been superseeded by PropertyList::setTimeGen

◆ setTimeGen()

void setTimeGen ( time_t  timer)

Sets the key generation date property

Parameters
timerUNIX time [seconds since 1/1/70]

◆ setTimeExp()

void setTimeExp ( time_t  timer)

Sets the key expiration date property

Parameters
timerUNIX time [seconds since 1/1/70]

◆ setMechs()

void setMechs ( int *  mechs,
int  len 
)

Sets allowed mechanisms for a key.

Parameters
mechsmechanism array
lennumber of mechanisms

◆ setFipsUsage()

void setFipsUsage ( int  usage)

Sets fips specific usage and padding flag

Parameters
usagesignature calculation/verification w/ specific padding or other operation

◆ operator=()

const PropertyList & operator= ( const PropertyList pl)

Copies one instance of a property list to another.

Parameters
plsource property list

◆ operator|=()

const PropertyList & operator|= ( const PropertyList pl)

Merges to property lists.

Parameters
plproperty list to be merged
Note
Existing values are overwritten.