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

/Users/baford/proj/netsteria/sst/lib/sign.h

00001 //
00002 // SignKey: abstract base class for public-key cryptographic signing methods
00003 //
00004 #ifndef SST_SIGN_H
00005 #define SST_SIGN_H
00006 
00007 #include <QString>
00008 
00009 class QObject;
00010 class QByteArray;
00011 
00012 namespace SST {
00013 
00014 class SecureHash;
00015 
00016 class SignKey
00017 {
00018 public:
00019         enum Type {
00020                 Invalid = 0,            // Uninitialized or invalid key
00021                 Public = 1,             // Public key only
00022                 Private = 2             // Private key
00023         };
00024 
00025 private:
00026         Type t;
00027 
00028 public:
00029         // Get the type of this key
00030         inline Type type() const { return t; }
00031 
00032         // Get the short hash ID of this public or private key,
00033         // which is usable only for uniquely identifying the key.
00034         virtual QByteArray id() const = 0;
00035 
00036         // Get this Ident's binary-encoded public or private key.
00037         virtual QByteArray key(bool getPrivateKey = false) const = 0;
00038 
00039         // Create a new SecureHash object suitable for hashing messages
00040         // to be signed using this identity's private key.
00041         virtual SecureHash *newHash(QObject *parent = 0) const = 0;
00042 
00043         // Generate or verify a signature
00044         virtual QByteArray sign(const QByteArray &digest) const = 0;
00045         virtual bool verify(const QByteArray &digest,
00046                                 const QByteArray &sig) const = 0;
00047 
00048         virtual ~SignKey();
00049 
00050 protected:
00051         SignKey();
00052 
00053         inline void setType(Type t) { this->t = t; }
00054 };
00055 
00056 } // namespace SST
00057 
00058 #endif  // SST_SIGN_H

Generated on Wed Mar 28 11:48:05 2007 for SST by doxygen 1.3.4