News SF.net Project Frequently Asked Questions Documentation Downloads Mailing Lists How to Contribute

SourceForge.net Logo

Changing the way games are made and played.

TNL::AsymmetricKey class Reference

TNL::AsymmetricKey Class Reference

#include <tnlAsymmetricKey.h>

Inheritance diagram for TNL::AsymmetricKey:

TNL::Object

Public Member Functions

 AsymmetricKey (U8 *dataPtr, U32 bufferSize)
 Constructs an AsymmetricKey from the specified data pointer.

 AsymmetricKey (const ByteBuffer &theBuffer)
 Constructs an AsymmetricKey from a ByteBuffer.

 AsymmetricKey (BitStream *theStream)
 Constructs an AsymmetricKey by reading it from a BitStream.

 AsymmetricKey (U32 keySize)
 Generates a new asymmetric key of keySize bytes.

 ~AsymmetricKey ()
 Destructor for the AsymmetricKey.

ByteBufferPtr getPublicKey ()
 Returns a ByteBuffer containing an encoding of the public key.

ByteBufferPtr getPrivateKey ()
 Returns a ByteBuffer containing an encoding of the private key.

bool hasPrivateKey ()
 Returns true if this AsymmetricKey is a key pair.

bool isValid ()
 Returns true if this is a valid key.

ByteBufferPtr computeSharedSecretKey (AsymmetricKey *publicKey)
 Compute a key we can share with the specified AsymmetricKey for a symmetric crypto.

U32 getKeySize ()
 Returns the strength of the AsymmetricKey in byte size.

ByteBufferPtr hashAndSign (const ByteBuffer &theByteBuffer)
 Constructs a digital signature for the specified buffer of bits.

bool verifySignature (const ByteBuffer &theByteBuffer, const ByteBuffer &theSignature)
 Returns true if the private key associated with this AsymmetricKey signed theByteBuffer with theSignature.


Private Types

enum  KeyType {
  KeyTypePrivate,
  KeyTypePublic
}
 Enum used to indicate the portion of the key we are working with. More...


Private Member Functions

void load (const ByteBuffer &theBuffer)
 Load keypair from a buffer.


Private Attributes

void * mKeyData
 Raw key data.

U32 mKeySize
 Size of the key at construct time.

bool mHasPrivateKey
 Do we have the private key for this?

ByteBufferPtr mPublicKey
 Buffer containing the public half of this keypair.

ByteBufferPtr mPrivateKey
 Buffer containing the private half of this keypair.

bool mIsValid

Member Enumeration Documentation

enum TNL::AsymmetricKey::KeyType [private]
 

Enum used to indicate the portion of the key we are working with.

Enumeration values:
KeyTypePrivate 
KeyTypePublic 


Constructor & Destructor Documentation

TNL::AsymmetricKey::AsymmetricKey U8 dataPtr,
U32  bufferSize
[inline]
 

Constructs an AsymmetricKey from the specified data pointer.

TNL::AsymmetricKey::AsymmetricKey const ByteBuffer theBuffer  )  [inline]
 

Constructs an AsymmetricKey from a ByteBuffer.

TNL::AsymmetricKey::AsymmetricKey BitStream theStream  )  [inline]
 

Constructs an AsymmetricKey by reading it from a BitStream.

TNL::AsymmetricKey::AsymmetricKey U32  keySize  ) 
 

Generates a new asymmetric key of keySize bytes.

TNL::AsymmetricKey::~AsymmetricKey  ) 
 

Destructor for the AsymmetricKey.


Member Function Documentation

void TNL::AsymmetricKey::load const ByteBuffer theBuffer  )  [private]
 

Load keypair from a buffer.

ByteBufferPtr TNL::AsymmetricKey::getPublicKey  )  [inline]
 

Returns a ByteBuffer containing an encoding of the public key.

ByteBufferPtr TNL::AsymmetricKey::getPrivateKey  )  [inline]
 

Returns a ByteBuffer containing an encoding of the private key.

bool TNL::AsymmetricKey::hasPrivateKey  )  [inline]
 

Returns true if this AsymmetricKey is a key pair.

bool TNL::AsymmetricKey::isValid  )  [inline]
 

Returns true if this is a valid key.

ByteBufferPtr TNL::AsymmetricKey::computeSharedSecretKey AsymmetricKey publicKey  ) 
 

Compute a key we can share with the specified AsymmetricKey for a symmetric crypto.

U32 TNL::AsymmetricKey::getKeySize  )  [inline]
 

Returns the strength of the AsymmetricKey in byte size.

ByteBufferPtr TNL::AsymmetricKey::hashAndSign const ByteBuffer theByteBuffer  ) 
 

Constructs a digital signature for the specified buffer of bits.

This method only works for private keys. A public key only Asymmetric key will generate a signature of 0 bytes in length.

bool TNL::AsymmetricKey::verifySignature const ByteBuffer theByteBuffer,
const ByteBuffer theSignature
 

Returns true if the private key associated with this AsymmetricKey signed theByteBuffer with theSignature.


Field Documentation

void* TNL::AsymmetricKey::mKeyData [private]
 

Raw key data.

The specific format of this buffer varies by cryptosystem, so look at the subclass to see how it's laid out. In general this is an opaque buffer.

U32 TNL::AsymmetricKey::mKeySize [private]
 

Size of the key at construct time.

bool TNL::AsymmetricKey::mHasPrivateKey [private]
 

Do we have the private key for this?

We may only have access to the public key (for instance, when validating a message signed by someone else).

ByteBufferPtr TNL::AsymmetricKey::mPublicKey [private]
 

Buffer containing the public half of this keypair.

ByteBufferPtr TNL::AsymmetricKey::mPrivateKey [private]
 

Buffer containing the private half of this keypair.

bool TNL::AsymmetricKey::mIsValid [private]