aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey/mce/mce_kem.h
blob: 2bb1edba56f0b25fdd33dd0ab8da44d4040e7526 (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
 *
 * Distributed under the terms of the Botan license
 *
 */

#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[0], v.size());

         }
   private:
      McEliece_Private_Operation m_raw_priv_op;
  };
}

#endif /* h-guard */