Main Page | Class Hierarchy | Class List | File List | Class Members

SST::Ident Class Reference

Represents an endpoint identifier and optionally an associated cryptographic signing key. More...

#include <ident.h>

List of all members.

Public Types

enum  Scheme {
  NoScheme = 0, MAC = 1, IP = 2, DSA160 = 10,
  RSA160 = 11
}
 Endpoint identifier scheme numbers. More...


Public Member Functions

 Ident ()
 Create a null Ident.

 Ident (const QByteArray &id)
 Create an Ident with a given binary identifier.

 Ident (const QByteArray &id, const QByteArray &key)
 Create an Ident with a binary identifier and corresponding key.

QByteArray id () const
 Get this identifier's short binary ID.

void setID (const QByteArray &id)
 Set the Ident's short binary ID.

bool isNull ()
 Check for the distinguished "null identity".

Scheme scheme () const
 Determine the scheme number this ID uses.

bool haveKey () const
 Determine whether this identifier contains an associated key usable for signature verification.

bool havePrivateKey () const
 Determine whether this identifier contains a private key usable for both signing and verification.

QByteArray key (bool getPrivateKey=false) const
 Get this Ident's binary-encoded public or private key.

bool setKey (const QByteArray &key)
 Set the public or private key associated with this Ident.

SecureHash * newHash (QObject *parent=NULL) const
 Create a new SecureHash object suitable for hashing messages to be signed using this identity's private key.

QByteArray hash (const void *data, int len) const
 Hash a block of data using this Ident scheme's hash function.

QByteArray hash (const QByteArray &data) const
 Hash a QByteArray using this Ident scheme's hash function.

QByteArray sign (const QByteArray &digest) const
 Sign a message.

bool verify (const QByteArray &digest, const QByteArray &sig) const
 Verify a signature.

QByteArray macAddress ()
 Extract the IEEE MAC address in an identifier with the MAC scheme.

QHostAddress ipAddress (quint16 *out_port=NULL)
 Extract the host address part of an identifier in the IP scheme.

quint16 ipPort ()
 Extract the port number part of an identifier in the IP scheme.


Static Public Member Functions

Ident generate (Scheme sch=RSA160, int bits=0)
 Generate a new Ident with a unique private key, using reasonable default parameters.

Ident fromMacAddress (const QByteArray &addr)
 Create an Ident representing a non-cryptographic IEEE MAC address.

Ident fromIpAddress (const QHostAddress &addr, quint16 port=0)
 Create an Ident representing a non-cryptographic IP address.


Detailed Description

Represents an endpoint identifier and optionally an associated cryptographic signing key.


Member Enumeration Documentation

enum SST::Ident::Scheme
 

Endpoint identifier scheme numbers.

The scheme number occupies the top 6 bits in any EID, making the EID's scheme easily recognizable via the first character in its Base64 representation.

Enumeration values:
NoScheme  Reserved for the "null" Ident.
MAC  IEEE MAC address.
IP  IP address with optional port.
DSA160  DSA with SHA-256, yielding 160-bit IDs.
RSA160  RSA with SHA-256, yielding 160-bit IDs.


Constructor & Destructor Documentation

Ident::Ident const QByteArray &  id  ) 
 

Create an Ident with a given binary identifier.

Parameters:
id the binary identifier.

Ident::Ident const QByteArray &  id,
const QByteArray &  key
 

Create an Ident with a binary identifier and corresponding key.

Parameters:
id the binary identifier.
key the binary representation of the key associated with the identifier.


Member Function Documentation

Ident Ident::fromIpAddress const QHostAddress &  addr,
quint16  port = 0
[static]
 

Create an Ident representing a non-cryptographic IP address.

Non-cryptographic identifiers cannot have signing keys.

Parameters:
addr the IP address.
port an optional transport-layer port number.

Ident Ident::fromMacAddress const QByteArray &  addr  )  [static]
 

Create an Ident representing a non-cryptographic IEEE MAC address.

Non-cryptographic identifiers cannot have signing keys.

Parameters:
addr the 6-byte MAC address.
Returns:
the resulting Ident.

Ident Ident::generate Scheme  sch = RSA160,
int  bits = 0
[static]
 

Generate a new Ident with a unique private key, using reasonable default parameters.

Parameters:
sch the signing scheme to use.
bits the desired key strength in bits, or 0 to use the selected scheme's default.
Returns:
the generated Ident.

QByteArray SST::Ident::hash const QByteArray &  data  )  const [inline]
 

Hash a QByteArray using this Ident scheme's hash function.

This is just a convenience function based on newHash().

Parameters:
data the QByteArray to hash.
Returns:
the resulting hash, in a QByteArray.
See also:
newHash

QByteArray Ident::hash const void *  data,
int  len
const
 

Hash a block of data using this Ident scheme's hash function.

This is just a convenience function based on newHash().

Parameters:
data a pointer to the data to hash.
len the number of bytes to hash.
Returns:
the resulting hash, in a QByteArray.
See also:
newHash

bool SST::Ident::haveKey  )  const [inline]
 

Determine whether this identifier contains an associated key usable for signature verification.

Returns:
true if this Ident contains a public key.

bool SST::Ident::havePrivateKey  )  const [inline]
 

Determine whether this identifier contains a private key usable for both signing and verification.

Returns:
true if this Ident contains a private key.

QByteArray SST::Ident::id  )  const [inline]
 

Get this identifier's short binary ID.

Returns:
the binary identifier, as a QByteArray.

QHostAddress Ident::ipAddress quint16 *  out_port = NULL  ) 
 

Extract the host address part of an identifier in the IP scheme.

Parameters:
port if non-NULL, location to receive optional port number.
Returns:
an IPv4 or an IPv6 address.

quint16 Ident::ipPort  ) 
 

Extract the port number part of an identifier in the IP scheme.

Returns:
the 16-bit port number, 0 if the EID contains no port.

bool SST::Ident::isNull  )  [inline]
 

Check for the distinguished "null identity".

Returns:
true if this is a null Ident.

QByteArray SST::Ident::key bool  getPrivateKey = false  )  const [inline]
 

Get this Ident's binary-encoded public or private key.

Parameters:
getPrivateKey true to obtain the complete public/private key pair if available, false to obtain only the public key.
Returns:
the key encoded into a QByteArray.

QByteArray Ident::macAddress  ) 
 

Extract the IEEE MAC address in an identifier with the MAC scheme.

Returns:
the 6-byte MAC address.

SecureHash* SST::Ident::newHash QObject *  parent = NULL  )  const [inline]
 

Create a new SecureHash object suitable for hashing messages to be signed using this identity's private key.

Parameters:
parent the optional parent for the new SecureHash object.
Returns:
the new SecureHash object. The caller must delete it when done (or allow it to be deleted by its parent).

Scheme SST::Ident::scheme  )  const [inline]
 

Determine the scheme number this ID uses.

Returns:
the scheme number.

void Ident::setID const QByteArray &  id  ) 
 

Set the Ident's short binary ID.

Clears any associated key information.

Parameters:
id the binary identifier.

bool Ident::setKey const QByteArray &  key  ) 
 

Set the public or private key associated with this Ident.

Parameters:
key the binary-encoded public or private key.
Returns:
true if the encoded key was recognized, valid, and the correct key for this identifier.

QByteArray SST::Ident::sign const QByteArray &  digest  )  const [inline]
 

Sign a message.

This Ident must contain a valid private key.

Parameters:
digest the hash digest of the message to be signed.
Returns:
the resulting signature, in a QByteArray.

bool SST::Ident::verify const QByteArray &  digest,
const QByteArray &  sig
const [inline]
 

Verify a signature.

This ident must contain a valid public key.

Parameters:
digest the hash digest of the signed message.
sig the signature to be verified.
Returns:
true if signature verification succeeds.


The documentation for this class was generated from the following files:
Generated on Wed Mar 28 11:48:05 2007 for SST by doxygen 1.3.4