| | | 1 | | using System; |
| | | 2 | | using System.Collections.Generic; |
| | | 3 | | |
| | | 4 | | namespace Renci.SshNet.Security.Chaos.NaCl.Internal |
| | | 5 | | { |
| | | 6 | | // Loops? Arrays? Never heard of that stuff |
| | | 7 | | // Library avoids unnecessary heap allocations and unsafe code |
| | | 8 | | // so this ugly code becomes necessary :( |
| | | 9 | | internal static class ByteIntegerConverter |
| | | 10 | | { |
| | | 11 | | #region Individual |
| | | 12 | | |
| | | 13 | | internal static UInt32 LoadLittleEndian32(byte[] buf, int offset) |
| | 0 | 14 | | { |
| | 0 | 15 | | return |
| | 0 | 16 | | (UInt32)(buf[offset + 0]) |
| | 0 | 17 | | | (((UInt32)(buf[offset + 1])) << 8) |
| | 0 | 18 | | | (((UInt32)(buf[offset + 2])) << 16) |
| | 0 | 19 | | | (((UInt32)(buf[offset + 3])) << 24); |
| | 0 | 20 | | } |
| | | 21 | | |
| | | 22 | | internal static void StoreLittleEndian32(byte[] buf, int offset, UInt32 value) |
| | 0 | 23 | | { |
| | 0 | 24 | | buf[offset + 0] = unchecked((byte)value); |
| | 0 | 25 | | buf[offset + 1] = unchecked((byte)(value >> 8)); |
| | 0 | 26 | | buf[offset + 2] = unchecked((byte)(value >> 16)); |
| | 0 | 27 | | buf[offset + 3] = unchecked((byte)(value >> 24)); |
| | 0 | 28 | | } |
| | | 29 | | |
| | | 30 | | internal static UInt64 LoadBigEndian64(byte[] buf, int offset) |
| | 240 | 31 | | { |
| | 240 | 32 | | return |
| | 240 | 33 | | (UInt64)(buf[offset + 7]) |
| | 240 | 34 | | | (((UInt64)(buf[offset + 6])) << 8) |
| | 240 | 35 | | | (((UInt64)(buf[offset + 5])) << 16) |
| | 240 | 36 | | | (((UInt64)(buf[offset + 4])) << 24) |
| | 240 | 37 | | | (((UInt64)(buf[offset + 3])) << 32) |
| | 240 | 38 | | | (((UInt64)(buf[offset + 2])) << 40) |
| | 240 | 39 | | | (((UInt64)(buf[offset + 1])) << 48) |
| | 240 | 40 | | | (((UInt64)(buf[offset + 0])) << 56); |
| | 240 | 41 | | } |
| | | 42 | | |
| | | 43 | | internal static void StoreBigEndian64(byte[] buf, int offset, UInt64 value) |
| | 104 | 44 | | { |
| | 104 | 45 | | buf[offset + 7] = unchecked((byte)value); |
| | 104 | 46 | | buf[offset + 6] = unchecked((byte)(value >> 8)); |
| | 104 | 47 | | buf[offset + 5] = unchecked((byte)(value >> 16)); |
| | 104 | 48 | | buf[offset + 4] = unchecked((byte)(value >> 24)); |
| | 104 | 49 | | buf[offset + 3] = unchecked((byte)(value >> 32)); |
| | 104 | 50 | | buf[offset + 2] = unchecked((byte)(value >> 40)); |
| | 104 | 51 | | buf[offset + 1] = unchecked((byte)(value >> 48)); |
| | 104 | 52 | | buf[offset + 0] = unchecked((byte)(value >> 56)); |
| | 104 | 53 | | } |
| | | 54 | | |
| | | 55 | | /*internal static void XorLittleEndian32(byte[] buf, int offset, UInt32 value) |
| | | 56 | | { |
| | | 57 | | buf[offset + 0] ^= (byte)value; |
| | | 58 | | buf[offset + 1] ^= (byte)(value >> 8); |
| | | 59 | | buf[offset + 2] ^= (byte)(value >> 16); |
| | | 60 | | buf[offset + 3] ^= (byte)(value >> 24); |
| | | 61 | | }*/ |
| | | 62 | | |
| | | 63 | | /*internal static void XorLittleEndian32(byte[] output, int outputOffset, byte[] input, int inputOffset, UInt32 |
| | | 64 | | { |
| | | 65 | | output[outputOffset + 0] = (byte)(input[inputOffset + 0] ^ value); |
| | | 66 | | output[outputOffset + 1] = (byte)(input[inputOffset + 1] ^ (value >> 8)); |
| | | 67 | | output[outputOffset + 2] = (byte)(input[inputOffset + 2] ^ (value >> 16)); |
| | | 68 | | output[outputOffset + 3] = (byte)(input[inputOffset + 3] ^ (value >> 24)); |
| | | 69 | | }*/ |
| | | 70 | | |
| | | 71 | | #endregion |
| | | 72 | | |
| | | 73 | | #region Array8 |
| | | 74 | | |
| | | 75 | | internal static void Array8LoadLittleEndian32(out Array8<UInt32> output, byte[] input, int inputOffset) |
| | 0 | 76 | | { |
| | 0 | 77 | | output.x0 = LoadLittleEndian32(input, inputOffset + 0); |
| | 0 | 78 | | output.x1 = LoadLittleEndian32(input, inputOffset + 4); |
| | 0 | 79 | | output.x2 = LoadLittleEndian32(input, inputOffset + 8); |
| | 0 | 80 | | output.x3 = LoadLittleEndian32(input, inputOffset + 12); |
| | 0 | 81 | | output.x4 = LoadLittleEndian32(input, inputOffset + 16); |
| | 0 | 82 | | output.x5 = LoadLittleEndian32(input, inputOffset + 20); |
| | 0 | 83 | | output.x6 = LoadLittleEndian32(input, inputOffset + 24); |
| | 0 | 84 | | output.x7 = LoadLittleEndian32(input, inputOffset + 28); |
| | 0 | 85 | | } |
| | | 86 | | |
| | | 87 | | /* internal static void Array8LoadLittleEndian32(out Array8<uint> output, byte[] input, int inputOffset, |
| | | 88 | | { |
| | | 89 | | #if DEBUG |
| | | 90 | | if (inputLength <= 0) |
| | | 91 | | throw new ArgumentException(); |
| | | 92 | | #endif |
| | | 93 | | int inputEnd = inputOffset + inputLength; |
| | | 94 | | UInt32 highestInt; |
| | | 95 | | switch (inputLength & 3) |
| | | 96 | | { |
| | | 97 | | case 1: |
| | | 98 | | highestInt = input[inputEnd - 1]; |
| | | 99 | | break; |
| | | 100 | | case 2: |
| | | 101 | | highestInt = (uint)( |
| | | 102 | | (input[inputEnd - 1] << 8) | |
| | | 103 | | (input[inputEnd - 2])); |
| | | 104 | | break; |
| | | 105 | | case 3: |
| | | 106 | | highestInt = (uint)( |
| | | 107 | | (input[inputEnd - 1] << 16) | |
| | | 108 | | (input[inputEnd - 2] << 8) | |
| | | 109 | | (input[inputEnd - 3])); |
| | | 110 | | break; |
| | | 111 | | case 0: |
| | | 112 | | highestInt = (uint)( |
| | | 113 | | (input[inputEnd - 1] << 24) | |
| | | 114 | | (input[inputEnd - 2] << 16) | |
| | | 115 | | (input[inputEnd - 3] << 8) | |
| | | 116 | | (input[inputEnd - 4])); |
| | | 117 | | break; |
| | | 118 | | default: |
| | | 119 | | throw new InvalidOperationException(); |
| | | 120 | | } |
| | | 121 | | switch ((inputLength - 1) >> 2) |
| | | 122 | | { |
| | | 123 | | case 7: |
| | | 124 | | output.x7 = highestInt; |
| | | 125 | | output.x6 = LoadLittleEndian32(input, inputOffset + 6 * 4); |
| | | 126 | | output.x5 = LoadLittleEndian32(input, inputOffset + 5 * 4); |
| | | 127 | | output.x4 = LoadLittleEndian32(input, inputOffset + 4 * 4); |
| | | 128 | | output.x3 = LoadLittleEndian32(input, inputOffset + 3 * 4); |
| | | 129 | | output.x2 = LoadLittleEndian32(input, inputOffset + 2 * 4); |
| | | 130 | | output.x1 = LoadLittleEndian32(input, inputOffset + 1 * 4); |
| | | 131 | | output.x0 = LoadLittleEndian32(input, inputOffset + 0 * 4); |
| | | 132 | | return; |
| | | 133 | | case 6: |
| | | 134 | | output.x7 = 0; |
| | | 135 | | output.x6 = highestInt; |
| | | 136 | | output.x5 = LoadLittleEndian32(input, inputOffset + 5 * 4); |
| | | 137 | | output.x4 = LoadLittleEndian32(input, inputOffset + 4 * 4); |
| | | 138 | | output.x3 = LoadLittleEndian32(input, inputOffset + 3 * 4); |
| | | 139 | | output.x2 = LoadLittleEndian32(input, inputOffset + 2 * 4); |
| | | 140 | | output.x1 = LoadLittleEndian32(input, inputOffset + 1 * 4); |
| | | 141 | | output.x0 = LoadLittleEndian32(input, inputOffset + 0 * 4); |
| | | 142 | | return; |
| | | 143 | | case 5: |
| | | 144 | | output.x7 = 0; |
| | | 145 | | output.x6 = 0; |
| | | 146 | | output.x5 = highestInt; |
| | | 147 | | output.x4 = LoadLittleEndian32(input, inputOffset + 4 * 4); |
| | | 148 | | output.x3 = LoadLittleEndian32(input, inputOffset + 3 * 4); |
| | | 149 | | output.x2 = LoadLittleEndian32(input, inputOffset + 2 * 4); |
| | | 150 | | output.x1 = LoadLittleEndian32(input, inputOffset + 1 * 4); |
| | | 151 | | output.x0 = LoadLittleEndian32(input, inputOffset + 0 * 4); |
| | | 152 | | return; |
| | | 153 | | case 4: |
| | | 154 | | output.x7 = 0; |
| | | 155 | | output.x6 = 0; |
| | | 156 | | output.x5 = 0; |
| | | 157 | | output.x4 = highestInt; |
| | | 158 | | output.x3 = LoadLittleEndian32(input, inputOffset + 3 * 4); |
| | | 159 | | output.x2 = LoadLittleEndian32(input, inputOffset + 2 * 4); |
| | | 160 | | output.x1 = LoadLittleEndian32(input, inputOffset + 1 * 4); |
| | | 161 | | output.x0 = LoadLittleEndian32(input, inputOffset + 0 * 4); |
| | | 162 | | return; |
| | | 163 | | case 3: |
| | | 164 | | output.x7 = 0; |
| | | 165 | | output.x6 = 0; |
| | | 166 | | output.x5 = 0; |
| | | 167 | | output.x4 = 0; |
| | | 168 | | output.x3 = highestInt; |
| | | 169 | | output.x2 = LoadLittleEndian32(input, inputOffset + 2 * 4); |
| | | 170 | | output.x1 = LoadLittleEndian32(input, inputOffset + 1 * 4); |
| | | 171 | | output.x0 = LoadLittleEndian32(input, inputOffset + 0 * 4); |
| | | 172 | | return; |
| | | 173 | | case 2: |
| | | 174 | | output.x7 = 0; |
| | | 175 | | output.x6 = 0; |
| | | 176 | | output.x5 = 0; |
| | | 177 | | output.x4 = 0; |
| | | 178 | | output.x3 = 0; |
| | | 179 | | output.x2 = highestInt; |
| | | 180 | | output.x1 = LoadLittleEndian32(input, inputOffset + 1 * 4); |
| | | 181 | | output.x0 = LoadLittleEndian32(input, inputOffset + 0 * 4); |
| | | 182 | | return; |
| | | 183 | | case 1: |
| | | 184 | | output.x7 = 0; |
| | | 185 | | output.x6 = 0; |
| | | 186 | | output.x5 = 0; |
| | | 187 | | output.x4 = 0; |
| | | 188 | | output.x3 = 0; |
| | | 189 | | output.x2 = 0; |
| | | 190 | | output.x1 = highestInt; |
| | | 191 | | output.x0 = LoadLittleEndian32(input, inputOffset + 0 * 4); |
| | | 192 | | return; |
| | | 193 | | case 0: |
| | | 194 | | output.x7 = 0; |
| | | 195 | | output.x6 = 0; |
| | | 196 | | output.x5 = 0; |
| | | 197 | | output.x4 = 0; |
| | | 198 | | output.x3 = 0; |
| | | 199 | | output.x2 = 0; |
| | | 200 | | output.x1 = 0; |
| | | 201 | | output.x0 = highestInt; |
| | | 202 | | return; |
| | | 203 | | default: |
| | | 204 | | throw new InvalidOperationException(); |
| | | 205 | | } |
| | | 206 | | }*/ |
| | | 207 | | |
| | | 208 | | /*internal static void Array8XorLittleEndian(byte[] output, int outputOffset, byte[] input, int inputOffset, ref |
| | | 209 | | { |
| | | 210 | | #if DEBUG |
| | | 211 | | InternalAssert(length > 0); |
| | | 212 | | #endif |
| | | 213 | | int outputEnd = outputOffset + length; |
| | | 214 | | UInt32 highestInt; |
| | | 215 | | switch ((length - 1) >> 2) |
| | | 216 | | { |
| | | 217 | | case 7: |
| | | 218 | | highestInt = keyStream.x7; |
| | | 219 | | XorLittleEndian32(output, outputOffset + 6 * 4, input, inputOffset + 6 * 4, keyStream.x6); |
| | | 220 | | XorLittleEndian32(output, outputOffset + 5 * 4, input, inputOffset + 6 * 4, keyStream.x5); |
| | | 221 | | XorLittleEndian32(output, outputOffset + 4 * 4, input, inputOffset + 6 * 4, keyStream.x4); |
| | | 222 | | XorLittleEndian32(output, outputOffset + 3 * 4, input, inputOffset + 6 * 4, keyStream.x3); |
| | | 223 | | XorLittleEndian32(output, outputOffset + 2 * 4, input, inputOffset + 6 * 4, keyStream.x2); |
| | | 224 | | XorLittleEndian32(output, outputOffset + 1 * 4, input, inputOffset + 6 * 4, keyStream.x1); |
| | | 225 | | XorLittleEndian32(output, outputOffset + 0 * 4, input, inputOffset + 6 * 4, keyStream.x0); |
| | | 226 | | break; |
| | | 227 | | case 6: |
| | | 228 | | highestInt = keyStream.x6; |
| | | 229 | | XorLittleEndian32(output, outputOffset + 5 * 4, input, inputOffset + 6 * 4, keyStream.x5); |
| | | 230 | | XorLittleEndian32(output, outputOffset + 4 * 4, input, inputOffset + 6 * 4, keyStream.x4); |
| | | 231 | | XorLittleEndian32(output, outputOffset + 3 * 4, input, inputOffset + 6 * 4, keyStream.x3); |
| | | 232 | | XorLittleEndian32(output, outputOffset + 2 * 4, input, inputOffset + 6 * 4, keyStream.x2); |
| | | 233 | | XorLittleEndian32(output, outputOffset + 1 * 4, input, inputOffset + 6 * 4, keyStream.x1); |
| | | 234 | | XorLittleEndian32(output, outputOffset + 0 * 4, input, inputOffset + 6 * 4, keyStream.x0); |
| | | 235 | | break; |
| | | 236 | | case 5: |
| | | 237 | | highestInt = keyStream.x5; |
| | | 238 | | XorLittleEndian32(output, outputOffset + 4 * 4, input, inputOffset + 6 * 4, keyStream.x4); |
| | | 239 | | XorLittleEndian32(output, outputOffset + 3 * 4, input, inputOffset + 6 * 4, keyStream.x3); |
| | | 240 | | XorLittleEndian32(output, outputOffset + 2 * 4, input, inputOffset + 6 * 4, keyStream.x2); |
| | | 241 | | XorLittleEndian32(output, outputOffset + 1 * 4, input, inputOffset + 6 * 4, keyStream.x1); |
| | | 242 | | XorLittleEndian32(output, outputOffset + 0 * 4, input, inputOffset + 6 * 4, keyStream.x0); |
| | | 243 | | break; |
| | | 244 | | case 4: |
| | | 245 | | highestInt = keyStream.x4; |
| | | 246 | | XorLittleEndian32(output, outputOffset + 3 * 4, input, inputOffset + 6 * 4, keyStream.x3); |
| | | 247 | | XorLittleEndian32(output, outputOffset + 2 * 4, input, inputOffset + 6 * 4, keyStream.x2); |
| | | 248 | | XorLittleEndian32(output, outputOffset + 1 * 4, input, inputOffset + 6 * 4, keyStream.x1); |
| | | 249 | | XorLittleEndian32(output, outputOffset + 0 * 4, input, inputOffset + 6 * 4, keyStream.x0); |
| | | 250 | | break; |
| | | 251 | | case 3: |
| | | 252 | | highestInt = keyStream.x3; |
| | | 253 | | XorLittleEndian32(output, outputOffset + 2 * 4, input, inputOffset + 6 * 4, keyStream.x2); |
| | | 254 | | XorLittleEndian32(output, outputOffset + 1 * 4, input, inputOffset + 6 * 4, keyStream.x1); |
| | | 255 | | XorLittleEndian32(output, outputOffset + 0 * 4, input, inputOffset + 6 * 4, keyStream.x0); |
| | | 256 | | break; |
| | | 257 | | case 2: |
| | | 258 | | highestInt = keyStream.x2; |
| | | 259 | | XorLittleEndian32(output, outputOffset + 1 * 4, input, inputOffset + 6 * 4, keyStream.x1); |
| | | 260 | | XorLittleEndian32(output, outputOffset + 0 * 4, input, inputOffset + 6 * 4, keyStream.x0); |
| | | 261 | | break; |
| | | 262 | | case 1: |
| | | 263 | | highestInt = keyStream.x1; |
| | | 264 | | XorLittleEndian32(output, outputOffset + 0 * 4, input, inputOffset + 6 * 4, keyStream.x0); |
| | | 265 | | break; |
| | | 266 | | case 0: |
| | | 267 | | highestInt = keyStream.x0; |
| | | 268 | | break; |
| | | 269 | | default: |
| | | 270 | | throw new InvalidOperationException(); |
| | | 271 | | } |
| | | 272 | | switch (length & 3) |
| | | 273 | | { |
| | | 274 | | case 1: |
| | | 275 | | output[outputEnd - 1] ^= (byte)highestInt; |
| | | 276 | | break; |
| | | 277 | | case 2: |
| | | 278 | | output[outputEnd - 1] ^= (byte)(highestInt >> 8); |
| | | 279 | | output[outputEnd - 2] ^= (byte)highestInt; |
| | | 280 | | break; |
| | | 281 | | case 3: |
| | | 282 | | output[outputEnd - 1] ^= (byte)(highestInt >> 16); |
| | | 283 | | output[outputEnd - 2] ^= (byte)(highestInt >> 8); |
| | | 284 | | output[outputEnd - 3] ^= (byte)highestInt; |
| | | 285 | | break; |
| | | 286 | | case 0: |
| | | 287 | | output[outputEnd - 1] ^= (byte)(highestInt >> 24); |
| | | 288 | | output[outputEnd - 2] ^= (byte)(highestInt >> 16); |
| | | 289 | | output[outputEnd - 3] ^= (byte)(highestInt >> 8); |
| | | 290 | | output[outputEnd - 4] ^= (byte)highestInt; |
| | | 291 | | break; |
| | | 292 | | default: |
| | | 293 | | throw new InvalidOperationException(); |
| | | 294 | | } |
| | | 295 | | }*/ |
| | | 296 | | |
| | | 297 | | /*internal static void Array8StoreLittleEndian32(byte[] output, int outputOffset, ref Array8<uint> input) |
| | | 298 | | { |
| | | 299 | | StoreLittleEndian32(output, outputOffset + 0, input.x0); |
| | | 300 | | StoreLittleEndian32(output, outputOffset + 4, input.x1); |
| | | 301 | | StoreLittleEndian32(output, outputOffset + 8, input.x2); |
| | | 302 | | StoreLittleEndian32(output, outputOffset + 12, input.x3); |
| | | 303 | | StoreLittleEndian32(output, outputOffset + 16, input.x4); |
| | | 304 | | StoreLittleEndian32(output, outputOffset + 20, input.x5); |
| | | 305 | | StoreLittleEndian32(output, outputOffset + 24, input.x6); |
| | | 306 | | StoreLittleEndian32(output, outputOffset + 28, input.x7); |
| | | 307 | | }*/ |
| | | 308 | | #endregion |
| | | 309 | | |
| | | 310 | | internal static void Array16LoadBigEndian64(out Array16<UInt64> output, byte[] input, int inputOffset) |
| | 15 | 311 | | { |
| | 15 | 312 | | output.x0 = LoadBigEndian64(input, inputOffset + 0); |
| | 15 | 313 | | output.x1 = LoadBigEndian64(input, inputOffset + 8); |
| | 15 | 314 | | output.x2 = LoadBigEndian64(input, inputOffset + 16); |
| | 15 | 315 | | output.x3 = LoadBigEndian64(input, inputOffset + 24); |
| | 15 | 316 | | output.x4 = LoadBigEndian64(input, inputOffset + 32); |
| | 15 | 317 | | output.x5 = LoadBigEndian64(input, inputOffset + 40); |
| | 15 | 318 | | output.x6 = LoadBigEndian64(input, inputOffset + 48); |
| | 15 | 319 | | output.x7 = LoadBigEndian64(input, inputOffset + 56); |
| | 15 | 320 | | output.x8 = LoadBigEndian64(input, inputOffset + 64); |
| | 15 | 321 | | output.x9 = LoadBigEndian64(input, inputOffset + 72); |
| | 15 | 322 | | output.x10 = LoadBigEndian64(input, inputOffset + 80); |
| | 15 | 323 | | output.x11 = LoadBigEndian64(input, inputOffset + 88); |
| | 15 | 324 | | output.x12 = LoadBigEndian64(input, inputOffset + 96); |
| | 15 | 325 | | output.x13 = LoadBigEndian64(input, inputOffset + 104); |
| | 15 | 326 | | output.x14 = LoadBigEndian64(input, inputOffset + 112); |
| | 15 | 327 | | output.x15 = LoadBigEndian64(input, inputOffset + 120); |
| | 15 | 328 | | } |
| | | 329 | | |
| | | 330 | | // ToDo: Only used in tests. Remove? |
| | | 331 | | internal static void Array16LoadLittleEndian32(out Array16<UInt32> output, byte[] input, int inputOffset) |
| | 0 | 332 | | { |
| | 0 | 333 | | output.x0 = LoadLittleEndian32(input, inputOffset + 0); |
| | 0 | 334 | | output.x1 = LoadLittleEndian32(input, inputOffset + 4); |
| | 0 | 335 | | output.x2 = LoadLittleEndian32(input, inputOffset + 8); |
| | 0 | 336 | | output.x3 = LoadLittleEndian32(input, inputOffset + 12); |
| | 0 | 337 | | output.x4 = LoadLittleEndian32(input, inputOffset + 16); |
| | 0 | 338 | | output.x5 = LoadLittleEndian32(input, inputOffset + 20); |
| | 0 | 339 | | output.x6 = LoadLittleEndian32(input, inputOffset + 24); |
| | 0 | 340 | | output.x7 = LoadLittleEndian32(input, inputOffset + 28); |
| | 0 | 341 | | output.x8 = LoadLittleEndian32(input, inputOffset + 32); |
| | 0 | 342 | | output.x9 = LoadLittleEndian32(input, inputOffset + 36); |
| | 0 | 343 | | output.x10 = LoadLittleEndian32(input, inputOffset + 40); |
| | 0 | 344 | | output.x11 = LoadLittleEndian32(input, inputOffset + 44); |
| | 0 | 345 | | output.x12 = LoadLittleEndian32(input, inputOffset + 48); |
| | 0 | 346 | | output.x13 = LoadLittleEndian32(input, inputOffset + 52); |
| | 0 | 347 | | output.x14 = LoadLittleEndian32(input, inputOffset + 56); |
| | 0 | 348 | | output.x15 = LoadLittleEndian32(input, inputOffset + 60); |
| | 0 | 349 | | } |
| | | 350 | | |
| | | 351 | | /*internal static void Array16LoadLittleEndian32(out Array16<UInt32> output, byte[] input, int inputOffset, int |
| | | 352 | | { |
| | | 353 | | Array8<UInt32> temp; |
| | | 354 | | if (inputLength > 32) |
| | | 355 | | { |
| | | 356 | | output.x0 = LoadLittleEndian32(input, inputOffset + 0); |
| | | 357 | | output.x1 = LoadLittleEndian32(input, inputOffset + 4); |
| | | 358 | | output.x2 = LoadLittleEndian32(input, inputOffset + 8); |
| | | 359 | | output.x3 = LoadLittleEndian32(input, inputOffset + 12); |
| | | 360 | | output.x4 = LoadLittleEndian32(input, inputOffset + 16); |
| | | 361 | | output.x5 = LoadLittleEndian32(input, inputOffset + 20); |
| | | 362 | | output.x6 = LoadLittleEndian32(input, inputOffset + 24); |
| | | 363 | | output.x7 = LoadLittleEndian32(input, inputOffset + 28); |
| | | 364 | | Array8LoadLittleEndian32(out temp, input, inputOffset + 32, inputLength - 32); |
| | | 365 | | output.x8 = temp.x0; |
| | | 366 | | output.x9 = temp.x1; |
| | | 367 | | output.x10 = temp.x2; |
| | | 368 | | output.x11 = temp.x3; |
| | | 369 | | output.x12 = temp.x4; |
| | | 370 | | output.x13 = temp.x5; |
| | | 371 | | output.x14 = temp.x6; |
| | | 372 | | output.x15 = temp.x7; |
| | | 373 | | } |
| | | 374 | | else |
| | | 375 | | { |
| | | 376 | | Array8LoadLittleEndian32(out temp, input, inputOffset, inputLength); |
| | | 377 | | output.x0 = temp.x0; |
| | | 378 | | output.x1 = temp.x1; |
| | | 379 | | output.x2 = temp.x2; |
| | | 380 | | output.x3 = temp.x3; |
| | | 381 | | output.x4 = temp.x4; |
| | | 382 | | output.x5 = temp.x5; |
| | | 383 | | output.x6 = temp.x6; |
| | | 384 | | output.x7 = temp.x7; |
| | | 385 | | output.x8 = 0; |
| | | 386 | | output.x9 = 0; |
| | | 387 | | output.x10 = 0; |
| | | 388 | | output.x11 = 0; |
| | | 389 | | output.x12 = 0; |
| | | 390 | | output.x13 = 0; |
| | | 391 | | output.x14 = 0; |
| | | 392 | | output.x15 = 0; |
| | | 393 | | } |
| | | 394 | | }*/ |
| | | 395 | | |
| | | 396 | | internal static void Array16StoreLittleEndian32(byte[] output, int outputOffset, ref Array16<UInt32> input) |
| | 0 | 397 | | { |
| | 0 | 398 | | StoreLittleEndian32(output, outputOffset + 0, input.x0); |
| | 0 | 399 | | StoreLittleEndian32(output, outputOffset + 4, input.x1); |
| | 0 | 400 | | StoreLittleEndian32(output, outputOffset + 8, input.x2); |
| | 0 | 401 | | StoreLittleEndian32(output, outputOffset + 12, input.x3); |
| | 0 | 402 | | StoreLittleEndian32(output, outputOffset + 16, input.x4); |
| | 0 | 403 | | StoreLittleEndian32(output, outputOffset + 20, input.x5); |
| | 0 | 404 | | StoreLittleEndian32(output, outputOffset + 24, input.x6); |
| | 0 | 405 | | StoreLittleEndian32(output, outputOffset + 28, input.x7); |
| | 0 | 406 | | StoreLittleEndian32(output, outputOffset + 32, input.x8); |
| | 0 | 407 | | StoreLittleEndian32(output, outputOffset + 36, input.x9); |
| | 0 | 408 | | StoreLittleEndian32(output, outputOffset + 40, input.x10); |
| | 0 | 409 | | StoreLittleEndian32(output, outputOffset + 44, input.x11); |
| | 0 | 410 | | StoreLittleEndian32(output, outputOffset + 48, input.x12); |
| | 0 | 411 | | StoreLittleEndian32(output, outputOffset + 52, input.x13); |
| | 0 | 412 | | StoreLittleEndian32(output, outputOffset + 56, input.x14); |
| | 0 | 413 | | StoreLittleEndian32(output, outputOffset + 60, input.x15); |
| | 0 | 414 | | } |
| | | 415 | | } |
| | | 416 | | } |