crypto/rijndael_test.cc
// Simple block cipher test 256 bits, replace the IV in each test, so no buffer
// overflow in this case. Values of IV are random, and results are checked
// against the Java Rijndael implementation.
Simple block cipher test 256 bits, replace the IV in each test, so no buffer
overflow in this case. Values of IV are random, and results are checked
against the Java Rijndael implementation.
Simple block cipher test 256 bits replace the IV in each test so no buffer overflow in this case . Values of IV are random and results are checked against the Java Rijndael implementation .
TEST(Rijndael256CFB, Key0Plain0) {
  const std::vector<std::string> kIV = {
    {  
      102, -126, -12, 77, -38, -70, -22, -119,
      83, 113, -86, -85, 112, -70, 95, -25,
      -74, 29, -24, 71, 90, 74, -108, -23,
      3, -64, 12, 52, 119, 120, 9, 118,
    }, {  
      108, 120, -32, -37, -29, 109, 63, -103,
      -18, 34, 44, 2, -106, -113, 10, 87,
      28, 125, -52, 125, -19, -59, -113, -7,
      -102, 97, -6, 93, -14, -73, 115, 60,
    }, {  
      123, 33, 67, -121, 114, 69, -87, -70,
      -53, 44, -92, 48, -106, -47, -127, 124,
      -111, -53, 36, 59, -1, -69, -73, 13,
      52, 81, 123, 38, -19, 90, 0, 89,
    }, {  
      -85, -110, 86, -47, 99, 49, -109, -63,
      -4, 106, 96, 110, -27, 29, 122, -23,
      21, -65, 118, 116, 30, 58, -34, -122,
      62, 41, -84, 109, 116, -25, 40, 118,
    },
  };
  const std::vector<std::string> kCipher = {
    {  
      -101, -88, -118, -23, -78, -41, -15, 70,
      -58, -120, 125, -81, 82, -59, 116, -105,
      40, 79, 20, -88, 73, 15, -25, -128,
      74, -57, 119, 18, -6, 20, 109, 89,
    }, {  
      -26, -88, 35, 46, 12, 53, 72, -77,
      66, 41, -52, -128, 76, 1, 72, -74,
      112, -62, -125, -45, -39, 114, 111, 65,
      -45, -53, 124, -91, -68, -124, 59, -60,
    }, {  
      16, 124, 47, 22, 48, 85, -128, -105,
      73, -124, -119, 120, 15, 93, -102, 33,
      -53, -81, 11, 121, 69, -66, 83, -4,
      -123, 67, -23, -5, 53, 46, 57, -77,
    } , {  
      -69, -100, -54, -10, 36, -43, 92, 23,
      117, -18, -35, 87, -30, -18, 103, -121,
      -82, -76, -25, 46, -2, 9, 23, 34,
      51, -20, 119, -92, -103, 69, 2, -19,
    }
  };
  const std::string kKey0(32, '\0');
  const std::string kPlainText0(32, '\0');
  for (int i(0); i < kIV.size(); ++i) {
    Rijndael rijndael(kKey0, kIV[i]);
    std::string cipher;
    rijndael.Encrypt(kPlainText0, &cipher);
    EXPECT_EQ(cipher.compare(kCipher[i]), 0);
    rijndael.SetIV(kIV[i]);
    std::string decrypted;
    rijndael.Decrypt(cipher, &decrypted);
    EXPECT_EQ(decrypted.compare(kPlainText0), 0);
  }
}
TEST ( Rijndael256CFB , Key0Plain0 ) { const std :: vector < std :: string > kIV = { { 102 , -126 , -12 , 77 , -38 , -70 , -22 , -119 , 83 , 113 , -86 , -85 , 112 , -70 , 95 , -25 , -74 , 29 , -24 , 71 , 90 , 74 , -108 , -23 , 3 , -64 , 12 , 52 , 119 , 120 , 9 , 118 , } , { 108 , 120 , -32 , -37 , -29 , 109 , 63 , -103 , -18 , 34 , 44 , 2 , -106 , -113 , 10 , 87 , 28 , 125 , -52 , 125 , -19 , -59 , -113 , -7 , -102 , 97 , -6 , 93 , -14 , -73 , 115 , 60 , } , { 123 , 33 , 67 , -121 , 114 , 69 , -87 , -70 , -53 , 44 , -92 , 48 , -106 , -47 , -127 , 124 , -111 , -53 , 36 , 59 , -1 , -69 , -73 , 13 , 52 , 81 , 123 , 38 , -19 , 90 , 0 , 89 , } , { -85 , -110 , 86 , -47 , 99 , 49 , -109 , -63 , -4 , 106 , 96 , 110 , -27 , 29 , 122 , -23 , 21 , -65 , 118 , 116 , 30 , 58 , -34 , -122 , 62 , 41 , -84 , 109 , 116 , -25 , 40 , 118 , } , } ; const std :: vector < std :: string > kCipher = { { -101 , -88 , -118 , -23 , -78 , -41 , -15 , 70 , -58 , -120 , 125 , -81 , 82 , -59 , 116 , -105 , 40 , 79 , 20 , -88 , 73 , 15 , -25 , -128 , 74 , -57 , 119 , 18 , -6 , 20 , 109 , 89 , } , { -26 , -88 , 35 , 46 , 12 , 53 , 72 , -77 , 66 , 41 , -52 , -128 , 76 , 1 , 72 , -74 , 112 , -62 , -125 , -45 , -39 , 114 , 111 , 65 , -45 , -53 , 124 , -91 , -68 , -124 , 59 , -60 , } , { 16 , 124 , 47 , 22 , 48 , 85 , -128 , -105 , 73 , -124 , -119 , 120 , 15 , 93 , -102 , 33 , -53 , -81 , 11 , 121 , 69 , -66 , 83 , -4 , -123 , 67 , -23 , -5 , 53 , 46 , 57 , -77 , } , { -69 , -100 , -54 , -10 , 36 , -43 , 92 , 23 , 117 , -18 , -35 , 87 , -30 , -18 , 103 , -121 , -82 , -76 , -25 , 46 , -2 , 9 , 23 , 34 , 51 , -20 , 119 , -92 , -103 , 69 , 2 , -19 , } } ; const std :: string kKey0 ( 32 , ' \0 ' ) ; const std :: string kPlainText0 ( 32 , ' \0 ' ) ; for ( int i ( 0 ) ; i < kIV . size ( ) ; ++ i ) { Rijndael rijndael ( kKey0 , kIV [ i ] ) ; std :: string cipher ; rijndael . Encrypt ( kPlainText0 , & cipher ) ; EXPECT_EQ ( cipher . compare ( kCipher [ i ] ) , 0 ) ; rijndael . SetIV ( kIV [ i ] ) ; std :: string decrypted ; rijndael . Decrypt ( cipher , & decrypted ) ; EXPECT_EQ ( decrypted . compare ( kPlainText0 ) , 0 ) ; } }
Simple block cipher test 256 bits, replace the IV in each test, so no buffer
overflow in this case.
Simple block cipher test 256 bits replace the IV in each test so no buffer overflow in this case .
// Test #1 // Test #2 // Test #3 // Test #4 // Test #1 // Test #2 // Test #3 // Test #4 // Rijndael 256 Encrypt test // Rijndael 256 Decrypt test, we must set up same IV