1# 2# Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved. 3# 4# Licensed under the Apache License 2.0 (the "License"). You may not use 5# this file except in compliance with the License. You can obtain a copy 6# in the file LICENSE in the source distribution or at 7# https://www.openssl.org/source/license.html 8 9# Original test vectors were taken from https://www.ietf.org/rfc/rfc3962.txt for CS3 10# These have an IV of all zeros, for a 128 bit AES key. 11 12Title = AES CBC Test vectors 13 14#------------------------------------------------------ 15# AES_CBC results for aligned block lengths. (Result should be the same as 32 byte CTS1 & CTS2) 16 17# 32 bytes input 18Cipher = AES-128-CBC 19Key = 636869636b656e207465726979616b69 20IV = 00000000000000000000000000000000 21Plaintext = 4920776f756c64206c696b65207468652047656e6572616c2047617527732043 22Ciphertext = 97687268d6ecccc0c07b25e25ecfe58439312523a78662d5be7fcbcc98ebf5a8 23 24# 48 bytes input 25Cipher = AES-128-CBC 26Key = 636869636b656e207465726979616b69 27IV = 00000000000000000000000000000000 28Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c20 29Ciphertext = 97687268d6ecccc0c07b25e25ecfe58439312523a78662d5be7fcbcc98ebf5a89dad8bbb96c4cdc03bc103e1a194bbd8 30 31# 64 bytes input 32Cipher = AES-128-CBC 33Key = 636869636b656e207465726979616b69 34IV = 00000000000000000000000000000000 35Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c20616e6420776f6e746f6e20736f75702e 36Ciphertext = 97687268d6ecccc0c07b25e25ecfe58439312523a78662d5be7fcbcc98ebf5a89dad8bbb96c4cdc03bc103e1a194bbd84807efe836ee89a526730dbc2f7bc840 37 38Title = AES CBC CTS1 Test vectors 39 40#------------------------------------------------------ 41# Manually edited using the same inputs to also produce CS1 ciphertext 42# where aligned blocks are the same as CBC mode, and partial lengths 43# have the last 2 blocks swapped compared to CS3. 44 45# 17 bytes Input((Default is CS1 if CTSMode is not specified) 46Cipher = AES-128-CBC-CTS 47Key = 636869636b656e207465726979616b69 48IV = 00000000000000000000000000000000 49Plaintext = 4920776f756c64206c696b652074686520 50Ciphertext = 97c6353568f2bf8cb4d8a580362da7ff7f 51NextIV = c6353568f2bf8cb4d8a580362da7ff7f 52 53# 31 bytes input 54Cipher = AES-128-CBC-CTS 55CTSMode = CS1 56Key = 636869636b656e207465726979616b69 57IV = 00000000000000000000000000000000 58Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320 59Ciphertext = 97687268d6ecccc0c07b25e25ecfe5fc00783e0efdb2c1d445d4c8eff7ed22 60NextIV = fc00783e0efdb2c1d445d4c8eff7ed22 61 62# 32 bytes input 63Cipher = AES-128-CBC-CTS 64CTSMode = CS1 65Key = 636869636b656e207465726979616b69 66IV = 00000000000000000000000000000000 67Plaintext = 4920776f756c64206c696b65207468652047656e6572616c2047617527732043 68Ciphertext = 97687268d6ecccc0c07b25e25ecfe58439312523a78662d5be7fcbcc98ebf5a8 69NextIV = 39312523a78662d5be7fcbcc98ebf5a8 70 71# 47 bytes input 72Cipher = AES-128-CBC-CTS 73Key = 636869636b656e207465726979616b69 74IV = 00000000000000000000000000000000 75Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c 76Ciphertext = 97687268d6ecccc0c07b25e25ecfe58439312523a78662d5be7fcbcc98ebf5b3fffd940c16a18c1b5549d2f838029e 77NextIV = b3fffd940c16a18c1b5549d2f838029e 78 79# 64 bytes input (CS1 is equivalent to CBC when the last block in full) 80Cipher = AES-128-CBC-CTS 81CTSMode = CS1 82Key = 636869636b656e207465726979616b69 83IV = 00000000000000000000000000000000 84Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c20616e6420776f6e746f6e20736f75702e 85Ciphertext = 97687268d6ecccc0c07b25e25ecfe58439312523a78662d5be7fcbcc98ebf5a89dad8bbb96c4cdc03bc103e1a194bbd84807efe836ee89a526730dbc2f7bc840 86NextIV = 4807efe836ee89a526730dbc2f7bc840 87 88#------------------------------------------------------------------------------- 89# Generated test values using an IV. 90 91# 47 bytes input 92Cipher = AES-128-CBC-CTS 93CTSMode = CS1 94Key = 636869636b656e207465726979616b69 95IV =000102030405060708090A0B0C0D0E0F 96Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c 97Ciphertext = 5432a630742dee7beb70f9f1400ee6a0b557cfb581949a4bdf3bb67dedd472426da5c54a9990f5ae0b7825f51f0060 98 99# 127 bytes 100Cipher = AES-128-CBC-CTS 101CTSMode = CS1 102Key = 636869636b656e207465726979616b69 103IV = 000102030405060708090A0B0C0D0E0F 104Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c20616e6420776f6e746f6e20736f75702e4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c20616e6420776f6e746f6e20736f7570 105Ciphertext = 5432a630742dee7beb70f9f1400ee6a0b557cfb581949a4bdf3bb67dedd472b9fc50e4e7dacf9e3d94b6cc031f9997a22d2fea7e6ef4aba2b717b0fa3f150e5e86e46b9e51c6ea5091a92aa791ce826b2e4fbaaf0e0314939625434b9530ce56f299891a48d26bdc287f54b230340d652a4721bf0f082ede80b6399800a92f 106 107# 129 bytes 108Cipher = AES-128-CBC-CTS 109CTSMode = CS1 110Key = 636869636b656e207465726979616b69 111IV = 000102030405060708090A0B0C0D0E0F 112Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c20616e6420776f6e746f6e20736f75702e4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c20616e6420776f6e746f6e20736f75702e49 113Ciphertext = 5432a630742dee7beb70f9f1400ee6a0b557cfb581949a4bdf3bb67dedd472b9fc50e4e7dacf9e3d94b6cc031f9997a22d2fea7e6ef4aba2b717b0fa3f150e5e86e46b9e51c6ea5091a92aa791ce826b2e4fbaaf0e0314939625434b9530ce56f299891a48d26bdc287f54b230340d14fde9fd1098b9b1db788b5868a8d009eeef 114 115# 17 Bytes 116Cipher = AES-192-CBC-CTS 117CTSMode = CS1 118Key = 636869636b656e207465726979616b69636869636b656e20 119IV = 000102030405060708090A0B0C0D0E0F 120Plaintext = 4920776f756c64206c696b652074686520 121Ciphertext = e9de1b402de8f79f947cc6b5880588d9b6 122 123# 31 Bytes 124Cipher = AES-192-CBC-CTS 125CTSMode = CS1 126Key = 636869636b656e207465726979616b69636869636b656e20 127IV = 000102030405060708090A0B0C0D0E0F 128Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320 129Ciphertext = e9de17d6248fb492bdea1fb2e09c8edea2b610546f3b1e1d231821e283e153 130 131# 32 Bytes 132Cipher = AES-192-CBC-CTS 133CTSMode = CS1 134Key = 636869636b656e207465726979616b69636869636b656e20 135IV = 000102030405060708090A0B0C0D0E0F 136Plaintext = 4920776f756c64206c696b65207468652047656e6572616c2047617527732043 137Ciphertext = e9de17d6248fb492bdea1fb2e09c8e8e31d005cc9fea948fed1ba6308dad9dd1 138 139#------------------------------------------------------------------------------ 140# Failure test 141 142# 15 bytes should fail for CS1 143Cipher = AES-128-CBC-CTS 144CTSMode = CS1 145Key = 636869636b656e207465726979616b69 146IV = 00000000000000000000000000000000 147Plaintext = 0102030405060708090A0B0C0D0E0F 148Result = CIPHERUPDATE_ERROR 149 150# Original test vectors were taken from https://www.ietf.org/rfc/rfc3962.txt for CS3 151# These have an IV of all zeros, for a 128 bit AES key. 152 153Title = AES CBC CTS2 Test vectors 154 155#------------------------------------------------------ 156# Manually edited using the same inputs to also produce CS2 ciphertext 157# where aligned blocks are the same as CBC mode, and partial lengths 158# are the same as CS3. 159 160# 17 bytes Input (For partial blocks the output should match CS3) 161Cipher = AES-128-CBC-CTS 162CTSMode = CS2 163Key = 636869636b656e207465726979616b69 164IV = 00000000000000000000000000000000 165Plaintext = 4920776f756c64206c696b652074686520 166Ciphertext = c6353568f2bf8cb4d8a580362da7ff7f97 167NextIV = c6353568f2bf8cb4d8a580362da7ff7f 168 169# 31 bytes input (For partial blocks the output should match CS3) 170Cipher = AES-128-CBC-CTS 171CTSMode = CS2 172Key = 636869636b656e207465726979616b69 173IV = 00000000000000000000000000000000 174Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320 175Ciphertext = fc00783e0efdb2c1d445d4c8eff7ed2297687268d6ecccc0c07b25e25ecfe5 176NextIV = fc00783e0efdb2c1d445d4c8eff7ed22 177 178# 32 bytes input (Aligned blocks should match normal CBC mode) 179Cipher = AES-128-CBC-CTS 180CTSMode = CS2 181Key = 636869636b656e207465726979616b69 182IV = 00000000000000000000000000000000 183Plaintext = 4920776f756c64206c696b65207468652047656e6572616c2047617527732043 184Ciphertext = 97687268d6ecccc0c07b25e25ecfe58439312523a78662d5be7fcbcc98ebf5a8 185NextIV = 39312523a78662d5be7fcbcc98ebf5a8 186 187# 47 bytes input 188Cipher = AES-128-CBC-CTS 189CTSMode = CS2 190Key = 636869636b656e207465726979616b69 191IV = 00000000000000000000000000000000 192Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c 193Ciphertext = 97687268d6ecccc0c07b25e25ecfe584b3fffd940c16a18c1b5549d2f838029e39312523a78662d5be7fcbcc98ebf5 194NextIV = b3fffd940c16a18c1b5549d2f838029e 195 196# 64 bytes input (CS2 is equivalent to CBC when the last block in full) 197Cipher = AES-128-CBC-CTS 198CTSMode = CS2 199Key = 636869636b656e207465726979616b69 200IV = 00000000000000000000000000000000 201Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c20616e6420776f6e746f6e20736f75702e 202Ciphertext = 97687268d6ecccc0c07b25e25ecfe58439312523a78662d5be7fcbcc98ebf5a89dad8bbb96c4cdc03bc103e1a194bbd84807efe836ee89a526730dbc2f7bc840 203NextIV = 4807efe836ee89a526730dbc2f7bc840 204 205# Generated test values using an IV. 206 207# 17 Bytes 208Cipher = AES-192-CBC-CTS 209CTSMode = CS2 210Key = 636869636b656e207465726979616b69636869636b656e20 211IV = 000102030405060708090A0B0C0D0E0F 212Plaintext = 4920776f756c64206c696b652074686520 213Ciphertext = de1b402de8f79f947cc6b5880588d9b6e9 214 215# 31 Bytes 216Cipher = AES-192-CBC-CTS 217CTSMode = CS2 218Key = 636869636b656e207465726979616b69636869636b656e20 219IV = 000102030405060708090A0B0C0D0E0F 220Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320 221Ciphertext = dea2b610546f3b1e1d231821e283e153e9de17d6248fb492bdea1fb2e09c8e 222 223# 32 Bytes 224Cipher = AES-192-CBC-CTS 225CTSMode = CS2 226Key = 636869636b656e207465726979616b69636869636b656e20 227IV = 000102030405060708090A0B0C0D0E0F 228Plaintext = 4920776f756c64206c696b65207468652047656e6572616c2047617527732043 229Ciphertext = e9de17d6248fb492bdea1fb2e09c8e8e31d005cc9fea948fed1ba6308dad9dd1 230 231# Failure test - 15 bytes should fail for CS2 232Cipher = AES-128-CBC-CTS 233CTSMode = CS2 234Key = 636869636b656e207465726979616b69 235IV = 00000000000000000000000000000000 236Plaintext = 0102030405060708090A0B0C0D0E0F 237Result = CIPHERUPDATE_ERROR 238 239 240Title = AES CBC CTS3 Test vectors 241 242# 17 bytes Input 243Cipher = AES-128-CBC-CTS 244CTSMode = CS3 245Key = 636869636b656e207465726979616b69 246IV = 00000000000000000000000000000000 247Plaintext = 4920776f756c64206c696b652074686520 248Ciphertext = c6353568f2bf8cb4d8a580362da7ff7f97 249NextIV = c6353568f2bf8cb4d8a580362da7ff7f 250 251# 31 bytes input 252Cipher = AES-128-CBC-CTS 253CTSMode = CS3 254Key = 636869636b656e207465726979616b69 255IV = 00000000000000000000000000000000 256Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320 257Ciphertext = fc00783e0efdb2c1d445d4c8eff7ed2297687268d6ecccc0c07b25e25ecfe5 258NextIV = fc00783e0efdb2c1d445d4c8eff7ed22 259 260# 32 bytes input (CS3 always swaps the last 2 byte blocks - so it is not equivalent to CBC for a full block) 261Cipher = AES-128-CBC-CTS 262CTSMode = CS3 263Key = 636869636b656e207465726979616b69 264IV = 00000000000000000000000000000000 265Plaintext = 4920776f756c64206c696b65207468652047656e6572616c2047617527732043 266Ciphertext = 39312523a78662d5be7fcbcc98ebf5a897687268d6ecccc0c07b25e25ecfe584 267NextIV = 39312523a78662d5be7fcbcc98ebf5a8 268 269# 47 bytes input 270Cipher = AES-128-CBC-CTS 271CTSMode = CS3 272Key = 636869636b656e207465726979616b69 273IV = 00000000000000000000000000000000 274Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c 275Ciphertext = 97687268d6ecccc0c07b25e25ecfe584b3fffd940c16a18c1b5549d2f838029e39312523a78662d5be7fcbcc98ebf5 276NextIV = b3fffd940c16a18c1b5549d2f838029e 277 278# 48 bytes input 279Cipher = AES-128-CBC-CTS 280CTSMode = CS3 281Key = 636869636b656e207465726979616b69 282IV = 00000000000000000000000000000000 283Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c20 284Ciphertext = 97687268d6ecccc0c07b25e25ecfe5849dad8bbb96c4cdc03bc103e1a194bbd839312523a78662d5be7fcbcc98ebf5a8 285NextIV = 9dad8bbb96c4cdc03bc103e1a194bbd8 286 287# 64 bytes input (CS3 always swaps the last 2 byte blocks - so it is not equivalent to CBC for a full block) 288Cipher = AES-128-CBC-CTS 289CTSMode = CS3 290Key = 636869636b656e207465726979616b69 291IV = 00000000000000000000000000000000 292Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c20616e6420776f6e746f6e20736f75702e 293Ciphertext = 97687268d6ecccc0c07b25e25ecfe58439312523a78662d5be7fcbcc98ebf5a84807efe836ee89a526730dbc2f7bc8409dad8bbb96c4cdc03bc103e1a194bbd8 294 295 296# Generated test values using an IV. 297# 47 bytes input 298Cipher = AES-128-CBC-CTS 299CTSMode = CS3 300Key = 636869636b656e207465726979616b69 301IV = 000102030405060708090A0B0C0D0E0F 302Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c 303Ciphertext = 5432a630742dee7beb70f9f1400ee6a0426da5c54a9990f5ae0b7825f51f0060b557cfb581949a4bdf3bb67dedd472 304 305# 17 Bytes 306Cipher = AES-192-CBC-CTS 307CTSMode = CS3 308Key = 636869636b656e207465726979616b69636869636b656e20 309IV =000102030405060708090A0B0C0D0E0F 310Plaintext = 4920776f756c64206c696b652074686520 311Ciphertext = de1b402de8f79f947cc6b5880588d9b6e9 312 313# 31 Bytes 314Cipher = AES-192-CBC-CTS 315CTSMode = CS3 316Key = 636869636b656e207465726979616b69636869636b656e20 317IV = 000102030405060708090A0B0C0D0E0F 318Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320 319Ciphertext = dea2b610546f3b1e1d231821e283e153e9de17d6248fb492bdea1fb2e09c8e 320 321# 32 Bytes 322Cipher = AES-192-CBC-CTS 323CTSMode = CS3 324Key = 636869636b656e207465726979616b69636869636b656e20 325IV = 000102030405060708090A0B0C0D0E0F 326Plaintext = 4920776f756c64206c696b65207468652047656e6572616c2047617527732043 327Ciphertext = 31d005cc9fea948fed1ba6308dad9dd1e9de17d6248fb492bdea1fb2e09c8e8e 328 329# 17 Bytes 330Cipher = AES-256-CBC-CTS 331CTSMode = CS3 332Key = 636869636b656e207465726979616b69636869636b656e207465726979616b69 333IV = 000102030405060708090A0B0C0D0E0F 334Plaintext = 4920776f756c64206c696b652074686520 335Ciphertext = 6b5f5abc21c4d04156c73850da3bba29e9 336 337# 31 Bytes 338Cipher = AES-256-CBC-CTS 339CTSMode = CS3 340Key = 636869636b656e207465726979616b69636869636b656e207465726979616b69 341IV = 000102030405060708090A0B0C0D0E0F 342Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320 343Ciphertext = f22553af78ee4f468f02fbe6f0f2168ee954e79fae9310dc75b6070e1d6253 344 345# 32 Bytes 346Cipher = AES-256-CBC-CTS 347CTSMode = CS3 348Key = 636869636b656e207465726979616b69636869636b656e207465726979616b69 349IV = 000102030405060708090A0B0C0D0E0F 350Plaintext = 4920776f756c64206c696b65207468652047656e6572616c2047617527732043 351Ciphertext = 2c0463982174df10baa9d8f782c5a5b3e954e79fae9310dc75b6070e1d625346 352 353# Failure tests 354# 15 bytes should fail for CS3 355Cipher = AES-128-CBC-CTS 356CTSMode = CS3 357Key = 636869636b656e207465726979616b69 358IV = 00000000000000000000000000000000 359Plaintext = 0102030405060708090A0B0C0D0E0F 360Result = CIPHERUPDATE_ERROR 361 362# 16 bytes input 363Cipher = AES-128-CBC 364Key = 636869636b656e207465726979616b69 365IV = 00000000000000000000000000000000 366Plaintext = 0102030405060708090A0B0C0D0E0F00 367Ciphertext = 011ca8de3bd20ebc2f8701d56dcf768e 368 369# 16 bytes with CS3 should return the same as plain CBC mode. 370Cipher = AES-128-CBC-CTS 371CTSMode = CS1 372Key = 636869636b656e207465726979616b69 373IV = 00000000000000000000000000000000 374Plaintext = 0102030405060708090A0B0C0D0E0F00 375Ciphertext = 011ca8de3bd20ebc2f8701d56dcf768e 376 377Cipher = AES-128-CBC-CTS 378CTSMode = CS2 379Key = 636869636b656e207465726979616b69 380IV = 00000000000000000000000000000000 381Plaintext = 0102030405060708090A0B0C0D0E0F00 382Ciphertext = 011ca8de3bd20ebc2f8701d56dcf768e 383 384Cipher = AES-128-CBC-CTS 385CTSMode = CS3 386Key = 636869636b656e207465726979616b69 387IV = 00000000000000000000000000000000 388Plaintext = 0102030405060708090A0B0C0D0E0F00 389Ciphertext = 011ca8de3bd20ebc2f8701d56dcf768e 390 391