‼️ Patenting in process. Don't try to steal or you'll lose your money.
This is a small and portable C 17 implementation of the Red Encryption Standard(RES). At this repository you also can find 'Res-crypt' terminal application which helps you to encrypt/decrypt strings. RES is upgraded version of Advanced Encryption Standard(AES) and is a part of RedLibrary.
RES has excess level of encryption, and should be used in specific tasks, where you need absolute encryption and ready to sacrifice your perfomance. If you need perfomance, we advise you to use AES(Aes implementation).
RES includes 2 encryption modes: ECB and CBC with 3 key length cases for each of them:
-
ECB
- ResECB 512 bits key
- ResECB 1024 bits key
- ResECB 1536 bits key
-
CBC
- ResCBC 512 bits key
- ResCBC 1024 bits key
- ResCBC 1536 bits key
There are 7 header files(6 with algorithms and 1 with shared definitions) and 6 source files(for each of algorithm).
// ResECB512.h
std::string * EncryptResECB512(const std::string& in, const std::string_view key);
std::string * DecryptResECB512(const std::string& in, const std::string_view key);
// ResECB1024.h
std::string * EncryptResECB1024(const std::string& in, const std::string_view key);
std::string * DecryptResECB1024(const std::string& in, const std::string_view key);
// ResECB1536.h
std::string * EncryptResECB1536(const std::string& in, const std::string_view key);
std::string * DecryptResECB1536(const std::string& in, const std::string_view key);
// ResCBC512.h
std::string * EncryptResCBC512(const std::string& in, const std::string_view key, const std::string_view iv);
std::string * DecryptResCBC512(const std::string& in, const std::string_view key, const std::string_view iv);
// ResCBC1024.h
std::string * EncryptResCBC1024(const std::string& in, const std::string_view key, const std::string_view iv);
std::string * DecryptResCBC1024(const std::string& in, const std::string_view key, const std::string_view iv);
// ResCBC1536.h
std::string * EncryptResCBC1536(const std::string& in, const std::string_view key, const std::string_view iv);
std::string * DecryptResCBC1536(const std::string& in, const std::string_view key, const std::string_view iv);
Tech notes:
- Padding is provided only for "in" params. "Iv" should equals 16 bytes. Key length(in bytes) is calculated using the formula:
KEY_LENGTH / 8
. - ECB mode is considered unsafe for most uses and is not implemented in streaming mode. See wikipedia's article on ECB for more details.
- This library is designed for small code size and simplicity, intended for cases where small binary size, low memory footprint and portability is more important than high performance.
Notes:
- If you want to route result of encryption to
std::cout
, you should convert string to hexadecimal system, in other way you will get bad output! - Convertion functions are included in each of examples.
- There is no built-in error checking or protection from out-of-bounds memory access errors as a result of malicious input.
Here's an example of encryption in CBC1536 mode:
And the following one is the decryption of previous message:
All material in this repository is in the public domain.
With Copyright© ∞ Vladimir Rogozin.