Search code examples
encryptioncryptographyaescrypto++

Where can I set the number of rounds of key in crypto++ (AES/CBC mode)?


Are the rounds of key already set in CBC mode(AES-128:10 rounds,AES-192:12 rounds,Aes-256:14 rounds) or is there other way to set the rounds of key? I've found setkeywithround(), but it doesn't seem to work with CBCmode. Below is the sample code I copied and modified from crypto++ wiki

void CBC_modified() {
    AutoSeededRandomPool prng;

    SecByteBlock key(32);
    SecByteBlock iv(AES::BLOCKSIZE);

    prng.GenerateBlock(key, key.size());
    prng.GenerateBlock(iv, iv.size());

    std::string plain = "CBC test mode";

    std::cout << "plain text: " << plain << endl<<endl;
    try
    {
        CBC_Mode< AES >::Encryption e;
        e.SetKeyWithIV(key, key.size(), iv);

Solution

  • Number of rounds of standard algorithms such as AES are predefined and I have never seen anybody change it. if you do so, it will be another algorithm and you will not be able to decrypt it with any standard version of algorithm.

    Round of AES are like this:

    • AES-128 -> 10 round
    • AES-192 -> 12 round
    • AES-256 -> 14 round

    BTW, rounds of algorithm is not related to its mode such as CBC.