Botan 2.17.3
Crypto and TLS for C&
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
24namespace Botan {
25
26class BlockCipher;
27class Cipher_Mode;
28class StreamCipher;
29class HashFunction;
30class RandomNumberGenerator;
31enum Cipher_Dir : int;
32
34 {
35 public:
36 OpenSSL_Error(const std::string& what, int err) :
37 Exception(what + " failed: " + ERR_error_string(err, nullptr)),
38 m_err(err) {}
39
40 ErrorType error_type() const noexcept override { return ErrorType::OpenSSLError; }
41
42 int error_code() const noexcept override { return m_err; }
43
44 private:
45 int m_err;
46 };
47
48/* Block Ciphers */
49
50std::unique_ptr<BlockCipher>
51make_openssl_block_cipher(const std::string& name);
52
53/* Cipher Modes */
54
55Cipher_Mode*
56make_openssl_cipher_mode(const std::string& name, Cipher_Dir direction);
57
58/* Hash */
59
60std::unique_ptr<HashFunction>
61make_openssl_hash(const std::string& name);
62
63/* RSA */
64
65#if defined(BOTAN_HAS_RSA)
66
67class RSA_PublicKey;
68class RSA_PrivateKey;
69
70std::unique_ptr<PK_Ops::Encryption>
71make_openssl_rsa_enc_op(const RSA_PublicKey& key, const std::string& params);
72std::unique_ptr<PK_Ops::Decryption>
73make_openssl_rsa_dec_op(const RSA_PrivateKey& key, const std::string& params);
74
75std::unique_ptr<PK_Ops::Verification>
76make_openssl_rsa_ver_op(const RSA_PublicKey& key, const std::string& params);
77std::unique_ptr<PK_Ops::Signature>
78make_openssl_rsa_sig_op(const RSA_PrivateKey& key, const std::string& params);
79std::unique_ptr<RSA_PrivateKey>
80make_openssl_rsa_private_key(RandomNumberGenerator& rng, size_t rsa_bits);
81
82#endif
83
84/* ECDSA */
85
86#if defined(BOTAN_HAS_ECDSA)
87
88class ECDSA_PublicKey;
89class ECDSA_PrivateKey;
90
91std::unique_ptr<PK_Ops::Verification>
92make_openssl_ecdsa_ver_op(const ECDSA_PublicKey& key, const std::string& params);
93std::unique_ptr<PK_Ops::Signature>
94make_openssl_ecdsa_sig_op(const ECDSA_PrivateKey& key, const std::string& params);
95
96#endif
97
98/* ECDH */
99
100#if defined(BOTAN_HAS_ECDH)
101
102class ECDH_PrivateKey;
103
104std::unique_ptr<PK_Ops::Key_Agreement>
105make_openssl_ecdh_ka_op(const ECDH_PrivateKey& key, const std::string& params);
106
107#endif
108
109#if defined(BOTAN_HAS_RC4)
110
111std::unique_ptr<StreamCipher>
112make_openssl_rc4(size_t skip);
113
114#endif
115
116}
117
118#endif
OpenSSL_Error(const std::string &what, int err)
Definition: openssl.h:36
ErrorType error_type() const noexcept override
Definition: openssl.h:40
int error_code() const noexcept override
Definition: openssl.h:42
std::string name
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
Definition: alg_id.cpp:13
std::unique_ptr< BlockCipher > make_openssl_block_cipher(const std::string &name)
Cipher_Mode * make_openssl_cipher_mode(const std::string &name, Cipher_Dir direction)
ErrorType
Definition: exceptn.h:20
Cipher_Dir
Definition: cipher_mode.h:23
std::unique_ptr< HashFunction > make_openssl_hash(const std::string &name)