crypto/rijndael_test.cc
// Test the "chained" operation of CFB, overflowing the register and requesting
// new bytes to refill the buffer. kCipher bytes were tested against the Java
// Rijndael implementation.
Test the "chained" operation of CFB, overflowing the register and requesting
new bytes to refill the buffer. kCipher bytes were tested against the Java
Rijndael implementation.
Test the " chained " operation of CFB overflowing the register and requesting new bytes to refill the buffer . kCipher bytes were tested against the Java Rijndael implementation .
TEST(Rijndael256CFB, Key0IV0) {
  const char kPlaintextBytes[64] = {
    37, 49, -10, 60, 88, -18, 16, -47,
    64, -75, 17, 32, 71, -38, 56, -78,
    97, 50, -94, -33, -117, 26, 120, -5,
    -27, 86, -81, -95, 48, -104, 88, 104,
    94, 51, 54, 102, 120, -17, 93, 94,
    1, -121, 93, -53, -63, 107, -95, -64,
    90, 68, -25, -85, -45, 73, 18, 37,
    97, 77, -67, 112, -6, 78, -121, -127,
  };
  const std::vector<std::string> kCipher = {
    { -29, },
    { 19, -120, },
    { 75, 24, 89, },
    {-11, -22, 28, 2, },
    { 105, 69, 96, 84, -109, },
    { -75, 71, -60, -127, -71, 82, },
    { -80, -62, 34, -19, -59, -50, -126, },
    { -111, 100, -46, -101, 6, -55, -105, -55, },
    { 54, 92, 68, -36, -127, 59, -112, 61, -58, },
    { -9, -50, 69, 119, 127, -51, 20, 14, -87, 49, },
  };
  const std::string kKey0(32, '\0');
  const std::string kIV0(32, '\0');
  Rijndael rijndael_enc(kKey0, kIV0);
  Rijndael rijndael_dec(kKey0, kIV0);
  int i(0);
  for (int j(1); j <= 10; ++j) {
    std::string cipher;
    rijndael_enc.Encrypt(std::string(&kPlaintextBytes[i], j), &cipher);
    EXPECT_EQ(cipher.compare(kCipher[j-1]), 0);
    std::string decrypted;
    rijndael_dec.Decrypt(cipher, &decrypted);
    EXPECT_EQ(decrypted.length(), j);
    EXPECT_EQ(decrypted.compare(std::string(&kPlaintextBytes[i], j)), 0);
    i+=j;
  }
}
TEST ( Rijndael256CFB , Key0IV0 ) { const char kPlaintextBytes [ 64 ] = { 37 , 49 , -10 , 60 , 88 , -18 , 16 , -47 , 64 , -75 , 17 , 32 , 71 , -38 , 56 , -78 , 97 , 50 , -94 , -33 , -117 , 26 , 120 , -5 , -27 , 86 , -81 , -95 , 48 , -104 , 88 , 104 , 94 , 51 , 54 , 102 , 120 , -17 , 93 , 94 , 1 , -121 , 93 , -53 , -63 , 107 , -95 , -64 , 90 , 68 , -25 , -85 , -45 , 73 , 18 , 37 , 97 , 77 , -67 , 112 , -6 , 78 , -121 , -127 , } ; const std :: vector < std :: string > kCipher = { { -29 , } , { 19 , -120 , } , { 75 , 24 , 89 , } , { -11 , -22 , 28 , 2 , } , { 105 , 69 , 96 , 84 , -109 , } , { -75 , 71 , -60 , -127 , -71 , 82 , } , { -80 , -62 , 34 , -19 , -59 , -50 , -126 , } , { -111 , 100 , -46 , -101 , 6 , -55 , -105 , -55 , } , { 54 , 92 , 68 , -36 , -127 , 59 , -112 , 61 , -58 , } , { -9 , -50 , 69 , 119 , 127 , -51 , 20 , 14 , -87 , 49 , } , } ; const std :: string kKey0 ( 32 , ' \0 ' ) ; const std :: string kIV0 ( 32 , ' \0 ' ) ; Rijndael rijndael_enc ( kKey0 , kIV0 ) ; Rijndael rijndael_dec ( kKey0 , kIV0 ) ; int i ( 0 ) ; for ( int j ( 1 ) ; j <= 10 ; ++ j ) { std :: string cipher ; rijndael_enc . Encrypt ( std :: string ( & kPlaintextBytes [ i ] , j ) , & cipher ) ; EXPECT_EQ ( cipher . compare ( kCipher [ j - 1 ] ) , 0 ) ; std :: string decrypted ; rijndael_dec . Decrypt ( cipher , & decrypted ) ; EXPECT_EQ ( decrypted . length ( ) , j ) ; EXPECT_EQ ( decrypted . compare ( std :: string ( & kPlaintextBytes [ i ] , j ) ) , 0 ) ; i += j ; } }
Test the "chained" operation of CFB, overflowing the register and requesting
new bytes to refill the buffer.
Test the " chained " operation of CFB overflowing the register and requesting new bytes to refill the buffer .
// Encipher variable length // Cipher again // Results must be the same