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

Encapsulates key handles or key blobs of type 'Backup Blob', see Format of Key Blobs. More...

Inheritance diagram for Key:
[legend]
Collaboration diagram for Key:
[legend]

Public Types

enum  types {
  TYPE_UNKNOWN = 0 , TYPE_HANDLE , TYPE_BLOB , TYPE_UNKNOWN = 0 ,
  TYPE_HANDLE , TYPE_BLOB
}
 
enum  types {
  TYPE_UNKNOWN = 0 , TYPE_HANDLE , TYPE_BLOB , TYPE_UNKNOWN = 0 ,
  TYPE_HANDLE , TYPE_BLOB
}
 

Public Member Functions

 Key (void)
 
 Key (const ByteArray &b)
 
 Key (const char *data, int len)
 
int getType () const
 
ByteArray getUName () const
 
PropertyList getProplist () const
 
ByteArray getPublicKey () const
 
- Public Member Functions inherited from ByteArray
 ByteArray (void)
 
 ByteArray (int len)
 
 ByteArray (const char *data, int len)
 
 ByteArray (const char *str)
 
 ByteArray (int val, int len)
 
 ByteArray (const ByteArray &ba)
 
virtual ~ByteArray (void)
 
void clear (void)
 
int length (void) const
 
char * get (void)
 
const char * get (void) const
 
void set (const char *data, int len)
 
void append (const char *data, int len)
 
void append (const ByteArray &ba)
 
void insert (const char *data, int len, int offset)
 
void fill (char value, int len, int offset)
 
int getInt (int def_val=0) const
 
void setInt (int val, int len)
 
void appendInt (int val, int len)
 
void getString (char *str, int max_size) const
 
void setString (const char *str)
 
void appendString (const char *str)
 
std::string toString (void) const
 
std::string toHexString (void) const
 
int compare (const ByteArray &ba) const
 
ByteArray sub (int offset, int len=-1) const
 
ByteArray lstrip (void) const
 
ByteArray rstrip (const std::set< char > &charsToBeStripped) const
 
void read (const char *filename)
 
void write (const char *filename) const
 
void xtrace (const char *text=0) const
 
ByteArrayoperator= (const ByteArray &ba)
 
const ByteArrayoperator+= (const ByteArray &ba)
 
const ByteArrayoperator|= (const ByteArray &ba)
 
const ByteArrayoperator^= (const ByteArray &ba)
 
char & operator[] (int idx)
 

Detailed Description

Encapsulates key handles or key blobs of type 'Backup Blob', see Format of Key Blobs.

A key can either contain a handle to a key that is stored on the CryptoServer (internal storage) or a key blob of type 'Backup Blob' that contains the attributes and components of the key (external storage).

A key blob contains the attributes and components of the key, see Format of Key Blobs. The key components are encrypted with the CryptoServers Master Backup Key (MBK). Additionally a key blob is protected against manipulation with a check value, which is a MAC over all key blob items, calculated with a MBK derived key.

Note
On cryptographic operations the CryptoServer accepts a key handle as well as a key blobs.
In case of a key handle the key will be loaded from the internal database, otherwise, in case of a key blob, the chack value (MAC) of the key is checked and the key is decrypted with the MBK.

Member Enumeration Documentation

◆ types [1/2]

enum types

Key Types

Enumerator
TYPE_UNKNOWN 

unknown key type

TYPE_HANDLE 

key handle: reference to internal key stored on CryptoServer

TYPE_BLOB 

key blob: external key (encrypted with the CryptoServer's MBK)

TYPE_UNKNOWN 

unknown key type

TYPE_HANDLE 

key handle: reference to internal key stored on CryptoServer

TYPE_BLOB 

key blob: external key (encrypted with the CryptoServer's MBK)

◆ types [2/2]

enum types

Key Types

Enumerator
TYPE_UNKNOWN 

unknown key type

TYPE_HANDLE 

key handle: reference to internal key stored on CryptoServer

TYPE_BLOB 

key blob: external key (encrypted with the CryptoServer's MBK)

TYPE_UNKNOWN 

unknown key type

TYPE_HANDLE 

key handle: reference to internal key stored on CryptoServer

TYPE_BLOB 

key blob: external key (encrypted with the CryptoServer's MBK)

Constructor & Destructor Documentation

◆ Key() [1/3]

Key ( void  )

Default Constructor: creates empty key

◆ Key() [2/3]

Key ( const ByteArray b)

Copy Constructor: creates a deep copy

◆ Key() [3/3]

Key ( const char *  data,
int  len 
)

Overloaded Constructor: creates a new key from given data

Member Function Documentation

◆ getType()

int getType ( void  ) const

Returns the key type.

Returns
key type:
  • KEY_TYPE_HANDLE : key handle for a key stored on CryptoServer
  • KEY_TYPE_BLOB : MBK encrypted key backup blob (external key)
Exceptions
cxi::Exceptionin case of a malformed key blob

◆ getUName()

ByteArray getUName ( void  ) const

Returns the unique key name.

Returns
unique key name, which is the MD5 hash over group, name and specifier.
Exceptions
cxi::Exceptionin case of a malformed key blob

◆ getProplist()

PropertyList getProplist ( void  ) const

Returns the property list of this key.

Returns
property list
Exceptions
cxi::Exceptionif key doesn't contain a key blob or if its structure is invalid
Note
If the key is not a key blob (but a handle) an exception will be thrown.

◆ getPublicKey()

ByteArray getPublicKey ( void  ) const

Returns the public key value of this key.

Returns
byte array
Exceptions
cxi::Exceptionif key doesn't contain a key blob or if its structure is invalid
Note
If the key is not a key blob (but a handle) an exception will be thrown.