BitShares-Core  5.0.0
BitShares blockchain implementation and command-line interface software
aes.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <fc/crypto/sha512.hpp>
4 #include <fc/crypto/sha256.hpp>
5 #include <fc/fwd.hpp>
6 #include <fc/uint128.hpp>
7 
8 #include <vector>
9 
10 namespace fc {
11  class path;
12 
14  {
15  public:
16  aes_encoder();
17  ~aes_encoder();
18 
19  void init( const fc::sha256& key, const uint128_t& init_value );
20  uint32_t encode( const char* plaintxt, uint32_t len, char* ciphertxt );
21 
22  private:
23  struct impl;
25  };
27  {
28  public:
29  aes_decoder();
30  ~aes_decoder();
31 
32  void init( const fc::sha256& key, const uint128_t& init_value );
33  uint32_t decode( const char* ciphertxt, uint32_t len, char* plaintext );
34 
35  private:
36  struct impl;
38  };
39 
40  unsigned aes_encrypt(unsigned char *plaintext, int plaintext_len, unsigned char *key,
41  unsigned char *iv, unsigned char *ciphertext);
42  unsigned aes_decrypt(unsigned char *ciphertext, int ciphertext_len, unsigned char *key,
43  unsigned char *iv, unsigned char *plaintext);
44  unsigned aes_cfb_decrypt(unsigned char *ciphertext, int ciphertext_len, unsigned char *key,
45  unsigned char *iv, unsigned char *plaintext);
46 
47  std::vector<char> aes_encrypt( const fc::sha512& key, const std::vector<char>& plain_text );
48  std::vector<char> aes_decrypt( const fc::sha512& key, const std::vector<char>& cipher_text );
49 
53  void aes_save( const fc::path& file, const fc::sha512& key, std::vector<char> plain_text );
54 
58  std::vector<char> aes_load( const fc::path& file, const fc::sha512& key );
59 
60 } // namespace fc
Used to forward declare value types.
Definition: fwd.hpp:10
void init(const fc::sha256 &key, const uint128_t &init_value)
Definition: aes.cpp:41
unsigned aes_encrypt(unsigned char *plaintext, int plaintext_len, unsigned char *key, unsigned char *iv, unsigned char *ciphertext)
Definition: aes.cpp:181
unsigned aes_cfb_decrypt(unsigned char *ciphertext, int ciphertext_len, unsigned char *key, unsigned char *iv, unsigned char *plaintext)
Definition: aes.cpp:279
~aes_encoder()
Definition: aes.cpp:37
void aes_save(const fc::path &file, const fc::sha512 &key, std::vector< char > plain_text)
Definition: aes.cpp:353
std::vector< char > aes_load(const fc::path &file, const fc::sha512 &key)
Definition: aes.cpp:369
Definition: api.hpp:15
unsigned aes_decrypt(unsigned char *ciphertext, int ciphertext_len, unsigned char *key, unsigned char *iv, unsigned char *plaintext)
Definition: aes.cpp:230
wraps boost::filesystem::path to provide platform independent path manipulation.
Definition: filesystem.hpp:28
uint32_t encode(const char *plaintxt, uint32_t len, char *ciphertxt)
Definition: aes.cpp:67