извините
~$ tree ./cryptolib
├── encoding
│ ├── base32.h
│ └── base64.h
├── hash
│ ├── crc32.h
│ ├── hash_base.h
│ ├── hmac.h
│ ├── sha256.cpp
│ ├── sha256.h
│ ├── sha512.cpp
│ ├── sha512.h
│ ├── streebog.cpp
│ └── streebog.h
├── public_key
│ ├── elgamal.h
│ ├── elgamalkey.cpp
│ ├── elgamalkey.h
│ ├── fiatshamir.h
│ ├── fiatshamirkey.cpp
│ ├── fiatshamirkey.h
│ ├── rsa.cpp
│ ├── rsa.h
│ ├── rsakey.cpp
│ └── rsakey.h
├── symmetric_key
│ ├── key.h
│ ├── rc4.h
│ └── symmetric_cipher_base.h
├── exceptions.h
└── utils.h
- Encoding
- Base64
- Base32
- Hash
- SHA256
- SHA512
- Streebog (GOST 34.11-2012)
- HMAC
- Public Key
- RSA (Ciper + sign)
- RSAKey
- ElGamal (Sign)
- ElGamalKey
- FiatShamir (Sign)
- FiatShamirKey
- RSA (Ciper + sign)
- Symmetric Key
- Key
- RC4
- other
- Exceptions
- Utils
Encode:
static std::string encode(const std::string &data);
static std::string encode(const std::vector<uint8_t> &data);
Decode:
static std::vector<uint8_t> decode(const std::string &data);
Encode:
static std::string encode(const std::string &data);
static std::string encode(const std::vector<uint8_t> &data);
Decode:
static std::vector<uint8_t> decode(const std::string &data);
Some usage:
D35CryptoLib/examples/base32-64/main.cpp
Lines 14 to 26 in 0aefd55
This paragraph needs rework
Basic abstract class for all hash functions.
Requires redefinition of methods:
virtual void update(const std::string &data) = 0;
virtual void update(const std::vector<uint8_t> &data) = 0;
virtual void update(std::ifstream& file) = 0;
virtual size_t blockSize() = 0;
// Add descriptions
It also provides the results of the functions:
std::vector<uint8_t> digest()
- Returns raw-bytes digeststd::string hexDigest()
- Returns hex-encoded digest
For normal operation of all methods, it is necessary to put the digest in D35Crypto::HashBase::_digest
(this->_digest
):
Definition:
protected:
std::vector<uint8_t> _digest;
Usage:
void update(const std::vector<uint8_t> &data)
{
std::vector<uint8_t> digest;
/* Calculating */
this->_digest = digest;
}
Calculating digest according to D35Crypto::HashBase
Output of the result according to D35Crypto::HashBase
Calculating digest according to D35Crypto::HashBase
Output of the result according to D35Crypto::HashBase
Calculating digest according to D35Crypto::HashBase
Output of the result according to D35Crypto::HashBase
Setup digest size:
Always initialized with digest size = 64 bytes (512 bits). For change 'work mode' u need use void setMode(int digestSize);
. That method manually set required digest size. Takes values 256 and 512.
Init:
D35Crypto::HMAC<D35Crypto::SHA256> hmac;
Calculating:
void create(const std::string&, const Key&);
void create(const std::vector<uint8_t>&, const Key&);
Output:
std::vector<uint8_t> raw();
- raw-bytes hmacstd::string hex();
- hex-encoded hmac
Some usages:
D35CryptoLib/examples/sha/main.cpp
Lines 33 to 35 in aff9435
D35CryptoLib/examples/hmac/main.cpp
Lines 9 to 14 in aff9435
// TODO
// TODO
// TODO
// TODO
По факту это обертка над вектором байт
// TODO