Botan  2.7.0
Crypto and TLS for C++11
openssl.h
Go to the documentation of this file.
1 /*
2 * Utils for calling OpenSSL
3 * (C) 2015,2016 Jack Lloyd
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7 
8 #ifndef BOTAN_INTERNAL_OPENSSL_H_
9 #define BOTAN_INTERNAL_OPENSSL_H_
10 
11 #include <botan/pk_ops_fwd.h>
12 #include <botan/secmem.h>
13 #include <botan/exceptn.h>
14 #include <memory>
15 #include <string>
16 
17 #include <openssl/err.h>
18 #include <openssl/evp.h>
19 
20 #if defined(BOTAN_HAS_RC4)
21 #include <openssl/rc4.h>
22 #endif
23 
24 namespace Botan {
25 
26 class BlockCipher;
27 class Cipher_Mode;
28 class StreamCipher;
29 class HashFunction;
30 class RandomNumberGenerator;
31 enum Cipher_Dir : int;
32 
33 class BOTAN_PUBLIC_API(2,0) OpenSSL_Error final : public Exception
34  {
35  public:
36  OpenSSL_Error(const std::string& what) :
37  Exception(what + " failed: " + ERR_error_string(ERR_get_error(), nullptr)) {}
38 
39  OpenSSL_Error(const std::string& what, int err) :
40  Exception(what + " failed: " + ERR_error_string(err, nullptr)) {}
41  };
42 
43 /* Block Ciphers */
44 
45 std::unique_ptr<BlockCipher>
46 make_openssl_block_cipher(const std::string& name);
47 
48 /* Cipher Modes */
49 
50 Cipher_Mode*
51 make_openssl_cipher_mode(const std::string& name, Cipher_Dir direction);
52 
53 /* Hash */
54 
55 std::unique_ptr<HashFunction>
56 make_openssl_hash(const std::string& name);
57 
58 /* RSA */
59 
60 #if defined(BOTAN_HAS_RSA)
61 
62 class RSA_PublicKey;
63 class RSA_PrivateKey;
64 
65 std::unique_ptr<PK_Ops::Encryption>
66 make_openssl_rsa_enc_op(const RSA_PublicKey& key, const std::string& params);
67 std::unique_ptr<PK_Ops::Decryption>
68 make_openssl_rsa_dec_op(const RSA_PrivateKey& key, const std::string& params);
69 
70 std::unique_ptr<PK_Ops::Verification>
71 make_openssl_rsa_ver_op(const RSA_PublicKey& key, const std::string& params);
72 std::unique_ptr<PK_Ops::Signature>
73 make_openssl_rsa_sig_op(const RSA_PrivateKey& key, const std::string& params);
74 std::unique_ptr<RSA_PrivateKey>
75 make_openssl_rsa_private_key(RandomNumberGenerator& rng, size_t rsa_bits);
76 
77 #endif
78 
79 /* ECDSA */
80 
81 #if defined(BOTAN_HAS_ECDSA)
82 
83 class ECDSA_PublicKey;
84 class ECDSA_PrivateKey;
85 
86 std::unique_ptr<PK_Ops::Verification>
87 make_openssl_ecdsa_ver_op(const ECDSA_PublicKey& key, const std::string& params);
88 std::unique_ptr<PK_Ops::Signature>
89 make_openssl_ecdsa_sig_op(const ECDSA_PrivateKey& key, const std::string& params);
90 
91 #endif
92 
93 /* ECDH */
94 
95 #if defined(BOTAN_HAS_ECDH)
96 
97 class ECDH_PrivateKey;
98 
99 std::unique_ptr<PK_Ops::Key_Agreement>
100 make_openssl_ecdh_ka_op(const ECDH_PrivateKey& key, const std::string& params);
101 
102 #endif
103 
104 #if defined(BOTAN_HAS_RC4)
105 
106 std::unique_ptr<StreamCipher>
107 make_openssl_rc4(size_t skip);
108 
109 #endif
110 
111 }
112 
113 #endif
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:27
Cipher_Mode * make_openssl_cipher_mode(const std::string &name, Cipher_Dir direction)
OpenSSL_Error(const std::string &what)
Definition: openssl.h:36
std::unique_ptr< HashFunction > make_openssl_hash(const std::string &name)
Definition: alg_id.cpp:13
Cipher_Dir
Definition: cipher_mode.h:24
std::unique_ptr< BlockCipher > make_openssl_block_cipher(const std::string &name)
OpenSSL_Error(const std::string &what, int err)
Definition: openssl.h:39