Botan 3.0.0-alpha0
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
17namespace Botan {
18
19class Cipher_Mode;
20class BlockCipher;
21class HashFunction;
22enum Cipher_Dir : int;
23typedef 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
48std::unique_ptr<Cipher_Mode>
49make_commoncrypto_cipher_mode(const std::string& name, Cipher_Dir direction);
50
51/* Block Ciphers */
52
53std::unique_ptr<BlockCipher>
54make_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
ErrorType error_type() const noexcept override
Definition: commoncrypto.h:36
CommonCrypto_Error(const std::string &what)
Definition: commoncrypto.h:28
int error_code() const noexcept override
Definition: commoncrypto.h:38
CommonCrypto_Error(const std::string &what, int32_t status)
Definition: commoncrypto.h:32
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< HashFunction > make_commoncrypto_hash(const std::string &name)
std::unique_ptr< Cipher_Mode > make_commoncrypto_cipher_mode(const std::string &name, Cipher_Dir direction)
std::unique_ptr< BlockCipher > make_commoncrypto_block_cipher(const std::string &name)
ErrorType
Definition: exceptn.h:20
Cipher_Dir
Definition: cipher_mode.h:23
int32_t CCCryptorStatus
Definition: commoncrypto.h:23
Definition: bigint.h:1077