aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/prov/openssl/openssl.h
blob: e28fb2931a122e81595f79f6c9a2548eeee43cb5 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
* Utils for calling OpenSSL
* (C) 2015,2016 Jack Lloyd
*
* Botan is released under the Simplified BSD License (see license.txt)
*/

#ifndef BOTAN_INTERNAL_OPENSSL_H__
#define BOTAN_INTERNAL_OPENSSL_H__

#include <botan/pk_ops_fwd.h>
#include <botan/secmem.h>
#include <botan/exceptn.h>
#include <memory>
#include <string>

#include <openssl/err.h>
#include <openssl/evp.h>

#if defined(BOTAN_HAS_RC4)
#include <openssl/rc4.h>
#endif

namespace Botan {

class BlockCipher;
class StreamCipher;
class HashFunction;

class OpenSSL_Error : public Exception
   {
   public:
      OpenSSL_Error(const std::string& what) :
         Exception(what + " failed: " + ERR_error_string(ERR_get_error(), nullptr)) {}
   };

/* Block Ciphers */

std::unique_ptr<BlockCipher>
make_openssl_block_cipher(const std::string& name);

/* Hash */

std::unique_ptr<HashFunction>
make_openssl_hash(const std::string& name);

/* RSA */

#if defined(BOTAN_HAS_RSA)

class RSA_PublicKey;
class RSA_PrivateKey;

std::unique_ptr<PK_Ops::Encryption>
make_openssl_rsa_enc_op(const RSA_PublicKey& key, const std::string& params);
std::unique_ptr<PK_Ops::Decryption>
make_openssl_rsa_dec_op(const RSA_PrivateKey& key, const std::string& params);

std::unique_ptr<PK_Ops::Verification>
make_openssl_rsa_ver_op(const RSA_PublicKey& key, const std::string& params);
std::unique_ptr<PK_Ops::Signature>
make_openssl_rsa_sig_op(const RSA_PrivateKey& key, const std::string& params);

#endif

/* ECDSA */

#if defined(BOTAN_HAS_ECDSA)

class ECDSA_PublicKey;
class ECDSA_PrivateKey;

std::unique_ptr<PK_Ops::Verification>
make_openssl_ecdsa_ver_op(const ECDSA_PublicKey& key, const std::string& params);
std::unique_ptr<PK_Ops::Signature>
make_openssl_ecdsa_sig_op(const ECDSA_PrivateKey& key, const std::string& params);

#endif

/* ECDH */

#if defined(BOTAN_HAS_ECDH)

class ECDH_PrivateKey;

std::unique_ptr<PK_Ops::Key_Agreement>
make_openssl_ecdh_ka_op(const ECDH_PrivateKey& key, const std::string& params);

#endif

#if defined(BOTAN_HAS_RC4)

std::unique_ptr<StreamCipher>
make_openssl_rc4(size_t skip);

#endif

}

#endif