Salsa20 test vectors
1 __gshared immutable immutable(char)[][] test_keys = [ 2 "80000000000000000000000000000000", 3 "0053a6f94c9ff24598eb3e91e4378add", 4 "00002000000000000000000000000000"~ 5 "00000000000000000000000000000000", 6 "0f62b5085bae0154a7fa4da0f34699ec"~ 7 "3f92e5388bde3184d72a7dd02376c91c" 8 9 ]; 10 11 __gshared immutable immutable(char)[][] test_ivs = [ 12 "0000000000000000", 13 "0d74db42a91077de", 14 "0000000000000000", 15 "288ff65dc42b92f9" 16 ]; 17 18 __gshared immutable immutable(char)[][] test_plaintexts = [ 19 "00000000000000000000000000000000"~ 20 "00000000000000000000000000000000"~ 21 "00000000000000000000000000000000"~ 22 "00000000000000000000000000000000", 23 24 "00000000000000000000000000000000"~ 25 "00000000000000000000000000000000"~ 26 "00000000000000000000000000000000"~ 27 "00000000000000000000000000000000", 28 29 "00000000000000000000000000000000"~ 30 "00000000000000000000000000000000"~ 31 "00000000000000000000000000000000"~ 32 "00000000000000000000000000000000", 33 34 "00000000000000000000000000000000"~ 35 "00000000000000000000000000000000"~ 36 "00000000000000000000000000000000"~ 37 "00000000000000000000000000000000" 38 39 40 ]; 41 42 __gshared immutable immutable(char)[][] test_ciphertexts = [ 43 "4dfa5e481da23ea09a31022050859936"~ // Expected output 44 "da52fcee218005164f267cb65f5cfd7f"~ 45 "2b4f97e0ff16924a52df269515110a07"~ 46 "f9e460bc65ef95da58f740b7d1dbb0aa", 47 48 "05e1e7beb697d999656bf37c1b978806"~ 49 "735d0b903a6007bd329927efbe1b0e2a"~ 50 "8137c1ae291493aa83a821755bee0b06"~ 51 "cd14855a67e46703ebf8f3114b584cba", 52 53 "c29ba0da9ebebfacdebbdd1d16e5f598"~ 54 "7e1cb12e9083d437eaaaa4ba0cdc909e"~ 55 "53d052ac387d86acda8d956ba9e6f654"~ 56 "3065f6912a7df710b4b57f27809bafe3", 57 58 "5e5e71f90199340304abb22a37b6625b"~ 59 "f883fb89ce3b21f54a10b81066ef87da"~ 60 "30b77699aa7379da595c77dd59542da2"~ 61 "08e5954f89e40eb7aa80a84a6176663f" 62 ]; 63 64 Salsa20 s20 = new Salsa20(); 65 ubyte[] buffer = new ubyte[64]; 66 char[] result; 67 for (int i = 0; i < test_keys.length; i++) 68 { 69 auto key = ByteConverter.hexDecode(test_keys[i]); 70 auto params = ByteConverter.hexDecode(test_ivs[i]); 71 72 // Encryption 73 s20.init(true, key, params); 74 s20.update(ByteConverter.hexDecode(test_plaintexts[i]), buffer); 75 result = ByteConverter.hexEncode(buffer); 76 assert(result == test_ciphertexts[i], 77 s20.name()~": ("~result~") != ("~test_ciphertexts[i]~")"); 78 79 // Decryption 80 s20.init(false, key, params); 81 s20.update(ByteConverter.hexDecode(test_ciphertexts[i]), buffer); 82 result = ByteConverter.hexEncode(buffer); 83 assert(result == test_plaintexts[i], 84 s20.name()~": ("~result~") != ("~test_plaintexts[i]~")"); 85 }