| 1 |
/* Microsoft Reference Implementation for TPM 2.0 |
| 2 |
* |
| 3 |
* The copyright in this software is being made available under the BSD License, |
| 4 |
* included below. This software may be subject to other third party and |
| 5 |
* contributor rights, including patent rights, and no such rights are granted |
| 6 |
* under this license. |
| 7 |
* |
| 8 |
* Copyright (c) Microsoft Corporation |
| 9 |
* |
| 10 |
* All rights reserved. |
| 11 |
* |
| 12 |
* BSD License |
| 13 |
* |
| 14 |
* Redistribution and use in source and binary forms, with or without modification, |
| 15 |
* are permitted provided that the following conditions are met: |
| 16 |
* |
| 17 |
* Redistributions of source code must retain the above copyright notice, this list |
| 18 |
* of conditions and the following disclaimer. |
| 19 |
* |
| 20 |
* Redistributions in binary form must reproduce the above copyright notice, this |
| 21 |
* list of conditions and the following disclaimer in the documentation and/or |
| 22 |
* other materials provided with the distribution. |
| 23 |
* |
| 24 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS"" |
| 25 |
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 26 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 27 |
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
| 28 |
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 29 |
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 30 |
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
| 31 |
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 32 |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 33 |
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 34 |
*/ |
| 35 |
// This is a vector for testing either encrypt or decrypt. The premise for decrypt |
| 36 |
// is that the IV for decryption is the same as the IV for encryption. However, |
| 37 |
// the ivOut value may be different for encryption and decryption. We will encrypt |
| 38 |
// at least two blocks. This means that the chaining value will be used for each |
| 39 |
// of the schemes (if any) and that implicitly checks that the chaining value |
| 40 |
// is handled properly. |
| 41 |
|
| 42 |
|
| 43 |
#if AES_128 |
| 44 |
|
| 45 |
const BYTE key_AES128 [] = { |
| 46 |
0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, |
| 47 |
0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c}; |
| 48 |
|
| 49 |
const BYTE dataIn_AES128 [] = { |
| 50 |
0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, |
| 51 |
0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, |
| 52 |
0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, |
| 53 |
0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51}; |
| 54 |
|
| 55 |
|
| 56 |
const BYTE dataOut_AES128_ECB [] = { |
| 57 |
0x3a, 0xd7, 0x7b, 0xb4, 0x0d, 0x7a, 0x36, 0x60, |
| 58 |
0xa8, 0x9e, 0xca, 0xf3, 0x24, 0x66, 0xef, 0x97, |
| 59 |
0xf5, 0xd3, 0xd5, 0x85, 0x03, 0xb9, 0x69, 0x9d, |
| 60 |
0xe7, 0x85, 0x89, 0x5a, 0x96, 0xfd, 0xba, 0xaf}; |
| 61 |
|
| 62 |
const BYTE dataOut_AES128_CBC [] = { |
| 63 |
0x76, 0x49, 0xab, 0xac, 0x81, 0x19, 0xb2, 0x46, |
| 64 |
0xce, 0xe9, 0x8e, 0x9b, 0x12, 0xe9, 0x19, 0x7d, |
| 65 |
0x50, 0x86, 0xcb, 0x9b, 0x50, 0x72, 0x19, 0xee, |
| 66 |
0x95, 0xdb, 0x11, 0x3a, 0x91, 0x76, 0x78, 0xb2}; |
| 67 |
|
| 68 |
const BYTE dataOut_AES128_CFB [] = { |
| 69 |
0x3b, 0x3f, 0xd9, 0x2e, 0xb7, 0x2d, 0xad, 0x20, |
| 70 |
0x33, 0x34, 0x49, 0xf8, 0xe8, 0x3c, 0xfb, 0x4a, |
| 71 |
0xc8, 0xa6, 0x45, 0x37, 0xa0, 0xb3, 0xa9, 0x3f, |
| 72 |
0xcd, 0xe3, 0xcd, 0xad, 0x9f, 0x1c, 0xe5, 0x8b}; |
| 73 |
|
| 74 |
const BYTE dataOut_AES128_OFB [] = { |
| 75 |
0x3b, 0x3f, 0xd9, 0x2e, 0xb7, 0x2d, 0xad, 0x20, |
| 76 |
0x33, 0x34, 0x49, 0xf8, 0xe8, 0x3c, 0xfb, 0x4a, |
| 77 |
0x77, 0x89, 0x50, 0x8d, 0x16, 0x91, 0x8f, 0x03, |
| 78 |
0xf5, 0x3c, 0x52, 0xda, 0xc5, 0x4e, 0xd8, 0x25}; |
| 79 |
|
| 80 |
|
| 81 |
const BYTE dataOut_AES128_CTR [] = { |
| 82 |
0x87, 0x4d, 0x61, 0x91, 0xb6, 0x20, 0xe3, 0x26, |
| 83 |
0x1b, 0xef, 0x68, 0x64, 0x99, 0x0d, 0xb6, 0xce, |
| 84 |
0x98, 0x06, 0xf6, 0x6b, 0x79, 0x70, 0xfd, 0xff, |
| 85 |
0x86, 0x17, 0x18, 0x7b, 0xb9, 0xff, 0xfd, 0xff}; |
| 86 |
#endif |
| 87 |
|
| 88 |
#if AES_192 |
| 89 |
|
| 90 |
const BYTE key_AES192 [] = { |
| 91 |
0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52, |
| 92 |
0xc8, 0x10, 0xf3, 0x2b, 0x80, 0x90, 0x79, 0xe5, |
| 93 |
0x62, 0xf8, 0xea, 0xd2, 0x52, 0x2c, 0x6b, 0x7b}; |
| 94 |
|
| 95 |
const BYTE dataIn_AES192 [] = { |
| 96 |
0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, |
| 97 |
0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, |
| 98 |
0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, |
| 99 |
0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51}; |
| 100 |
|
| 101 |
const BYTE dataOut_AES192_ECB [] = { |
| 102 |
0xbd, 0x33, 0x4f, 0x1d, 0x6e, 0x45, 0xf2, 0x5f, |
| 103 |
0xf7, 0x12, 0xa2, 0x14, 0x57, 0x1f, 0xa5, 0xcc, |
| 104 |
0x97, 0x41, 0x04, 0x84, 0x6d, 0x0a, 0xd3, 0xad, |
| 105 |
0x77, 0x34, 0xec, 0xb3, 0xec, 0xee, 0x4e, 0xef}; |
| 106 |
|
| 107 |
const BYTE dataOut_AES192_CBC [] = { |
| 108 |
0x4f, 0x02, 0x1d, 0xb2, 0x43, 0xbc, 0x63, 0x3d, |
| 109 |
0x71, 0x78, 0x18, 0x3a, 0x9f, 0xa0, 0x71, 0xe8, |
| 110 |
0xb4, 0xd9, 0xad, 0xa9, 0xad, 0x7d, 0xed, 0xf4, |
| 111 |
0xe5, 0xe7, 0x38, 0x76, 0x3f, 0x69, 0x14, 0x5a}; |
| 112 |
|
| 113 |
const BYTE dataOut_AES192_CFB [] = { |
| 114 |
0xcd, 0xc8, 0x0d, 0x6f, 0xdd, 0xf1, 0x8c, 0xab, |
| 115 |
0x34, 0xc2, 0x59, 0x09, 0xc9, 0x9a, 0x41, 0x74, |
| 116 |
0x67, 0xce, 0x7f, 0x7f, 0x81, 0x17, 0x36, 0x21, |
| 117 |
0x96, 0x1a, 0x2b, 0x70, 0x17, 0x1d, 0x3d, 0x7a}; |
| 118 |
|
| 119 |
const BYTE dataOut_AES192_OFB [] = { |
| 120 |
0xcd, 0xc8, 0x0d, 0x6f, 0xdd, 0xf1, 0x8c, 0xab, |
| 121 |
0x34, 0xc2, 0x59, 0x09, 0xc9, 0x9a, 0x41, 0x74, |
| 122 |
0xfc, 0xc2, 0x8b, 0x8d, 0x4c, 0x63, 0x83, 0x7c, |
| 123 |
0x09, 0xe8, 0x17, 0x00, 0xc1, 0x10, 0x04, 0x01}; |
| 124 |
|
| 125 |
const BYTE dataOut_AES192_CTR [] = { |
| 126 |
0x1a, 0xbc, 0x93, 0x24, 0x17, 0x52, 0x1c, 0xa2, |
| 127 |
0x4f, 0x2b, 0x04, 0x59, 0xfe, 0x7e, 0x6e, 0x0b, |
| 128 |
0x09, 0x03, 0x39, 0xec, 0x0a, 0xa6, 0xfa, 0xef, |
| 129 |
0xd5, 0xcc, 0xc2, 0xc6, 0xf4, 0xce, 0x8e, 0x94}; |
| 130 |
#endif |
| 131 |
|
| 132 |
#if AES_256 |
| 133 |
|
| 134 |
const BYTE key_AES256 [] = { |
| 135 |
0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe, |
| 136 |
0x2b, 0x73, 0xae, 0xf0, 0x85, 0x7d, 0x77, 0x81, |
| 137 |
0x1f, 0x35, 0x2c, 0x07, 0x3b, 0x61, 0x08, 0xd7, |
| 138 |
0x2d, 0x98, 0x10, 0xa3, 0x09, 0x14, 0xdf, 0xf4}; |
| 139 |
|
| 140 |
const BYTE dataIn_AES256 [] = { |
| 141 |
0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, |
| 142 |
0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, |
| 143 |
0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, |
| 144 |
0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51}; |
| 145 |
|
| 146 |
const BYTE dataOut_AES256_ECB [] = { |
| 147 |
0xf3, 0xee, 0xd1, 0xbd, 0xb5, 0xd2, 0xa0, 0x3c, |
| 148 |
0x06, 0x4b, 0x5a, 0x7e, 0x3d, 0xb1, 0x81, 0xf8, |
| 149 |
0x59, 0x1c, 0xcb, 0x10, 0xd4, 0x10, 0xed, 0x26, |
| 150 |
0xdc, 0x5b, 0xa7, 0x4a, 0x31, 0x36, 0x28, 0x70}; |
| 151 |
|
| 152 |
const BYTE dataOut_AES256_CBC [] = { |
| 153 |
0xf5, 0x8c, 0x4c, 0x04, 0xd6, 0xe5, 0xf1, 0xba, |
| 154 |
0x77, 0x9e, 0xab, 0xfb, 0x5f, 0x7b, 0xfb, 0xd6, |
| 155 |
0x9c, 0xfc, 0x4e, 0x96, 0x7e, 0xdb, 0x80, 0x8d, |
| 156 |
0x67, 0x9f, 0x77, 0x7b, 0xc6, 0x70, 0x2c, 0x7d}; |
| 157 |
|
| 158 |
const BYTE dataOut_AES256_CFB [] = { |
| 159 |
0xdc, 0x7e, 0x84, 0xbf, 0xda, 0x79, 0x16, 0x4b, |
| 160 |
0x7e, 0xcd, 0x84, 0x86, 0x98, 0x5d, 0x38, 0x60, |
| 161 |
0x39, 0xff, 0xed, 0x14, 0x3b, 0x28, 0xb1, 0xc8, |
| 162 |
0x32, 0x11, 0x3c, 0x63, 0x31, 0xe5, 0x40, 0x7b}; |
| 163 |
|
| 164 |
const BYTE dataOut_AES256_OFB [] = { |
| 165 |
0xdc, 0x7e, 0x84, 0xbf, 0xda, 0x79, 0x16, 0x4b, |
| 166 |
0x7e, 0xcd, 0x84, 0x86, 0x98, 0x5d, 0x38, 0x60, |
| 167 |
0x4f, 0xeb, 0xdc, 0x67, 0x40, 0xd2, 0x0b, 0x3a, |
| 168 |
0xc8, 0x8f, 0x6a, 0xd8, 0x2a, 0x4f, 0xb0, 0x8d}; |
| 169 |
|
| 170 |
const BYTE dataOut_AES256_CTR [] = { |
| 171 |
0x60, 0x1e, 0xc3, 0x13, 0x77, 0x57, 0x89, 0xa5, |
| 172 |
0xb7, 0xa7, 0xf5, 0x04, 0xbb, 0xf3, 0xd2, 0x28, |
| 173 |
0xf4, 0x43, 0xe3, 0xca, 0x4d, 0x62, 0xb5, 0x9a, |
| 174 |
0xca, 0x84, 0xe9, 0x90, 0xca, 0xca, 0xf5, 0xc5}; |
| 175 |
#endif |
| 176 |
|
| 177 |
|
| 178 |
|