Botan  1.11.15
src/lib/pubkey/dlies/dlies.h
Go to the documentation of this file.
00001 /*
00002 * DLIES
00003 * (C) 1999-2007 Jack Lloyd
00004 *
00005 * Botan is released under the Simplified BSD License (see license.txt)
00006 */
00007 
00008 #ifndef BOTAN_DLIES_H__
00009 #define BOTAN_DLIES_H__
00010 
00011 #include <botan/pubkey.h>
00012 #include <botan/mac.h>
00013 #include <botan/kdf.h>
00014 
00015 namespace Botan {
00016 
00017 /**
00018 * DLIES Encryption
00019 */
00020 class BOTAN_DLL DLIES_Encryptor : public PK_Encryptor
00021    {
00022    public:
00023       DLIES_Encryptor(const PK_Key_Agreement_Key&,
00024                       KDF* kdf,
00025                       MessageAuthenticationCode* mac,
00026                       size_t mac_key_len = 20);
00027 
00028       void set_other_key(const std::vector<byte>&);
00029    private:
00030       std::vector<byte> enc(const byte[], size_t,
00031                             RandomNumberGenerator&) const;
00032 
00033       size_t maximum_input_size() const;
00034 
00035       std::vector<byte> other_key, my_key;
00036 
00037       PK_Key_Agreement ka;
00038       std::unique_ptr<KDF> kdf;
00039       std::unique_ptr<MessageAuthenticationCode> mac;
00040       size_t mac_keylen;
00041    };
00042 
00043 /**
00044 * DLIES Decryption
00045 */
00046 class BOTAN_DLL DLIES_Decryptor : public PK_Decryptor
00047    {
00048    public:
00049       DLIES_Decryptor(const PK_Key_Agreement_Key&,
00050                       KDF* kdf,
00051                       MessageAuthenticationCode* mac,
00052                       size_t mac_key_len = 20);
00053 
00054    private:
00055       secure_vector<byte> dec(const byte[], size_t) const;
00056 
00057       std::vector<byte> my_key;
00058 
00059       PK_Key_Agreement ka;
00060       std::unique_ptr<KDF> kdf;
00061       std::unique_ptr<MessageAuthenticationCode> mac;
00062       size_t mac_keylen;
00063    };
00064 
00065 }
00066 
00067 #endif