aboutsummaryrefslogtreecommitdiffstats
path: root/src/pubkey/pk_ops.h
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-03-04 22:09:07 +0000
committerlloyd <[email protected]>2010-03-04 22:09:07 +0000
commit664e00a6d51cf7d6f3fefbbb3500a113d21288ab (patch)
tree32db25ebf468a2c75ec4578d83f8c41e0197bfaf /src/pubkey/pk_ops.h
parentf5cfe2857acb30ece3f01fbc98a83e8b82e4907a (diff)
This checkin represents a pretty major change in how PK operations are
performed. Up until now, each key object (eg DSA_PublicKey or ECDH_PrivateKey) had two jobs: contain the key material, and know how to perform any operations on that key. However because of a desire to support alternative implementations (GNU MP, hardware, whatever), there was a notion of operations, with the key objects containing an op that they got via engine rather than actually implementing the underlying algorithms directly. Now, represent the operation as an abstract interface (typically mapping a byte string to a byte string), and pass a plain Public_Key& or Private_Key& to the engine. The engine does any checks it wants (eg based on name, typeid, key sizes, etc), and either returns nothing (I'll pass) or a pointer to a new operation that represents signatures or encryption or what-have-you using that key. This means that plain key objects no longer contain operations. This is a major break with the traditional interface. On the other hand, using these 'bare' operations without padding, KDFs, etc is 99% of the time a bad idea anyway (and if you really need them, there are options so you get the bare op but via the pubkey.h interfaces). Currently this change is only implemented for DH and ECDH (ie, key agreement algorithms). Additionally the optional engines (gnump and openssl) have not been updated. I'll probably wait to touch those until after I can change them all in one go for all algos.
Diffstat (limited to 'src/pubkey/pk_ops.h')
-rw-r--r--src/pubkey/pk_ops.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/pubkey/pk_ops.h b/src/pubkey/pk_ops.h
new file mode 100644
index 000000000..2b9ac4366
--- /dev/null
+++ b/src/pubkey/pk_ops.h
@@ -0,0 +1,38 @@
+/*
+* PK Operation Types
+* (C) 2010 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#ifndef BOTAN_PK_OPERATIONS_H__
+#define BOTAN_PK_OPERATIONS_H__
+
+#include <botan/secmem.h>
+
+namespace Botan {
+
+namespace PK_Ops {
+
+/*
+* A generic Key Agreement Operation (eg DH or ECDH)
+*/
+class BOTAN_DLL KA_Operation
+ {
+ public:
+ /*
+ * Perform a key agreement operation
+ * @param w the other key value
+ * @param w_len the length of w in bytes
+ * @returns the agreed key
+ */
+ virtual SecureVector<byte> agree(const byte w[], u32bit w_len) const = 0;
+
+ virtual ~KA_Operation() {}
+ };
+
+}
+
+}
+
+#endif