0

I'm supposed to overload the class below twice. Once I'm supposed to implement it with AES (Rijndael) and once with Twofish. However, I can't seem to find a simple implementation that allows to encrypt only a single block. The implementations I found come with included CBC and Padding. Any hint?

#ifndef CRYPTER_H
#define CRYPTER_H

#include <valarray>

class Crypter {
public:
    Crypter();
    virtual ~Crypter();

    //Encrypts a single block of 16 byte.
    virtual std::valarray<unsigned char> encrypt(std::valarray<unsigned char> plaintext,
            std::valarray<unsigned char> passphrase) = 0;

    //Decrypts a single block of 16 byte.
    virtual std::valarray<unsigned char> decrypt(std::valarray<unsigned char> cyphertext,
            std::valarray<unsigned char> passphrase) = 0;     
};
#endif  /* CRYPTER_H */
Cory Kramer
  • 114,268
  • 16
  • 167
  • 218
Aptitude
  • 23
  • 3

1 Answers1

1

Openssl is the best crypto library for C/C++ and I think it's definitely worth to give it a look.

You can always break data yourself into blocks and encrypt/decrypt with library functions.

Catalin
  • 474
  • 4
  • 19
  • 1
    It is not the best library, but is widely used in Linux, etc. – i486 Sep 02 '15 at 11:48
  • @i486: In OSS cryptography, "widely used" is a strength in and of itself. However, OpenSSL doesn't have a Twofish implementation AFAIK...? – DevSolar Sep 02 '15 at 11:51
  • Found it :-) I can copy the source code from aes_x86core.c. However, there's no Twofish implementation. – Aptitude Sep 02 '15 at 12:22
  • @Aptitude: The idea is to *use* a library (and benefit from future releases), not copy its source code... – DevSolar Sep 02 '15 at 14:28