Botan 2.19.5 Crypto and TLS for C&

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
25 class BOTAN_PUBLIC_API(2, 0) CommonCrypto_Error final : public Exception
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
48Cipher_Mode*
49 make_commoncrypto_cipher_mode(const std::string& name, Cipher_Dir direction);
50
51/* Block Ciphers */
52
53std::unique_ptr<BlockCipher>
54 make_commoncrypto_block_cipher(const std::string& name);
55
56/* Hash */
57
58std::unique_ptr<HashFunction> make_commoncrypto_hash(const std::string& name);
59
60}
61
62#endif
Botan::CommonCrypto_Error
Definition: commoncrypto.h:26
Botan::CommonCrypto_Error::error_type
ErrorType error_type() const noexcept override
Definition: commoncrypto.h:36
Botan::CommonCrypto_Error::CommonCrypto_Error
CommonCrypto_Error(const std::string &what)
Definition: commoncrypto.h:28
Botan::CommonCrypto_Error::error_code
int error_code() const noexcept override
Definition: commoncrypto.h:38
Botan::CommonCrypto_Error::CommonCrypto_Error
CommonCrypto_Error(const std::string &what, int32_t status)
Definition: commoncrypto.h:32
Botan::Exception
Definition: exceptn.h:86
name
std::string name
Definition: commoncrypto_hash.cpp:24
final
int(* final)(unsigned char *, CTX *)
Definition: commoncrypto_hash.cpp:29
BOTAN_PUBLIC_API
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
Botan
Definition: alg_id.cpp:13
Botan::make_commoncrypto_hash
std::unique_ptr< HashFunction > make_commoncrypto_hash(const std::string &name)
Definition: commoncrypto_hash.cpp:97
Botan::make_commoncrypto_block_cipher
std::unique_ptr< BlockCipher > make_commoncrypto_block_cipher(const std::string &name)
Definition: commoncrypto_block.cpp:150
Botan::ErrorType
ErrorType
Definition: exceptn.h:20
Botan::ErrorType::CommonCryptoError
@ CommonCryptoError
Botan::Cipher_Dir
Cipher_Dir
Definition: cipher_mode.h:23
Botan::make_commoncrypto_cipher_mode
Cipher_Mode * make_commoncrypto_cipher_mode(const std::string &name, Cipher_Dir direction)
Definition: commoncrypto_mode.cpp:234
Botan::CCCryptorStatus
int32_t CCCryptorStatus
Definition: commoncrypto.h:23
std
Definition: bigint.h:1155