Hello, Jeff

Thank You very much for such good exploitation, it took a while but thanks 
to that I understood Crypto++ operation. I'm leaving here C familiar code 
with basic AES ECB (1 block) encryption.


#include <iostream>
#include <cstdlib>
using std::exit;
#include "hex.h"
using CryptoPP::HexEncoder;
#include "filters.h"
using CryptoPP::StringSink;
using CryptoPP::StringSource;
using CryptoPP::StreamTransformationFilter;
using CryptoPP::ArraySink;
#include "aes.h"
using CryptoPP::AES;
#include "modes.h"
using CryptoPP::ECB_Mode;
#include <string>
using std::string;

using namespace std;

int main(int argc, char* argv[]) {

    uint8_t key[16] =   {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
    uint8_t plain[16] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F};

    uint8_t cipher[16];

    try {

        ECB_Mode< AES >::Encryption _ENCTYPTION;
        _ENCTYPTION.SetKey( key, 16 );

        StringSource ss1 ( plain, 16, true, new StreamTransformationFilter( 
_ENCTYPTION, new ArraySink( cipher, 16 ) ) );
    }
    catch( CryptoPP::Exception& _ENCTYPTION ) {
        cerr << _ENCTYPTION.what() << endl;
        exit(1);
    }

    string cipher_string;

    StringSource ss2 (cipher, 16, true, new HexEncoder( new 
StringSink(cipher_string)));

    cout << cipher_string << endl;

return 0;
}






I'm wondering if I can get to AES cipher functions without using any mode?

Daniel



On Wednesday, 2 August 2017 20:44:42 UTC+2, Jeffrey Walton wrote:
>
>
>
> On Wednesday, August 2, 2017 at 8:09:55 AM UTC-4, Daniel Karcz wrote:
>>
>> Hello Everyone,
>>
>> I'm moving myself from my own C AES C Library to Crypto++.
>>
>> ...
>>
>> Can Somebody explain me where exactly in this piece of code encryption have 
>> place?
>> In C library I have function which I have to call to encrypt data, it look 
>> similar to
>>
>> encrypt(plain_text, cipher_text, key);
>>
>> I know that encryption is made in try{} block, but I see only class 
>> declaration, key setting and after that is StringSource which Is transform 
>> bytes into string.
>>
>>
> You are using a Pipeline. Obviously, Crypto++ has them just like Unix and 
> Linux. Also see https://www.cryptopp.com/wiki/Pipelining .
>
> In a pipeline, data flows from a source to a sink. In between there are 
> filters which transform the data. The Crypto++ code above is a lot like the 
> following Unix commands:
>
>     cat plain.txt | enc -k key -m ecb | hex -e > cipher.txt
>
> The StreamTransformationFilter is the heavy lifter. It accumulates 
> incoming plain text. It adds padding to the final block. It also 
> accumulates cipher text until you retireve it. Its a very complex filter.
>
> Another filter is the HexEncoder. Its easy to understand its operation.
>
> You might be interested in https://www.cryptopp.com/wiki/Init-Update-Final. 
> It kind of presents Crypto++'s objects in a Java-esque kind of way.
>
> Jeff
>

-- 
-- 
You received this message because you are subscribed to the "Crypto++ Users" 
Google Group.
To unsubscribe, send an email to cryptopp-users-unsubscr...@googlegroups.com.
More information about Crypto++ and this group is available at 
http://www.cryptopp.com.
--- 
You received this message because you are subscribed to the Google Groups 
"Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cryptopp-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to