aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey/mce/mce_kem.h
blob: 7a8d2f7ff51f90a8a9e96e88c009a9f3161f6e74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/**
 * (C) 2014 cryptosource GmbH
 * (C) 2014 Falko Strenzke fstrenzke@cryptosource.de
 *
 * Botan is released under the Simplified BSD License (see license.txt)
 *
 */

#ifndef BOTAN_MCE_KEM_H__
#define BOTAN_MCE_KEM_H__

#include <botan/mceliece.h>
#include <utility>

namespace Botan {

class BOTAN_DLL McEliece_KEM_Encryptor
   {
   public:
      McEliece_KEM_Encryptor(const McEliece_PublicKey& public_key);

      /**
      * returns the pair (mceliece ciphertext, symmetric key)
      */
      std::pair<secure_vector<byte>, secure_vector<byte>> encrypt(RandomNumberGenerator& rng);

   private:
      McEliece_Public_Operation m_raw_pub_op;
   };

class BOTAN_DLL McEliece_KEM_Decryptor
   {
    public:
      McEliece_KEM_Decryptor(const McEliece_PrivateKey& mce_key);

      /**
      * returns the derived 512-bit symmetric key
      */
      secure_vector<Botan::byte> decrypt(const byte msg[], size_t msg_len);

      /**
      * returns the derived 512-bit symmetric key
      */
      template<typename Alloc>
      secure_vector<Botan::byte> decrypt_vec(const std::vector<byte, Alloc>& v)
         {
         return decrypt(v.data(), v.size());

         }
   private:
      McEliece_Private_Operation m_raw_priv_op;
  };
}

#endif