kmac_vectors.js (6401B)
1 function getTestVectors() { 2 // KMAC test vectors from https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Standards-and-Guidelines/documents/examples/KMAC_samples.pdf 3 4 var vectors = [ 5 { 6 // Sample #1 - KMAC128, no customization 7 name: "KMAC128 with no customization", 8 algorithm: "KMAC128", 9 length: 256, 10 keyBuffer: new Uint8Array([ 11 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 12 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 13 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 14 ]), 15 key: null, 16 plaintext: new Uint8Array([0x00, 0x01, 0x02, 0x03]), 17 customization: undefined, 18 signature: new Uint8Array([ 19 0xe5, 0x78, 0x0b, 0x0d, 0x3e, 0xa6, 0xf7, 0xd3, 0xa4, 0x29, 0xc5, 0x70, 20 0x6a, 0xa4, 0x3a, 0x00, 0xfa, 0xdb, 0xd7, 0xd4, 0x96, 0x28, 0x83, 0x9e, 21 0x31, 0x87, 0x24, 0x3f, 0x45, 0x6e, 0xe1, 0x4e, 22 ]), 23 }, 24 { 25 // Sample #2 - KMAC128, with customization 26 name: "KMAC128 with customization", 27 algorithm: "KMAC128", 28 length: 256, 29 keyBuffer: new Uint8Array([ 30 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 31 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 32 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 33 ]), 34 key: null, 35 plaintext: new Uint8Array([0x00, 0x01, 0x02, 0x03]), 36 customization: new Uint8Array([ 37 77, 121, 32, 84, 97, 103, 103, 101, 100, 32, 65, 112, 112, 108, 105, 99, 38 97, 116, 105, 111, 110, 39 ]), // "My Tagged Application" 40 signature: new Uint8Array([ 41 0x3b, 0x1f, 0xba, 0x96, 0x3c, 0xd8, 0xb0, 0xb5, 0x9e, 0x8c, 0x1a, 0x6d, 42 0x71, 0x88, 0x8b, 0x71, 0x43, 0x65, 0x1a, 0xf8, 0xba, 0x0a, 0x70, 0x70, 43 0xc0, 0x97, 0x9e, 0x28, 0x11, 0x32, 0x4a, 0xa5, 44 ]), 45 }, 46 { 47 // Sample #3 - KMAC128, large data, with customization 48 name: "KMAC128 with large data and customization", 49 algorithm: "KMAC128", 50 length: 256, 51 keyBuffer: new Uint8Array([ 52 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 53 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 54 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 55 ]), 56 key: null, 57 plaintext: new Uint8Array(Array.from({ length: 200 }, (_, i) => i)), // 0x00-0xC7 58 customization: new Uint8Array([ 59 77, 121, 32, 84, 97, 103, 103, 101, 100, 32, 65, 112, 112, 108, 105, 99, 60 97, 116, 105, 111, 110, 61 ]), // "My Tagged Application" 62 signature: new Uint8Array([ 63 0x1f, 0x5b, 0x4e, 0x6c, 0xca, 0x02, 0x20, 0x9e, 0x0d, 0xcb, 0x5c, 0xa6, 64 0x35, 0xb8, 0x9a, 0x15, 0xe2, 0x71, 0xec, 0xc7, 0x60, 0x07, 0x1d, 0xfd, 65 0x80, 0x5f, 0xaa, 0x38, 0xf9, 0x72, 0x92, 0x30, 66 ]), 67 }, 68 { 69 // Sample #4 - KMAC256, with customization, 512-bit output 70 name: "KMAC256 with customization and 512-bit output", 71 algorithm: "KMAC256", 72 length: 512, 73 keyBuffer: new Uint8Array([ 74 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 75 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 76 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 77 ]), 78 key: null, 79 plaintext: new Uint8Array([0x00, 0x01, 0x02, 0x03]), 80 customization: new Uint8Array([ 81 77, 121, 32, 84, 97, 103, 103, 101, 100, 32, 65, 112, 112, 108, 105, 99, 82 97, 116, 105, 111, 110, 83 ]), // "My Tagged Application" 84 signature: new Uint8Array([ 85 0x20, 0xc5, 0x70, 0xc3, 0x13, 0x46, 0xf7, 0x03, 0xc9, 0xac, 0x36, 0xc6, 86 0x1c, 0x03, 0xcb, 0x64, 0xc3, 0x97, 0x0d, 0x0c, 0xfc, 0x78, 0x7e, 0x9b, 87 0x79, 0x59, 0x9d, 0x27, 0x3a, 0x68, 0xd2, 0xf7, 0xf6, 0x9d, 0x4c, 0xc3, 88 0xde, 0x9d, 0x10, 0x4a, 0x35, 0x16, 0x89, 0xf2, 0x7c, 0xf6, 0xf5, 0x95, 89 0x1f, 0x01, 0x03, 0xf3, 0x3f, 0x4f, 0x24, 0x87, 0x10, 0x24, 0xd9, 0xc2, 90 0x77, 0x73, 0xa8, 0xdd, 91 ]), 92 }, 93 { 94 // Sample #5 - KMAC256, large data, no customization, 512-bit output 95 name: "KMAC256 with large data and no customization", 96 algorithm: "KMAC256", 97 length: 512, 98 keyBuffer: new Uint8Array([ 99 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 100 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 101 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 102 ]), 103 key: null, 104 plaintext: new Uint8Array(Array.from({ length: 200 }, (_, i) => i)), // 0x00-0xC7 105 customization: undefined, 106 signature: new Uint8Array([ 107 0x75, 0x35, 0x8c, 0xf3, 0x9e, 0x41, 0x49, 0x4e, 0x94, 0x97, 0x07, 0x92, 108 0x7c, 0xee, 0x0a, 0xf2, 0x0a, 0x3f, 0xf5, 0x53, 0x90, 0x4c, 0x86, 0xb0, 109 0x8f, 0x21, 0xcc, 0x41, 0x4b, 0xcf, 0xd6, 0x91, 0x58, 0x9d, 0x27, 0xcf, 110 0x5e, 0x15, 0x36, 0x9c, 0xbb, 0xff, 0x8b, 0x9a, 0x4c, 0x2e, 0xb1, 0x78, 111 0x00, 0x85, 0x5d, 0x02, 0x35, 0xff, 0x63, 0x5d, 0xa8, 0x25, 0x33, 0xec, 112 0x6b, 0x75, 0x9b, 0x69, 113 ]), 114 }, 115 { 116 // Sample #6 - KMAC256, large data, with customization, 512-bit output 117 name: "KMAC256 with large data and customization", 118 algorithm: "KMAC256", 119 length: 512, 120 keyBuffer: new Uint8Array([ 121 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 122 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 123 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 124 ]), 125 key: null, 126 plaintext: new Uint8Array(Array.from({ length: 200 }, (_, i) => i)), // 0x00-0xC7 127 customization: new Uint8Array([ 128 77, 121, 32, 84, 97, 103, 103, 101, 100, 32, 65, 112, 112, 108, 105, 99, 129 97, 116, 105, 111, 110, 130 ]), // "My Tagged Application" 131 signature: new Uint8Array([ 132 0xb5, 0x86, 0x18, 0xf7, 0x1f, 0x92, 0xe1, 0xd5, 0x6c, 0x1b, 0x8c, 0x55, 133 0xdd, 0xd7, 0xcd, 0x18, 0x8b, 0x97, 0xb4, 0xca, 0x4d, 0x99, 0x83, 0x1e, 134 0xb2, 0x69, 0x9a, 0x83, 0x7d, 0xa2, 0xe4, 0xd9, 0x70, 0xfb, 0xac, 0xfd, 135 0xe5, 0x00, 0x33, 0xae, 0xa5, 0x85, 0xf1, 0xa2, 0x70, 0x85, 0x10, 0xc3, 136 0x2d, 0x07, 0x88, 0x08, 0x01, 0xbd, 0x18, 0x28, 0x98, 0xfe, 0x47, 0x68, 137 0x76, 0xfc, 0x89, 0x65, 138 ]), 139 }, 140 ]; 141 142 return vectors; 143 }