Botan  2.11.0
Crypto and TLS for C++11
commoncrypto.h
Go to the documentation of this file.
1 /*
2 * Utils for calling CommonCrypto
3 * (C) 2018 Jose Pereira
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7 
8 #ifndef BOTAN_INTERNAL_COMMONCRYPTO_H_
9 #define BOTAN_INTERNAL_COMMONCRYPTO_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 namespace Botan {
18 
19 class Cipher_Mode;
20 class BlockCipher;
21 class HashFunction;
22 enum Cipher_Dir : int;
23 typedef int32_t CCCryptorStatus;
24 
26  {
27  public:
28  CommonCrypto_Error(const std::string& what) :
29  Exception(what + " failed."),
30  m_rc(0) {}
31 
32  CommonCrypto_Error(const std::string& what, int32_t status) :
33  Exception(what + std::string(" failed. Status: ") + ccryptorstatus_to_string(status)),
34  m_rc(status) {}
35 
36  ErrorType error_type() const noexcept override { return ErrorType::CommonCryptoError; }
37 
38  int error_code() const noexcept override { return m_rc; }
39 
40  private:
41  std::string ccryptorstatus_to_string(CCCryptorStatus status);
42 
43  int32_t m_rc;
44  };
45 
46 /* Cipher Modes */
47 
48 Cipher_Mode*
49 make_commoncrypto_cipher_mode(const std::string& name, Cipher_Dir direction);
50 
51 /* Block Ciphers */
52 
53 std::unique_ptr<BlockCipher>
54 make_commoncrypto_block_cipher(const std::string& name);
55 
56 /* Hash */
57 
58 std::unique_ptr<HashFunction> make_commoncrypto_hash(const std::string& name);
59 
60 }
61 
62 #endif
std::unique_ptr< BlockCipher > make_commoncrypto_block_cipher(const std::string &name)
ErrorType error_type() const noexcept override
Definition: commoncrypto.h:36
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
Definition: bigint.h:1136
CommonCrypto_Error(const std::string &what, int32_t status)
Definition: commoncrypto.h:32
int error_code() const noexcept override
Definition: commoncrypto.h:38
std::string name
ErrorType
Definition: exceptn.h:20
Definition: alg_id.cpp:13
std::unique_ptr< HashFunction > make_commoncrypto_hash(const std::string &name)
CommonCrypto_Error(const std::string &what)
Definition: commoncrypto.h:28
Cipher_Dir
Definition: cipher_mode.h:23
Cipher_Mode * make_commoncrypto_cipher_mode(const std::string &name, Cipher_Dir direction)