Source file src/crypto/des/des_test.go

     1  // Copyright 2011 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package des_test
     6  
     7  import (
     8  	"bytes"
     9  	"crypto/cipher"
    10  	"crypto/des"
    11  	"testing"
    12  )
    13  
    14  type CryptTest struct {
    15  	key []byte
    16  	in  []byte
    17  	out []byte
    18  }
    19  
    20  // some custom tests for DES
    21  var encryptDESTests = []CryptTest{
    22  	{
    23  		[]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    24  		[]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    25  		[]byte{0x8c, 0xa6, 0x4d, 0xe9, 0xc1, 0xb1, 0x23, 0xa7}},
    26  	{
    27  		[]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    28  		[]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
    29  		[]byte{0x35, 0x55, 0x50, 0xb2, 0x15, 0x0e, 0x24, 0x51}},
    30  	{
    31  		[]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    32  		[]byte{0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef},
    33  		[]byte{0x61, 0x7b, 0x3a, 0x0c, 0xe8, 0xf0, 0x71, 0x00}},
    34  	{
    35  		[]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    36  		[]byte{0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10},
    37  		[]byte{0x92, 0x31, 0xf2, 0x36, 0xff, 0x9a, 0xa9, 0x5c}},
    38  	{
    39  		[]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
    40  		[]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    41  		[]byte{0xca, 0xaa, 0xaf, 0x4d, 0xea, 0xf1, 0xdb, 0xae}},
    42  	{
    43  		[]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
    44  		[]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
    45  		[]byte{0x73, 0x59, 0xb2, 0x16, 0x3e, 0x4e, 0xdc, 0x58}},
    46  	{
    47  		[]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
    48  		[]byte{0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef},
    49  		[]byte{0x6d, 0xce, 0x0d, 0xc9, 0x00, 0x65, 0x56, 0xa3}},
    50  	{
    51  		[]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
    52  		[]byte{0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10},
    53  		[]byte{0x9e, 0x84, 0xc5, 0xf3, 0x17, 0x0f, 0x8e, 0xff}},
    54  	{
    55  		[]byte{0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef},
    56  		[]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    57  		[]byte{0xd5, 0xd4, 0x4f, 0xf7, 0x20, 0x68, 0x3d, 0x0d}},
    58  	{
    59  		[]byte{0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef},
    60  		[]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
    61  		[]byte{0x59, 0x73, 0x23, 0x56, 0xf3, 0x6f, 0xde, 0x06}},
    62  	{
    63  		[]byte{0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef},
    64  		[]byte{0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef},
    65  		[]byte{0x56, 0xcc, 0x09, 0xe7, 0xcf, 0xdc, 0x4c, 0xef}},
    66  	{
    67  		[]byte{0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef},
    68  		[]byte{0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10},
    69  		[]byte{0x12, 0xc6, 0x26, 0xaf, 0x05, 0x8b, 0x43, 0x3b}},
    70  	{
    71  		[]byte{0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10},
    72  		[]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    73  		[]byte{0xa6, 0x8c, 0xdc, 0xa9, 0x0c, 0x90, 0x21, 0xf9}},
    74  	{
    75  		[]byte{0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10},
    76  		[]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
    77  		[]byte{0x2a, 0x2b, 0xb0, 0x08, 0xdf, 0x97, 0xc2, 0xf2}},
    78  	{
    79  		[]byte{0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10},
    80  		[]byte{0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef},
    81  		[]byte{0xed, 0x39, 0xd9, 0x50, 0xfa, 0x74, 0xbc, 0xc4}},
    82  	{
    83  		[]byte{0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10},
    84  		[]byte{0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10},
    85  		[]byte{0xa9, 0x33, 0xf6, 0x18, 0x30, 0x23, 0xb3, 0x10}},
    86  	{
    87  		[]byte{0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef},
    88  		[]byte{0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11},
    89  		[]byte{0x17, 0x66, 0x8d, 0xfc, 0x72, 0x92, 0x53, 0x2d}},
    90  	{
    91  		[]byte{0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef},
    92  		[]byte{0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01},
    93  		[]byte{0xb4, 0xfd, 0x23, 0x16, 0x47, 0xa5, 0xbe, 0xc0}},
    94  	{
    95  		[]byte{0x0e, 0x32, 0x92, 0x32, 0xea, 0x6d, 0x0d, 0x73},
    96  		[]byte{0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87},
    97  		[]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
    98  	{
    99  		[]byte{0x73, 0x65, 0x63, 0x52, 0x33, 0x74, 0x24, 0x3b}, // "secR3t$;"
   100  		[]byte{0x61, 0x20, 0x74, 0x65, 0x73, 0x74, 0x31, 0x32}, // "a test12"
   101  		[]byte{0x37, 0x0d, 0xee, 0x2c, 0x1f, 0xb4, 0xf7, 0xa5}},
   102  	{
   103  		[]byte{0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68}, // "abcdefgh"
   104  		[]byte{0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68}, // "abcdefgh"
   105  		[]byte{0x2a, 0x8d, 0x69, 0xde, 0x9d, 0x5f, 0xdf, 0xf9}},
   106  	{
   107  		[]byte{0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68}, // "abcdefgh"
   108  		[]byte{0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38}, // "12345678"
   109  		[]byte{0x21, 0xc6, 0x0d, 0xa5, 0x34, 0x24, 0x8b, 0xce}},
   110  	{
   111  		[]byte{0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38}, // "12345678"
   112  		[]byte{0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68}, // "abcdefgh"
   113  		[]byte{0x94, 0xd4, 0x43, 0x6b, 0xc3, 0xb5, 0xb6, 0x93}},
   114  	{
   115  		[]byte{0x1f, 0x79, 0x90, 0x5f, 0x88, 0x01, 0xc8, 0x88}, // random
   116  		[]byte{0xc7, 0x46, 0x18, 0x73, 0xaf, 0x48, 0x5f, 0xb3}, // random
   117  		[]byte{0xb0, 0x93, 0x50, 0x88, 0xf9, 0x92, 0x44, 0x6a}},
   118  	{
   119  		[]byte{0xe6, 0xf4, 0xf2, 0xdb, 0x31, 0x42, 0x53, 0x01}, // random
   120  		[]byte{0xff, 0x3d, 0x25, 0x50, 0x12, 0xe3, 0x4a, 0xc5}, // random
   121  		[]byte{0x86, 0x08, 0xd3, 0xd1, 0x6c, 0x2f, 0xd2, 0x55}},
   122  	{
   123  		[]byte{0x69, 0xc1, 0x9d, 0xc1, 0x15, 0xc5, 0xfb, 0x2b}, // random
   124  		[]byte{0x1a, 0x22, 0x5c, 0xaf, 0x1f, 0x1d, 0xa3, 0xf9}, // random
   125  		[]byte{0x64, 0xba, 0x31, 0x67, 0x56, 0x91, 0x1e, 0xa7}},
   126  	{
   127  		[]byte{0x6e, 0x5e, 0xe2, 0x47, 0xc4, 0xbf, 0xf6, 0x51}, // random
   128  		[]byte{0x11, 0xc9, 0x57, 0xff, 0x66, 0x89, 0x0e, 0xf0}, // random
   129  		[]byte{0x94, 0xc5, 0x35, 0xb2, 0xc5, 0x8b, 0x39, 0x72}},
   130  }
   131  
   132  var weakKeyTests = []CryptTest{
   133  	{
   134  		[]byte{0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01},
   135  		[]byte{0x55, 0x74, 0xc0, 0xbd, 0x7c, 0xdf, 0xf7, 0x39}, // random
   136  		nil},
   137  	{
   138  		[]byte{0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe},
   139  		[]byte{0xe8, 0xe1, 0xa7, 0xc1, 0xde, 0x11, 0x89, 0xaa}, // random
   140  		nil},
   141  	{
   142  		[]byte{0xe0, 0xe0, 0xe0, 0xe0, 0xf1, 0xf1, 0xf1, 0xf1},
   143  		[]byte{0x50, 0x6a, 0x4b, 0x94, 0x3b, 0xed, 0x7d, 0xdc}, // random
   144  		nil},
   145  	{
   146  		[]byte{0x1f, 0x1f, 0x1f, 0x1f, 0x0e, 0x0e, 0x0e, 0x0e},
   147  		[]byte{0x88, 0x81, 0x56, 0x38, 0xec, 0x3b, 0x1c, 0x97}, // random
   148  		nil},
   149  	{
   150  		[]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
   151  		[]byte{0x17, 0xa0, 0x83, 0x62, 0x32, 0xfe, 0x9a, 0x0b}, // random
   152  		nil},
   153  	{
   154  		[]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
   155  		[]byte{0xca, 0x8f, 0xca, 0x1f, 0x50, 0xc5, 0x7b, 0x49}, // random
   156  		nil},
   157  	{
   158  		[]byte{0xe1, 0xe1, 0xe1, 0xe1, 0xf0, 0xf0, 0xf0, 0xf0},
   159  		[]byte{0xb1, 0xea, 0xad, 0x7d, 0xe7, 0xc3, 0x7a, 0x43}, // random
   160  		nil},
   161  	{
   162  		[]byte{0x1e, 0x1e, 0x1e, 0x1e, 0x0f, 0x0f, 0x0f, 0x0f},
   163  		[]byte{0xae, 0x74, 0x7d, 0x6f, 0xef, 0x16, 0xbb, 0x81}, // random
   164  		nil},
   165  }
   166  
   167  var semiWeakKeyTests = []CryptTest{
   168  	// key and out contain the semi-weak key pair
   169  	{
   170  		[]byte{0x01, 0x1f, 0x01, 0x1f, 0x01, 0x0e, 0x01, 0x0e},
   171  		[]byte{0x12, 0xfa, 0x31, 0x16, 0xf9, 0xc5, 0x0a, 0xe4}, // random
   172  		[]byte{0x1f, 0x01, 0x1f, 0x01, 0x0e, 0x01, 0x0e, 0x01}},
   173  	{
   174  		[]byte{0x01, 0xe0, 0x01, 0xe0, 0x01, 0xf1, 0x01, 0xf1},
   175  		[]byte{0xb0, 0x4c, 0x7a, 0xee, 0xd2, 0xe5, 0x4d, 0xb7}, // random
   176  		[]byte{0xe0, 0x01, 0xe0, 0x01, 0xf1, 0x01, 0xf1, 0x01}},
   177  	{
   178  		[]byte{0x01, 0xfe, 0x01, 0xfe, 0x01, 0xfe, 0x01, 0xfe},
   179  		[]byte{0xa4, 0x81, 0xcd, 0xb1, 0x64, 0x6f, 0xd3, 0xbc}, // random
   180  		[]byte{0xfe, 0x01, 0xfe, 0x01, 0xfe, 0x01, 0xfe, 0x01}},
   181  	{
   182  		[]byte{0x1f, 0xe0, 0x1f, 0xe0, 0x0e, 0xf1, 0x0e, 0xf1},
   183  		[]byte{0xee, 0x27, 0xdd, 0x88, 0x4c, 0x22, 0xcd, 0xce}, // random
   184  		[]byte{0xe0, 0x1f, 0xe0, 0x1f, 0xf1, 0x0e, 0xf1, 0x0e}},
   185  	{
   186  		[]byte{0x1f, 0xfe, 0x1f, 0xfe, 0x0e, 0xfe, 0x0e, 0xfe},
   187  		[]byte{0x19, 0x3d, 0xcf, 0x97, 0x70, 0xfb, 0xab, 0xe1}, // random
   188  		[]byte{0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x0e, 0xfe, 0x0e}},
   189  	{
   190  		[]byte{0xe0, 0xfe, 0xe0, 0xfe, 0xf1, 0xfe, 0xf1, 0xfe},
   191  		[]byte{0x7c, 0x82, 0x69, 0xe4, 0x1e, 0x86, 0x99, 0xd7}, // random
   192  		[]byte{0xfe, 0xe0, 0xfe, 0xe0, 0xfe, 0xf1, 0xfe, 0xf1}},
   193  }
   194  
   195  // some custom tests for TripleDES
   196  var encryptTripleDESTests = []CryptTest{
   197  	{
   198  		[]byte{
   199  			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   200  			0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   201  			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
   202  		[]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
   203  		[]byte{0x92, 0x95, 0xb5, 0x9b, 0xb3, 0x84, 0x73, 0x6e}},
   204  	{
   205  		[]byte{
   206  			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   207  			0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   208  			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
   209  		[]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
   210  		[]byte{0xc1, 0x97, 0xf5, 0x58, 0x74, 0x8a, 0x20, 0xe7}},
   211  	{
   212  		[]byte{
   213  			0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   214  			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   215  			0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
   216  		[]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
   217  		[]byte{0x3e, 0x68, 0x0a, 0xa7, 0x8b, 0x75, 0xdf, 0x18}},
   218  	{
   219  		[]byte{
   220  			0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   221  			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   222  			0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
   223  		[]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
   224  		[]byte{0x6d, 0x6a, 0x4a, 0x64, 0x4c, 0x7b, 0x8c, 0x91}},
   225  	{
   226  		[]byte{ // "abcdefgh12345678ABCDEFGH"
   227  			0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
   228  			0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
   229  			0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48},
   230  		[]byte{0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30}, // "00000000"
   231  		[]byte{0xe4, 0x61, 0xb7, 0x59, 0x68, 0x8b, 0xff, 0x66}},
   232  	{
   233  		[]byte{ // "abcdefgh12345678ABCDEFGH"
   234  			0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
   235  			0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
   236  			0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48},
   237  		[]byte{0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38}, // "12345678"
   238  		[]byte{0xdb, 0xd0, 0x92, 0xde, 0xf8, 0x34, 0xff, 0x58}},
   239  	{
   240  		[]byte{ // "abcdefgh12345678ABCDEFGH"
   241  			0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
   242  			0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
   243  			0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48},
   244  		[]byte{0xf0, 0xc5, 0x82, 0x22, 0xd3, 0xe6, 0x12, 0xd2}, // random
   245  		[]byte{0xba, 0xe4, 0x41, 0xb1, 0x3c, 0x37, 0x4d, 0xf4}},
   246  	{
   247  		[]byte{ // random
   248  			0xd3, 0x7d, 0x45, 0xee, 0x22, 0xe9, 0xcf, 0x52,
   249  			0xf4, 0x65, 0xa2, 0x4f, 0x70, 0xd1, 0x81, 0x8a,
   250  			0x3d, 0xbe, 0x2f, 0x39, 0xc7, 0x71, 0xd2, 0xe9},
   251  		[]byte{0x49, 0x53, 0xc3, 0xe9, 0x78, 0xdf, 0x9f, 0xaf}, // random
   252  		[]byte{0x53, 0x40, 0x51, 0x24, 0xd8, 0x3c, 0xf9, 0x88}},
   253  	{
   254  		[]byte{ // random
   255  			0xcb, 0x10, 0x7d, 0xda, 0x7e, 0x96, 0x57, 0x0a,
   256  			0xe8, 0xeb, 0xe8, 0x07, 0x8e, 0x87, 0xd3, 0x57,
   257  			0xb2, 0x61, 0x12, 0xb8, 0x2a, 0x90, 0xb7, 0x2f},
   258  		[]byte{0xa3, 0xc2, 0x60, 0xb1, 0x0b, 0xb7, 0x28, 0x6e}, // random
   259  		[]byte{0x56, 0x73, 0x7d, 0xfb, 0xb5, 0xa1, 0xc3, 0xde}},
   260  }
   261  
   262  // NIST Special Publication 800-20, Appendix A
   263  // Key for use with Table A.1 tests
   264  var tableA1Key = []byte{
   265  	0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
   266  	0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
   267  	0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
   268  }
   269  
   270  // Table A.1 Resulting Ciphertext from the Variable Plaintext Known Answer Test
   271  var tableA1Tests = []CryptTest{
   272  	{nil, // 0
   273  		[]byte{0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
   274  		[]byte{0x95, 0xf8, 0xa5, 0xe5, 0xdd, 0x31, 0xd9, 0x00}},
   275  	{nil, // 1
   276  		[]byte{0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
   277  		[]byte{0xdd, 0x7f, 0x12, 0x1c, 0xa5, 0x01, 0x56, 0x19}},
   278  	{nil, // 2
   279  		[]byte{0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
   280  		[]byte{0x2e, 0x86, 0x53, 0x10, 0x4f, 0x38, 0x34, 0xea}},
   281  	{nil, // 3
   282  		[]byte{0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
   283  		[]byte{0x4b, 0xd3, 0x88, 0xff, 0x6c, 0xd8, 0x1d, 0x4f}},
   284  	{nil, // 4
   285  		[]byte{0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
   286  		[]byte{0x20, 0xb9, 0xe7, 0x67, 0xb2, 0xfb, 0x14, 0x56}},
   287  	{nil, // 5
   288  		[]byte{0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
   289  		[]byte{0x55, 0x57, 0x93, 0x80, 0xd7, 0x71, 0x38, 0xef}},
   290  	{nil, // 6
   291  		[]byte{0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
   292  		[]byte{0x6c, 0xc5, 0xde, 0xfa, 0xaf, 0x04, 0x51, 0x2f}},
   293  	{nil, // 7
   294  		[]byte{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
   295  		[]byte{0x0d, 0x9f, 0x27, 0x9b, 0xa5, 0xd8, 0x72, 0x60}},
   296  	{nil, // 8
   297  		[]byte{0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
   298  		[]byte{0xd9, 0x03, 0x1b, 0x02, 0x71, 0xbd, 0x5a, 0x0a}},
   299  	{nil, // 9
   300  		[]byte{0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
   301  		[]byte{0x42, 0x42, 0x50, 0xb3, 0x7c, 0x3d, 0xd9, 0x51}},
   302  	{nil, // 10
   303  		[]byte{0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
   304  		[]byte{0xb8, 0x06, 0x1b, 0x7e, 0xcd, 0x9a, 0x21, 0xe5}},
   305  	{nil, // 11
   306  		[]byte{0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
   307  		[]byte{0xf1, 0x5d, 0x0f, 0x28, 0x6b, 0x65, 0xbd, 0x28}},
   308  	{nil, // 12
   309  		[]byte{0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
   310  		[]byte{0xad, 0xd0, 0xcc, 0x8d, 0x6e, 0x5d, 0xeb, 0xa1}},
   311  	{nil, // 13
   312  		[]byte{0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
   313  		[]byte{0xe6, 0xd5, 0xf8, 0x27, 0x52, 0xad, 0x63, 0xd1}},
   314  	{nil, // 14
   315  		[]byte{0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
   316  		[]byte{0xec, 0xbf, 0xe3, 0xbd, 0x3f, 0x59, 0x1a, 0x5e}},
   317  	{nil, // 15
   318  		[]byte{0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
   319  		[]byte{0xf3, 0x56, 0x83, 0x43, 0x79, 0xd1, 0x65, 0xcd}},
   320  	{nil, // 16
   321  		[]byte{0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00},
   322  		[]byte{0x2b, 0x9f, 0x98, 0x2f, 0x20, 0x03, 0x7f, 0xa9}},
   323  	{nil, // 17
   324  		[]byte{0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00},
   325  		[]byte{0x88, 0x9d, 0xe0, 0x68, 0xa1, 0x6f, 0x0b, 0xe6}},
   326  	{nil, // 18
   327  		[]byte{0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00},
   328  		[]byte{0xe1, 0x9e, 0x27, 0x5d, 0x84, 0x6a, 0x12, 0x98}},
   329  	{nil, // 19
   330  		[]byte{0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00},
   331  		[]byte{0x32, 0x9a, 0x8e, 0xd5, 0x23, 0xd7, 0x1a, 0xec}},
   332  	{nil, // 20
   333  		[]byte{0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00},
   334  		[]byte{0xe7, 0xfc, 0xe2, 0x25, 0x57, 0xd2, 0x3c, 0x97}},
   335  	{nil, // 21
   336  		[]byte{0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00},
   337  		[]byte{0x12, 0xa9, 0xf5, 0x81, 0x7f, 0xf2, 0xd6, 0x5d}},
   338  	{nil, // 22
   339  		[]byte{0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00},
   340  		[]byte{0xa4, 0x84, 0xc3, 0xad, 0x38, 0xdc, 0x9c, 0x19}},
   341  	{nil, // 23
   342  		[]byte{0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00},
   343  		[]byte{0xfb, 0xe0, 0x0a, 0x8a, 0x1e, 0xf8, 0xad, 0x72}},
   344  	{nil, // 24
   345  		[]byte{0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00},
   346  		[]byte{0x75, 0x0d, 0x07, 0x94, 0x07, 0x52, 0x13, 0x63}},
   347  	{nil, // 25
   348  		[]byte{0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00},
   349  		[]byte{0x64, 0xfe, 0xed, 0x9c, 0x72, 0x4c, 0x2f, 0xaf}},
   350  	{nil, // 26
   351  		[]byte{0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00},
   352  		[]byte{0xf0, 0x2b, 0x26, 0x3b, 0x32, 0x8e, 0x2b, 0x60}},
   353  	{nil, // 27
   354  		[]byte{0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00},
   355  		[]byte{0x9d, 0x64, 0x55, 0x5a, 0x9a, 0x10, 0xb8, 0x52}},
   356  	{nil, // 28
   357  		[]byte{0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00},
   358  		[]byte{0xd1, 0x06, 0xff, 0x0b, 0xed, 0x52, 0x55, 0xd7}},
   359  	{nil, // 29
   360  		[]byte{0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00},
   361  		[]byte{0xe1, 0x65, 0x2c, 0x6b, 0x13, 0x8c, 0x64, 0xa5}},
   362  	{nil, // 30
   363  		[]byte{0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00},
   364  		[]byte{0xe4, 0x28, 0x58, 0x11, 0x86, 0xec, 0x8f, 0x46}},
   365  	{nil, // 31
   366  		[]byte{0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00},
   367  		[]byte{0xae, 0xb5, 0xf5, 0xed, 0xe2, 0x2d, 0x1a, 0x36}},
   368  	{nil, // 32
   369  		[]byte{0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00},
   370  		[]byte{0xe9, 0x43, 0xd7, 0x56, 0x8a, 0xec, 0x0c, 0x5c}},
   371  	{nil, // 33
   372  		[]byte{0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00},
   373  		[]byte{0xdf, 0x98, 0xc8, 0x27, 0x6f, 0x54, 0xb0, 0x4b}},
   374  	{nil, // 34
   375  		[]byte{0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00},
   376  		[]byte{0xb1, 0x60, 0xe4, 0x68, 0x0f, 0x6c, 0x69, 0x6f}},
   377  	{nil, // 35
   378  		[]byte{0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00},
   379  		[]byte{0xfa, 0x07, 0x52, 0xb0, 0x7d, 0x9c, 0x4a, 0xb8}},
   380  	{nil, // 36
   381  		[]byte{0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00},
   382  		[]byte{0xca, 0x3a, 0x2b, 0x03, 0x6d, 0xbc, 0x85, 0x02}},
   383  	{nil, // 37
   384  		[]byte{0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00},
   385  		[]byte{0x5e, 0x09, 0x05, 0x51, 0x7b, 0xb5, 0x9b, 0xcf}},
   386  	{nil, // 38
   387  		[]byte{0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00},
   388  		[]byte{0x81, 0x4e, 0xeb, 0x3b, 0x91, 0xd9, 0x07, 0x26}},
   389  	{nil, // 39
   390  		[]byte{0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00},
   391  		[]byte{0x4d, 0x49, 0xdb, 0x15, 0x32, 0x91, 0x9c, 0x9f}},
   392  	{nil, // 40
   393  		[]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00},
   394  		[]byte{0x25, 0xeb, 0x5f, 0xc3, 0xf8, 0xcf, 0x06, 0x21}},
   395  	{nil, // 41
   396  		[]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00},
   397  		[]byte{0xab, 0x6a, 0x20, 0xc0, 0x62, 0x0d, 0x1c, 0x6f}},
   398  	{nil, // 42
   399  		[]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00},
   400  		[]byte{0x79, 0xe9, 0x0d, 0xbc, 0x98, 0xf9, 0x2c, 0xca}},
   401  	{nil, // 43
   402  		[]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00},
   403  		[]byte{0x86, 0x6e, 0xce, 0xdd, 0x80, 0x72, 0xbb, 0x0e}},
   404  	{nil, // 44
   405  		[]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00},
   406  		[]byte{0x8b, 0x54, 0x53, 0x6f, 0x2f, 0x3e, 0x64, 0xa8}},
   407  	{nil, // 45
   408  		[]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00},
   409  		[]byte{0xea, 0x51, 0xd3, 0x97, 0x55, 0x95, 0xb8, 0x6b}},
   410  	{nil, // 46
   411  		[]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00},
   412  		[]byte{0xca, 0xff, 0xc6, 0xac, 0x45, 0x42, 0xde, 0x31}},
   413  	{nil, // 47
   414  		[]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00},
   415  		[]byte{0x8d, 0xd4, 0x5a, 0x2d, 0xdf, 0x90, 0x79, 0x6c}},
   416  	{nil, // 48
   417  		[]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00},
   418  		[]byte{0x10, 0x29, 0xd5, 0x5e, 0x88, 0x0e, 0xc2, 0xd0}},
   419  	{nil, // 49
   420  		[]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00},
   421  		[]byte{0x5d, 0x86, 0xcb, 0x23, 0x63, 0x9d, 0xbe, 0xa9}},
   422  	{nil, // 50
   423  		[]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00},
   424  		[]byte{0x1d, 0x1c, 0xa8, 0x53, 0xae, 0x7c, 0x0c, 0x5f}},
   425  	{nil, // 51
   426  		[]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00},
   427  		[]byte{0xce, 0x33, 0x23, 0x29, 0x24, 0x8f, 0x32, 0x28}},
   428  	{nil, // 52
   429  		[]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00},
   430  		[]byte{0x84, 0x05, 0xd1, 0xab, 0xe2, 0x4f, 0xb9, 0x42}},
   431  	{nil, // 53
   432  		[]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00},
   433  		[]byte{0xe6, 0x43, 0xd7, 0x80, 0x90, 0xca, 0x42, 0x07}},
   434  	{nil, // 54
   435  		[]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00},
   436  		[]byte{0x48, 0x22, 0x1b, 0x99, 0x37, 0x74, 0x8a, 0x23}},
   437  	{nil, // 55
   438  		[]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00},
   439  		[]byte{0xdd, 0x7c, 0x0b, 0xbd, 0x61, 0xfa, 0xfd, 0x54}},
   440  	{nil, // 56
   441  		[]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80},
   442  		[]byte{0x2f, 0xbc, 0x29, 0x1a, 0x57, 0x0d, 0xb5, 0xc4}},
   443  	{nil, // 57
   444  		[]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40},
   445  		[]byte{0xe0, 0x7c, 0x30, 0xd7, 0xe4, 0xe2, 0x6e, 0x12}},
   446  	{nil, // 58
   447  		[]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20},
   448  		[]byte{0x09, 0x53, 0xe2, 0x25, 0x8e, 0x8e, 0x90, 0xa1}},
   449  	{nil, // 59
   450  		[]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
   451  		[]byte{0x5b, 0x71, 0x1b, 0xc4, 0xce, 0xeb, 0xf2, 0xee}},
   452  	{nil, // 60
   453  		[]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08},
   454  		[]byte{0xcc, 0x08, 0x3f, 0x1e, 0x6d, 0x9e, 0x85, 0xf6}},
   455  	{nil, // 61
   456  		[]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04},
   457  		[]byte{0xd2, 0xfd, 0x88, 0x67, 0xd5, 0x0d, 0x2d, 0xfe}},
   458  	{nil, // 62
   459  		[]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02},
   460  		[]byte{0x06, 0xe7, 0xea, 0x22, 0xce, 0x92, 0x70, 0x8f}},
   461  	{nil, // 63
   462  		[]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01},
   463  		[]byte{0x16, 0x6b, 0x40, 0xb4, 0x4a, 0xba, 0x4b, 0xd6}},
   464  }
   465  
   466  // Plaintext for use with Table A.2 tests
   467  var tableA2Plaintext = []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
   468  
   469  // Table A.2 Resulting Ciphertext from the Variable Key Known Answer Test
   470  var tableA2Tests = []CryptTest{
   471  	{ // 0
   472  		[]byte{
   473  			0x80, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
   474  			0x80, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
   475  			0x80, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01},
   476  		nil,
   477  		[]byte{0x95, 0xa8, 0xd7, 0x28, 0x13, 0xda, 0xa9, 0x4d}},
   478  	{ // 1
   479  		[]byte{
   480  			0x40, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
   481  			0x40, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
   482  			0x40, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01},
   483  		nil,
   484  		[]byte{0x0e, 0xec, 0x14, 0x87, 0xdd, 0x8c, 0x26, 0xd5}},
   485  	{ // 2
   486  		[]byte{
   487  			0x20, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
   488  			0x20, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
   489  			0x20, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01},
   490  		nil,
   491  		[]byte{0x7a, 0xd1, 0x6f, 0xfb, 0x79, 0xc4, 0x59, 0x26}},
   492  	{ // 3
   493  		[]byte{
   494  			0x10, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
   495  			0x10, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
   496  			0x10, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01},
   497  		nil,
   498  		[]byte{0xd3, 0x74, 0x62, 0x94, 0xca, 0x6a, 0x6c, 0xf3}},
   499  	{ // 4
   500  		[]byte{
   501  			0x08, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
   502  			0x08, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
   503  			0x08, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01},
   504  		nil,
   505  		[]byte{0x80, 0x9f, 0x5f, 0x87, 0x3c, 0x1f, 0xd7, 0x61}},
   506  	{ // 5
   507  		[]byte{
   508  			0x04, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
   509  			0x04, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
   510  			0x04, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01},
   511  		nil,
   512  		[]byte{0xc0, 0x2f, 0xaf, 0xfe, 0xc9, 0x89, 0xd1, 0xfc}},
   513  	{ // 6
   514  		[]byte{
   515  			0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
   516  			0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
   517  			0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01},
   518  		nil,
   519  		[]byte{0x46, 0x15, 0xaa, 0x1d, 0x33, 0xe7, 0x2f, 0x10}},
   520  	{ // 7
   521  		[]byte{
   522  			0x01, 0x80, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
   523  			0x01, 0x80, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
   524  			0x01, 0x80, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01},
   525  		nil,
   526  		[]byte{0x20, 0x55, 0x12, 0x33, 0x50, 0xc0, 0x08, 0x58}},
   527  	{ // 8
   528  		[]byte{
   529  			0x01, 0x40, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
   530  			0x01, 0x40, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
   531  			0x01, 0x40, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01},
   532  		nil,
   533  		[]byte{0xdf, 0x3b, 0x99, 0xd6, 0x57, 0x73, 0x97, 0xc8}},
   534  	{ // 9
   535  		[]byte{
   536  			0x01, 0x20, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
   537  			0x01, 0x20, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
   538  			0x01, 0x20, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01},
   539  		nil,
   540  		[]byte{0x31, 0xfe, 0x17, 0x36, 0x9b, 0x52, 0x88, 0xc9}},
   541  	{ // 10
   542  		[]byte{
   543  			0x01, 0x10, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
   544  			0x01, 0x10, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
   545  			0x01, 0x10, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01},
   546  		nil,
   547  		[]byte{0xdf, 0xdd, 0x3c, 0xc6, 0x4d, 0xae, 0x16, 0x42}},
   548  	{ // 11
   549  		[]byte{
   550  			0x01, 0x08, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
   551  			0x01, 0x08, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
   552  			0x01, 0x08, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01},
   553  		nil,
   554  		[]byte{0x17, 0x8c, 0x83, 0xce, 0x2b, 0x39, 0x9d, 0x94}},
   555  	{ // 12
   556  		[]byte{
   557  			0x01, 0x04, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
   558  			0x01, 0x04, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
   559  			0x01, 0x04, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01},
   560  		nil,
   561  		[]byte{0x50, 0xf6, 0x36, 0x32, 0x4a, 0x9b, 0x7f, 0x80}},
   562  	{ // 13
   563  		[]byte{
   564  			0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
   565  			0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
   566  			0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01},
   567  		nil,
   568  		[]byte{0xa8, 0x46, 0x8e, 0xe3, 0xbc, 0x18, 0xf0, 0x6d}},
   569  	{ // 14
   570  		[]byte{
   571  			0x01, 0x01, 0x80, 0x01, 0x01, 0x01, 0x01, 0x01,
   572  			0x01, 0x01, 0x80, 0x01, 0x01, 0x01, 0x01, 0x01,
   573  			0x01, 0x01, 0x80, 0x01, 0x01, 0x01, 0x01, 0x01},
   574  		nil,
   575  		[]byte{0xa2, 0xdc, 0x9e, 0x92, 0xfd, 0x3c, 0xde, 0x92}},
   576  	{ // 15
   577  		[]byte{
   578  			0x01, 0x01, 0x40, 0x01, 0x01, 0x01, 0x01, 0x01,
   579  			0x01, 0x01, 0x40, 0x01, 0x01, 0x01, 0x01, 0x01,
   580  			0x01, 0x01, 0x40, 0x01, 0x01, 0x01, 0x01, 0x01},
   581  		nil,
   582  		[]byte{0xca, 0xc0, 0x9f, 0x79, 0x7d, 0x03, 0x12, 0x87}},
   583  	{ // 16
   584  		[]byte{
   585  			0x01, 0x01, 0x20, 0x01, 0x01, 0x01, 0x01, 0x01,
   586  			0x01, 0x01, 0x20, 0x01, 0x01, 0x01, 0x01, 0x01,
   587  			0x01, 0x01, 0x20, 0x01, 0x01, 0x01, 0x01, 0x01},
   588  		nil,
   589  		[]byte{0x90, 0xba, 0x68, 0x0b, 0x22, 0xae, 0xb5, 0x25}},
   590  	{ // 17
   591  		[]byte{
   592  			0x01, 0x01, 0x10, 0x01, 0x01, 0x01, 0x01, 0x01,
   593  			0x01, 0x01, 0x10, 0x01, 0x01, 0x01, 0x01, 0x01,
   594  			0x01, 0x01, 0x10, 0x01, 0x01, 0x01, 0x01, 0x01},
   595  		nil,
   596  		[]byte{0xce, 0x7a, 0x24, 0xf3, 0x50, 0xe2, 0x80, 0xb6}},
   597  	{ // 18
   598  		[]byte{
   599  			0x01, 0x01, 0x08, 0x01, 0x01, 0x01, 0x01, 0x01,
   600  			0x01, 0x01, 0x08, 0x01, 0x01, 0x01, 0x01, 0x01,
   601  			0x01, 0x01, 0x08, 0x01, 0x01, 0x01, 0x01, 0x01},
   602  		nil,
   603  		[]byte{0x88, 0x2b, 0xff, 0x0a, 0xa0, 0x1a, 0x0b, 0x87}},
   604  	{ // 19
   605  		[]byte{
   606  			0x01, 0x01, 0x04, 0x01, 0x01, 0x01, 0x01, 0x01,
   607  			0x01, 0x01, 0x04, 0x01, 0x01, 0x01, 0x01, 0x01,
   608  			0x01, 0x01, 0x04, 0x01, 0x01, 0x01, 0x01, 0x01},
   609  		nil,
   610  		[]byte{0x25, 0x61, 0x02, 0x88, 0x92, 0x45, 0x11, 0xc2}},
   611  	{ // 20
   612  		[]byte{
   613  			0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01,
   614  			0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01,
   615  			0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01},
   616  		nil,
   617  		[]byte{0xc7, 0x15, 0x16, 0xc2, 0x9c, 0x75, 0xd1, 0x70}},
   618  	{ // 21
   619  		[]byte{
   620  			0x01, 0x01, 0x01, 0x80, 0x01, 0x01, 0x01, 0x01,
   621  			0x01, 0x01, 0x01, 0x80, 0x01, 0x01, 0x01, 0x01,
   622  			0x01, 0x01, 0x01, 0x80, 0x01, 0x01, 0x01, 0x01},
   623  		nil,
   624  		[]byte{0x51, 0x99, 0xc2, 0x9a, 0x52, 0xc9, 0xf0, 0x59}},
   625  	{ // 22
   626  		[]byte{
   627  			0x01, 0x01, 0x01, 0x40, 0x01, 0x01, 0x01, 0x01,
   628  			0x01, 0x01, 0x01, 0x40, 0x01, 0x01, 0x01, 0x01,
   629  			0x01, 0x01, 0x01, 0x40, 0x01, 0x01, 0x01, 0x01},
   630  		nil,
   631  		[]byte{0xc2, 0x2f, 0x0a, 0x29, 0x4a, 0x71, 0xf2, 0x9f}},
   632  	{ // 23
   633  		[]byte{
   634  			0x01, 0x01, 0x01, 0x20, 0x01, 0x01, 0x01, 0x01,
   635  			0x01, 0x01, 0x01, 0x20, 0x01, 0x01, 0x01, 0x01,
   636  			0x01, 0x01, 0x01, 0x20, 0x01, 0x01, 0x01, 0x01},
   637  		nil,
   638  		[]byte{0xee, 0x37, 0x14, 0x83, 0x71, 0x4c, 0x02, 0xea}},
   639  	{ // 24
   640  		[]byte{
   641  			0x01, 0x01, 0x01, 0x10, 0x01, 0x01, 0x01, 0x01,
   642  			0x01, 0x01, 0x01, 0x10, 0x01, 0x01, 0x01, 0x01,
   643  			0x01, 0x01, 0x01, 0x10, 0x01, 0x01, 0x01, 0x01},
   644  		nil,
   645  		[]byte{0xa8, 0x1f, 0xbd, 0x44, 0x8f, 0x9e, 0x52, 0x2f}},
   646  	{ // 25
   647  		[]byte{
   648  			0x01, 0x01, 0x01, 0x08, 0x01, 0x01, 0x01, 0x01,
   649  			0x01, 0x01, 0x01, 0x08, 0x01, 0x01, 0x01, 0x01,
   650  			0x01, 0x01, 0x01, 0x08, 0x01, 0x01, 0x01, 0x01},
   651  		nil,
   652  		[]byte{0x4f, 0x64, 0x4c, 0x92, 0xe1, 0x92, 0xdf, 0xed}},
   653  	{ // 26
   654  		[]byte{
   655  			0x01, 0x01, 0x01, 0x04, 0x01, 0x01, 0x01, 0x01,
   656  			0x01, 0x01, 0x01, 0x04, 0x01, 0x01, 0x01, 0x01,
   657  			0x01, 0x01, 0x01, 0x04, 0x01, 0x01, 0x01, 0x01},
   658  		nil,
   659  		[]byte{0x1a, 0xfa, 0x9a, 0x66, 0xa6, 0xdf, 0x92, 0xae}},
   660  	{ // 27
   661  		[]byte{
   662  			0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01,
   663  			0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01,
   664  			0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01},
   665  		nil,
   666  		[]byte{0xb3, 0xc1, 0xcc, 0x71, 0x5c, 0xb8, 0x79, 0xd8}},
   667  	{ // 28
   668  		[]byte{
   669  			0x01, 0x01, 0x01, 0x01, 0x80, 0x01, 0x01, 0x01,
   670  			0x01, 0x01, 0x01, 0x01, 0x80, 0x01, 0x01, 0x01,
   671  			0x01, 0x01, 0x01, 0x01, 0x80, 0x01, 0x01, 0x01},
   672  		nil,
   673  		[]byte{0x19, 0xd0, 0x32, 0xe6, 0x4a, 0xb0, 0xbd, 0x8b}},
   674  	{ // 29
   675  		[]byte{
   676  			0x01, 0x01, 0x01, 0x01, 0x40, 0x01, 0x01, 0x01,
   677  			0x01, 0x01, 0x01, 0x01, 0x40, 0x01, 0x01, 0x01,
   678  			0x01, 0x01, 0x01, 0x01, 0x40, 0x01, 0x01, 0x01},
   679  		nil,
   680  		[]byte{0x3c, 0xfa, 0xa7, 0xa7, 0xdc, 0x87, 0x20, 0xdc}},
   681  	{ // 30
   682  		[]byte{
   683  			0x01, 0x01, 0x01, 0x01, 0x20, 0x01, 0x01, 0x01,
   684  			0x01, 0x01, 0x01, 0x01, 0x20, 0x01, 0x01, 0x01,
   685  			0x01, 0x01, 0x01, 0x01, 0x20, 0x01, 0x01, 0x01},
   686  		nil,
   687  		[]byte{0xb7, 0x26, 0x5f, 0x7f, 0x44, 0x7a, 0xc6, 0xf3}},
   688  	{ // 31
   689  		[]byte{
   690  			0x01, 0x01, 0x01, 0x01, 0x10, 0x01, 0x01, 0x01,
   691  			0x01, 0x01, 0x01, 0x01, 0x10, 0x01, 0x01, 0x01,
   692  			0x01, 0x01, 0x01, 0x01, 0x10, 0x01, 0x01, 0x01},
   693  		nil,
   694  		[]byte{0x9d, 0xb7, 0x3b, 0x3c, 0x0d, 0x16, 0x3f, 0x54}},
   695  	{ // 32
   696  		[]byte{
   697  			0x01, 0x01, 0x01, 0x01, 0x08, 0x01, 0x01, 0x01,
   698  			0x01, 0x01, 0x01, 0x01, 0x08, 0x01, 0x01, 0x01,
   699  			0x01, 0x01, 0x01, 0x01, 0x08, 0x01, 0x01, 0x01},
   700  		nil,
   701  		[]byte{0x81, 0x81, 0xb6, 0x5b, 0xab, 0xf4, 0xa9, 0x75}},
   702  	{ // 33
   703  		[]byte{
   704  			0x01, 0x01, 0x01, 0x01, 0x04, 0x01, 0x01, 0x01,
   705  			0x01, 0x01, 0x01, 0x01, 0x04, 0x01, 0x01, 0x01,
   706  			0x01, 0x01, 0x01, 0x01, 0x04, 0x01, 0x01, 0x01},
   707  		nil,
   708  		[]byte{0x93, 0xc9, 0xb6, 0x40, 0x42, 0xea, 0xa2, 0x40}},
   709  	{ // 34
   710  		[]byte{
   711  			0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01,
   712  			0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01,
   713  			0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01},
   714  		nil,
   715  		[]byte{0x55, 0x70, 0x53, 0x08, 0x29, 0x70, 0x55, 0x92}},
   716  	{ // 35
   717  		[]byte{
   718  			0x01, 0x01, 0x01, 0x01, 0x01, 0x80, 0x01, 0x01,
   719  			0x01, 0x01, 0x01, 0x01, 0x01, 0x80, 0x01, 0x01,
   720  			0x01, 0x01, 0x01, 0x01, 0x01, 0x80, 0x01, 0x01},
   721  		nil,
   722  		[]byte{0x86, 0x38, 0x80, 0x9e, 0x87, 0x87, 0x87, 0xa0}},
   723  	{ // 36
   724  		[]byte{
   725  			0x01, 0x01, 0x01, 0x01, 0x01, 0x40, 0x01, 0x01,
   726  			0x01, 0x01, 0x01, 0x01, 0x01, 0x40, 0x01, 0x01,
   727  			0x01, 0x01, 0x01, 0x01, 0x01, 0x40, 0x01, 0x01},
   728  		nil,
   729  		[]byte{0x41, 0xb9, 0xa7, 0x9a, 0xf7, 0x9a, 0xc2, 0x08}},
   730  	{ // 37
   731  		[]byte{
   732  			0x01, 0x01, 0x01, 0x01, 0x01, 0x20, 0x01, 0x01,
   733  			0x01, 0x01, 0x01, 0x01, 0x01, 0x20, 0x01, 0x01,
   734  			0x01, 0x01, 0x01, 0x01, 0x01, 0x20, 0x01, 0x01},
   735  		nil,
   736  		[]byte{0x7a, 0x9b, 0xe4, 0x2f, 0x20, 0x09, 0xa8, 0x92}},
   737  	{ // 38
   738  		[]byte{
   739  			0x01, 0x01, 0x01, 0x01, 0x01, 0x10, 0x01, 0x01,
   740  			0x01, 0x01, 0x01, 0x01, 0x01, 0x10, 0x01, 0x01,
   741  			0x01, 0x01, 0x01, 0x01, 0x01, 0x10, 0x01, 0x01},
   742  		nil,
   743  		[]byte{0x29, 0x03, 0x8d, 0x56, 0xba, 0x6d, 0x27, 0x45}},
   744  	{ // 39
   745  		[]byte{
   746  			0x01, 0x01, 0x01, 0x01, 0x01, 0x08, 0x01, 0x01,
   747  			0x01, 0x01, 0x01, 0x01, 0x01, 0x08, 0x01, 0x01,
   748  			0x01, 0x01, 0x01, 0x01, 0x01, 0x08, 0x01, 0x01},
   749  		nil,
   750  		[]byte{0x54, 0x95, 0xc6, 0xab, 0xf1, 0xe5, 0xdf, 0x51}},
   751  	{ // 40
   752  		[]byte{
   753  			0x01, 0x01, 0x01, 0x01, 0x01, 0x04, 0x01, 0x01,
   754  			0x01, 0x01, 0x01, 0x01, 0x01, 0x04, 0x01, 0x01,
   755  			0x01, 0x01, 0x01, 0x01, 0x01, 0x04, 0x01, 0x01},
   756  		nil,
   757  		[]byte{0xae, 0x13, 0xdb, 0xd5, 0x61, 0x48, 0x89, 0x33}},
   758  	{ // 41
   759  		[]byte{
   760  			0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01,
   761  			0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01,
   762  			0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01},
   763  		nil,
   764  		[]byte{0x02, 0x4d, 0x1f, 0xfa, 0x89, 0x04, 0xe3, 0x89}},
   765  	{ // 42
   766  		[]byte{
   767  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x80, 0x01,
   768  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x80, 0x01,
   769  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x80, 0x01},
   770  		nil,
   771  		[]byte{0xd1, 0x39, 0x97, 0x12, 0xf9, 0x9b, 0xf0, 0x2e}},
   772  	{ // 43
   773  		[]byte{
   774  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x40, 0x01,
   775  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x40, 0x01,
   776  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x40, 0x01},
   777  		nil,
   778  		[]byte{0x14, 0xc1, 0xd7, 0xc1, 0xcf, 0xfe, 0xc7, 0x9e}},
   779  	{ // 44
   780  		[]byte{
   781  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x20, 0x01,
   782  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x20, 0x01,
   783  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x20, 0x01},
   784  		nil,
   785  		[]byte{0x1d, 0xe5, 0x27, 0x9d, 0xae, 0x3b, 0xed, 0x6f}},
   786  	{ // 45
   787  		[]byte{
   788  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x10, 0x01,
   789  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x10, 0x01,
   790  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x10, 0x01},
   791  		nil,
   792  		[]byte{0xe9, 0x41, 0xa3, 0x3f, 0x85, 0x50, 0x13, 0x03}},
   793  	{ // 46
   794  		[]byte{
   795  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x08, 0x01,
   796  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x08, 0x01,
   797  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x08, 0x01},
   798  		nil,
   799  		[]byte{0xda, 0x99, 0xdb, 0xbc, 0x9a, 0x03, 0xf3, 0x79}},
   800  	{ // 47
   801  		[]byte{
   802  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x04, 0x01,
   803  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x04, 0x01,
   804  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x04, 0x01},
   805  		nil,
   806  		[]byte{0xb7, 0xfc, 0x92, 0xf9, 0x1d, 0x8e, 0x92, 0xe9}},
   807  	{ // 48
   808  		[]byte{
   809  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01,
   810  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01,
   811  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01},
   812  		nil,
   813  		[]byte{0xae, 0x8e, 0x5c, 0xaa, 0x3c, 0xa0, 0x4e, 0x85}},
   814  	{ // 49
   815  		[]byte{
   816  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x80,
   817  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x80,
   818  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x80},
   819  		nil,
   820  		[]byte{0x9c, 0xc6, 0x2d, 0xf4, 0x3b, 0x6e, 0xed, 0x74}},
   821  	{ // 50
   822  		[]byte{
   823  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x40,
   824  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x40,
   825  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x40},
   826  		nil,
   827  		[]byte{0xd8, 0x63, 0xdb, 0xb5, 0xc5, 0x9a, 0x91, 0xa0}},
   828  	{ // 50
   829  		[]byte{
   830  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x20,
   831  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x20,
   832  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x20},
   833  		nil,
   834  		[]byte{0xa1, 0xab, 0x21, 0x90, 0x54, 0x5b, 0x91, 0xd7}},
   835  	{ // 52
   836  		[]byte{
   837  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x10,
   838  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x10,
   839  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x10},
   840  		nil,
   841  		[]byte{0x08, 0x75, 0x04, 0x1e, 0x64, 0xc5, 0x70, 0xf7}},
   842  	{ // 53
   843  		[]byte{
   844  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x08,
   845  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x08,
   846  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x08},
   847  		nil,
   848  		[]byte{0x5a, 0x59, 0x45, 0x28, 0xbe, 0xbe, 0xf1, 0xcc}},
   849  	{ // 54
   850  		[]byte{
   851  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x04,
   852  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x04,
   853  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x04},
   854  		nil,
   855  		[]byte{0xfc, 0xdb, 0x32, 0x91, 0xde, 0x21, 0xf0, 0xc0}},
   856  	{ // 55
   857  		[]byte{
   858  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02,
   859  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02,
   860  			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02},
   861  		nil,
   862  		[]byte{0x86, 0x9e, 0xfd, 0x7f, 0x9f, 0x26, 0x5a, 0x09}},
   863  }
   864  
   865  // Plaintext for use with Table A.3 tests
   866  var tableA3Plaintext = []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
   867  
   868  // Table A.3 Values To Be Used for the Permutation Operation Known Answer Test
   869  var tableA3Tests = []CryptTest{
   870  	{ // 0
   871  		[]byte{
   872  			0x10, 0x46, 0x91, 0x34, 0x89, 0x98, 0x01, 0x31,
   873  			0x10, 0x46, 0x91, 0x34, 0x89, 0x98, 0x01, 0x31,
   874  			0x10, 0x46, 0x91, 0x34, 0x89, 0x98, 0x01, 0x31,
   875  		},
   876  		nil,
   877  		[]byte{0x88, 0xd5, 0x5e, 0x54, 0xf5, 0x4c, 0x97, 0xb4}},
   878  	{ // 1
   879  		[]byte{
   880  			0x10, 0x07, 0x10, 0x34, 0x89, 0x98, 0x80, 0x20,
   881  			0x10, 0x07, 0x10, 0x34, 0x89, 0x98, 0x80, 0x20,
   882  			0x10, 0x07, 0x10, 0x34, 0x89, 0x98, 0x80, 0x20,
   883  		},
   884  		nil,
   885  		[]byte{0x0c, 0x0c, 0xc0, 0x0c, 0x83, 0xea, 0x48, 0xfd}},
   886  	{ // 2
   887  		[]byte{
   888  			0x10, 0x07, 0x10, 0x34, 0xc8, 0x98, 0x01, 0x20,
   889  			0x10, 0x07, 0x10, 0x34, 0xc8, 0x98, 0x01, 0x20,
   890  			0x10, 0x07, 0x10, 0x34, 0xc8, 0x98, 0x01, 0x20,
   891  		},
   892  		nil,
   893  		[]byte{0x83, 0xbc, 0x8e, 0xf3, 0xa6, 0x57, 0x01, 0x83}},
   894  	{ // 3
   895  		[]byte{
   896  			0x10, 0x46, 0x10, 0x34, 0x89, 0x98, 0x80, 0x20,
   897  			0x10, 0x46, 0x10, 0x34, 0x89, 0x98, 0x80, 0x20,
   898  			0x10, 0x46, 0x10, 0x34, 0x89, 0x98, 0x80, 0x20,
   899  		},
   900  		nil,
   901  		[]byte{0xdf, 0x72, 0x5d, 0xca, 0xd9, 0x4e, 0xa2, 0xe9}},
   902  	{ // 4
   903  		[]byte{
   904  			0x10, 0x86, 0x91, 0x15, 0x19, 0x19, 0x01, 0x01,
   905  			0x10, 0x86, 0x91, 0x15, 0x19, 0x19, 0x01, 0x01,
   906  			0x10, 0x86, 0x91, 0x15, 0x19, 0x19, 0x01, 0x01,
   907  		},
   908  		nil,
   909  		[]byte{0xe6, 0x52, 0xb5, 0x3b, 0x55, 0x0b, 0xe8, 0xb0}},
   910  	{ // 5
   911  		[]byte{
   912  			0x10, 0x86, 0x91, 0x15, 0x19, 0x58, 0x01, 0x01,
   913  			0x10, 0x86, 0x91, 0x15, 0x19, 0x58, 0x01, 0x01,
   914  			0x10, 0x86, 0x91, 0x15, 0x19, 0x58, 0x01, 0x01,
   915  		},
   916  		nil,
   917  		[]byte{0xaf, 0x52, 0x71, 0x20, 0xc4, 0x85, 0xcb, 0xb0}},
   918  	{ // 6
   919  		[]byte{
   920  			0x51, 0x07, 0xb0, 0x15, 0x19, 0x58, 0x01, 0x01,
   921  			0x51, 0x07, 0xb0, 0x15, 0x19, 0x58, 0x01, 0x01,
   922  			0x51, 0x07, 0xb0, 0x15, 0x19, 0x58, 0x01, 0x01,
   923  		},
   924  		nil,
   925  		[]byte{0x0f, 0x04, 0xce, 0x39, 0x3d, 0xb9, 0x26, 0xd5}},
   926  	{ // 7
   927  		[]byte{
   928  			0x10, 0x07, 0xb0, 0x15, 0x19, 0x19, 0x01, 0x01,
   929  			0x10, 0x07, 0xb0, 0x15, 0x19, 0x19, 0x01, 0x01,
   930  			0x10, 0x07, 0xb0, 0x15, 0x19, 0x19, 0x01, 0x01,
   931  		},
   932  		nil,
   933  		[]byte{0xc9, 0xf0, 0x0f, 0xfc, 0x74, 0x07, 0x90, 0x67}},
   934  	{ // 8
   935  		[]byte{
   936  			0x31, 0x07, 0x91, 0x54, 0x98, 0x08, 0x01, 0x01,
   937  			0x31, 0x07, 0x91, 0x54, 0x98, 0x08, 0x01, 0x01,
   938  			0x31, 0x07, 0x91, 0x54, 0x98, 0x08, 0x01, 0x01,
   939  		},
   940  		nil,
   941  		[]byte{0x7c, 0xfd, 0x82, 0xa5, 0x93, 0x25, 0x2b, 0x4e}},
   942  	{ // 9
   943  		[]byte{
   944  			0x31, 0x07, 0x91, 0x94, 0x98, 0x08, 0x01, 0x01,
   945  			0x31, 0x07, 0x91, 0x94, 0x98, 0x08, 0x01, 0x01,
   946  			0x31, 0x07, 0x91, 0x94, 0x98, 0x08, 0x01, 0x01,
   947  		},
   948  		nil,
   949  		[]byte{0xcb, 0x49, 0xa2, 0xf9, 0xe9, 0x13, 0x63, 0xe3}},
   950  	{ // 10
   951  		[]byte{
   952  			0x10, 0x07, 0x91, 0x15, 0xb9, 0x08, 0x01, 0x40,
   953  			0x10, 0x07, 0x91, 0x15, 0xb9, 0x08, 0x01, 0x40,
   954  			0x10, 0x07, 0x91, 0x15, 0xb9, 0x08, 0x01, 0x40,
   955  		},
   956  		nil,
   957  		[]byte{0x00, 0xb5, 0x88, 0xbe, 0x70, 0xd2, 0x3f, 0x56}},
   958  	{ // 11
   959  		[]byte{
   960  			0x31, 0x07, 0x91, 0x15, 0x98, 0x08, 0x01, 0x40,
   961  			0x31, 0x07, 0x91, 0x15, 0x98, 0x08, 0x01, 0x40,
   962  			0x31, 0x07, 0x91, 0x15, 0x98, 0x08, 0x01, 0x40,
   963  		},
   964  		nil,
   965  		[]byte{0x40, 0x6a, 0x9a, 0x6a, 0xb4, 0x33, 0x99, 0xae}},
   966  	{ // 12
   967  		[]byte{
   968  			0x10, 0x07, 0xd0, 0x15, 0x89, 0x98, 0x01, 0x01,
   969  			0x10, 0x07, 0xd0, 0x15, 0x89, 0x98, 0x01, 0x01,
   970  			0x10, 0x07, 0xd0, 0x15, 0x89, 0x98, 0x01, 0x01,
   971  		},
   972  		nil,
   973  		[]byte{0x6c, 0xb7, 0x73, 0x61, 0x1d, 0xca, 0x9a, 0xda}},
   974  	{ // 13
   975  		[]byte{
   976  			0x91, 0x07, 0x91, 0x15, 0x89, 0x98, 0x01, 0x01,
   977  			0x91, 0x07, 0x91, 0x15, 0x89, 0x98, 0x01, 0x01,
   978  			0x91, 0x07, 0x91, 0x15, 0x89, 0x98, 0x01, 0x01,
   979  		},
   980  		nil,
   981  		[]byte{0x67, 0xfd, 0x21, 0xc1, 0x7d, 0xbb, 0x5d, 0x70}},
   982  	{ // 14
   983  		[]byte{
   984  			0x91, 0x07, 0xd0, 0x15, 0x89, 0x19, 0x01, 0x01,
   985  			0x91, 0x07, 0xd0, 0x15, 0x89, 0x19, 0x01, 0x01,
   986  			0x91, 0x07, 0xd0, 0x15, 0x89, 0x19, 0x01, 0x01,
   987  		},
   988  		nil,
   989  		[]byte{0x95, 0x92, 0xcb, 0x41, 0x10, 0x43, 0x07, 0x87}},
   990  	{ // 15
   991  		[]byte{
   992  			0x10, 0x07, 0xd0, 0x15, 0x98, 0x98, 0x01, 0x20,
   993  			0x10, 0x07, 0xd0, 0x15, 0x98, 0x98, 0x01, 0x20,
   994  			0x10, 0x07, 0xd0, 0x15, 0x98, 0x98, 0x01, 0x20,
   995  		},
   996  		nil,
   997  		[]byte{0xa6, 0xb7, 0xff, 0x68, 0xa3, 0x18, 0xdd, 0xd3}},
   998  	{ // 16
   999  		[]byte{
  1000  			0x10, 0x07, 0x94, 0x04, 0x98, 0x19, 0x01, 0x01,
  1001  			0x10, 0x07, 0x94, 0x04, 0x98, 0x19, 0x01, 0x01,
  1002  			0x10, 0x07, 0x94, 0x04, 0x98, 0x19, 0x01, 0x01,
  1003  		},
  1004  		nil,
  1005  		[]byte{0x4d, 0x10, 0x21, 0x96, 0xc9, 0x14, 0xca, 0x16}},
  1006  	{ // 17
  1007  		[]byte{
  1008  			0x01, 0x07, 0x91, 0x04, 0x91, 0x19, 0x04, 0x01,
  1009  			0x01, 0x07, 0x91, 0x04, 0x91, 0x19, 0x04, 0x01,
  1010  			0x01, 0x07, 0x91, 0x04, 0x91, 0x19, 0x04, 0x01,
  1011  		},
  1012  		nil,
  1013  		[]byte{0x2d, 0xfa, 0x9f, 0x45, 0x73, 0x59, 0x49, 0x65}},
  1014  	{ // 18
  1015  		[]byte{
  1016  			0x01, 0x07, 0x91, 0x04, 0x91, 0x19, 0x01, 0x01,
  1017  			0x01, 0x07, 0x91, 0x04, 0x91, 0x19, 0x01, 0x01,
  1018  			0x01, 0x07, 0x91, 0x04, 0x91, 0x19, 0x01, 0x01,
  1019  		},
  1020  		nil,
  1021  		[]byte{0xb4, 0x66, 0x04, 0x81, 0x6c, 0x0e, 0x07, 0x74}},
  1022  	{ // 19
  1023  		[]byte{
  1024  			0x01, 0x07, 0x94, 0x04, 0x91, 0x19, 0x04, 0x01,
  1025  			0x01, 0x07, 0x94, 0x04, 0x91, 0x19, 0x04, 0x01,
  1026  			0x01, 0x07, 0x94, 0x04, 0x91, 0x19, 0x04, 0x01,
  1027  		},
  1028  		nil,
  1029  		[]byte{0x6e, 0x7e, 0x62, 0x21, 0xa4, 0xf3, 0x4e, 0x87}},
  1030  	{ // 20
  1031  		[]byte{
  1032  			0x19, 0x07, 0x92, 0x10, 0x98, 0x1a, 0x01, 0x01,
  1033  			0x19, 0x07, 0x92, 0x10, 0x98, 0x1a, 0x01, 0x01,
  1034  			0x19, 0x07, 0x92, 0x10, 0x98, 0x1a, 0x01, 0x01,
  1035  		},
  1036  		nil,
  1037  		[]byte{0xaa, 0x85, 0xe7, 0x46, 0x43, 0x23, 0x31, 0x99}},
  1038  	{ // 21
  1039  		[]byte{
  1040  			0x10, 0x07, 0x91, 0x19, 0x98, 0x19, 0x08, 0x01,
  1041  			0x10, 0x07, 0x91, 0x19, 0x98, 0x19, 0x08, 0x01,
  1042  			0x10, 0x07, 0x91, 0x19, 0x98, 0x19, 0x08, 0x01,
  1043  		},
  1044  		nil,
  1045  		[]byte{0x2e, 0x5a, 0x19, 0xdb, 0x4d, 0x19, 0x62, 0xd6}},
  1046  	{ // 22
  1047  		[]byte{
  1048  			0x10, 0x07, 0x91, 0x19, 0x98, 0x1a, 0x08, 0x01,
  1049  			0x10, 0x07, 0x91, 0x19, 0x98, 0x1a, 0x08, 0x01,
  1050  			0x10, 0x07, 0x91, 0x19, 0x98, 0x1a, 0x08, 0x01,
  1051  		},
  1052  		nil,
  1053  		[]byte{0x23, 0xa8, 0x66, 0xa8, 0x09, 0xd3, 0x08, 0x94}},
  1054  	{ // 23
  1055  		[]byte{
  1056  			0x10, 0x07, 0x92, 0x10, 0x98, 0x19, 0x01, 0x01,
  1057  			0x10, 0x07, 0x92, 0x10, 0x98, 0x19, 0x01, 0x01,
  1058  			0x10, 0x07, 0x92, 0x10, 0x98, 0x19, 0x01, 0x01,
  1059  		},
  1060  		nil,
  1061  		[]byte{0xd8, 0x12, 0xd9, 0x61, 0xf0, 0x17, 0xd3, 0x20}},
  1062  	{ // 24
  1063  		[]byte{
  1064  			0x10, 0x07, 0x91, 0x15, 0x98, 0x19, 0x01, 0x0b,
  1065  			0x10, 0x07, 0x91, 0x15, 0x98, 0x19, 0x01, 0x0b,
  1066  			0x10, 0x07, 0x91, 0x15, 0x98, 0x19, 0x01, 0x0b,
  1067  		},
  1068  		nil,
  1069  		[]byte{0x05, 0x56, 0x05, 0x81, 0x6e, 0x58, 0x60, 0x8f}},
  1070  	{ // 25
  1071  		[]byte{
  1072  			0x10, 0x04, 0x80, 0x15, 0x98, 0x19, 0x01, 0x01,
  1073  			0x10, 0x04, 0x80, 0x15, 0x98, 0x19, 0x01, 0x01,
  1074  			0x10, 0x04, 0x80, 0x15, 0x98, 0x19, 0x01, 0x01,
  1075  		},
  1076  		nil,
  1077  		[]byte{0xab, 0xd8, 0x8e, 0x8b, 0x1b, 0x77, 0x16, 0xf1}},
  1078  	{ // 26
  1079  		[]byte{
  1080  			0x10, 0x04, 0x80, 0x15, 0x98, 0x19, 0x01, 0x02,
  1081  			0x10, 0x04, 0x80, 0x15, 0x98, 0x19, 0x01, 0x02,
  1082  			0x10, 0x04, 0x80, 0x15, 0x98, 0x19, 0x01, 0x02,
  1083  		},
  1084  		nil,
  1085  		[]byte{0x53, 0x7a, 0xc9, 0x5b, 0xe6, 0x9d, 0xa1, 0xe1}},
  1086  	{ // 27
  1087  		[]byte{
  1088  			0x10, 0x04, 0x80, 0x15, 0x98, 0x19, 0x01, 0x08,
  1089  			0x10, 0x04, 0x80, 0x15, 0x98, 0x19, 0x01, 0x08,
  1090  			0x10, 0x04, 0x80, 0x15, 0x98, 0x19, 0x01, 0x08,
  1091  		},
  1092  		nil,
  1093  		[]byte{0xae, 0xd0, 0xf6, 0xae, 0x3c, 0x25, 0xcd, 0xd8}},
  1094  	{ // 28
  1095  		[]byte{
  1096  			0x10, 0x02, 0x91, 0x15, 0x98, 0x10, 0x01, 0x04,
  1097  			0x10, 0x02, 0x91, 0x15, 0x98, 0x10, 0x01, 0x04,
  1098  			0x10, 0x02, 0x91, 0x15, 0x98, 0x10, 0x01, 0x04,
  1099  		},
  1100  		nil,
  1101  		[]byte{0xb3, 0xe3, 0x5a, 0x5e, 0xe5, 0x3e, 0x7b, 0x8d}},
  1102  	{ // 29
  1103  		[]byte{
  1104  			0x10, 0x02, 0x91, 0x15, 0x98, 0x19, 0x01, 0x04,
  1105  			0x10, 0x02, 0x91, 0x15, 0x98, 0x19, 0x01, 0x04,
  1106  			0x10, 0x02, 0x91, 0x15, 0x98, 0x19, 0x01, 0x04,
  1107  		},
  1108  		nil,
  1109  		[]byte{0x61, 0xc7, 0x9c, 0x71, 0x92, 0x1a, 0x2e, 0xf8}},
  1110  	{ // 30
  1111  		[]byte{
  1112  			0x10, 0x02, 0x91, 0x15, 0x98, 0x10, 0x02, 0x01,
  1113  			0x10, 0x02, 0x91, 0x15, 0x98, 0x10, 0x02, 0x01,
  1114  			0x10, 0x02, 0x91, 0x15, 0x98, 0x10, 0x02, 0x01,
  1115  		},
  1116  		nil,
  1117  		[]byte{0xe2, 0xf5, 0x72, 0x8f, 0x09, 0x95, 0x01, 0x3c}},
  1118  	{ // 31
  1119  		[]byte{
  1120  			0x10, 0x02, 0x91, 0x16, 0x98, 0x10, 0x01, 0x01,
  1121  			0x10, 0x02, 0x91, 0x16, 0x98, 0x10, 0x01, 0x01,
  1122  			0x10, 0x02, 0x91, 0x16, 0x98, 0x10, 0x01, 0x01,
  1123  		},
  1124  		nil,
  1125  		[]byte{0x1a, 0xea, 0xc3, 0x9a, 0x61, 0xf0, 0xa4, 0x64}},
  1126  }
  1127  
  1128  // Table A.4 Values To Be Used for the Substitution Table Known Answer Test
  1129  var tableA4Tests = []CryptTest{
  1130  	{ // 0
  1131  		[]byte{
  1132  			0x7c, 0xa1, 0x10, 0x45, 0x4a, 0x1a, 0x6e, 0x57,
  1133  			0x7c, 0xa1, 0x10, 0x45, 0x4a, 0x1a, 0x6e, 0x57,
  1134  			0x7c, 0xa1, 0x10, 0x45, 0x4a, 0x1a, 0x6e, 0x57},
  1135  		[]byte{0x01, 0xa1, 0xd6, 0xd0, 0x39, 0x77, 0x67, 0x42},
  1136  		[]byte{0x69, 0x0f, 0x5b, 0x0d, 0x9a, 0x26, 0x93, 0x9b}},
  1137  	{ // 1
  1138  		[]byte{
  1139  			0x01, 0x31, 0xd9, 0x61, 0x9d, 0xc1, 0x37, 0x6e,
  1140  			0x01, 0x31, 0xd9, 0x61, 0x9d, 0xc1, 0x37, 0x6e,
  1141  			0x01, 0x31, 0xd9, 0x61, 0x9d, 0xc1, 0x37, 0x6e},
  1142  		[]byte{0x5c, 0xd5, 0x4c, 0xa8, 0x3d, 0xef, 0x57, 0xda},
  1143  		[]byte{0x7a, 0x38, 0x9d, 0x10, 0x35, 0x4b, 0xd2, 0x71}},
  1144  	{ // 2
  1145  		[]byte{
  1146  			0x07, 0xa1, 0x13, 0x3e, 0x4a, 0x0b, 0x26, 0x86,
  1147  			0x07, 0xa1, 0x13, 0x3e, 0x4a, 0x0b, 0x26, 0x86,
  1148  			0x07, 0xa1, 0x13, 0x3e, 0x4a, 0x0b, 0x26, 0x86},
  1149  		[]byte{0x02, 0x48, 0xd4, 0x38, 0x06, 0xf6, 0x71, 0x72},
  1150  		[]byte{0x86, 0x8e, 0xbb, 0x51, 0xca, 0xb4, 0x59, 0x9a}},
  1151  	{ // 3
  1152  		[]byte{
  1153  			0x38, 0x49, 0x67, 0x4c, 0x26, 0x02, 0x31, 0x9e,
  1154  			0x38, 0x49, 0x67, 0x4c, 0x26, 0x02, 0x31, 0x9e,
  1155  			0x38, 0x49, 0x67, 0x4c, 0x26, 0x02, 0x31, 0x9e},
  1156  		[]byte{0x51, 0x45, 0x4b, 0x58, 0x2d, 0xdf, 0x44, 0x0a},
  1157  		[]byte{0x71, 0x78, 0x87, 0x6e, 0x01, 0xf1, 0x9b, 0x2a}},
  1158  	{ // 4
  1159  		[]byte{
  1160  			0x04, 0xb9, 0x15, 0xba, 0x43, 0xfe, 0xb5, 0xb6,
  1161  			0x04, 0xb9, 0x15, 0xba, 0x43, 0xfe, 0xb5, 0xb6,
  1162  			0x04, 0xb9, 0x15, 0xba, 0x43, 0xfe, 0xb5, 0xb6},
  1163  		[]byte{0x42, 0xfd, 0x44, 0x30, 0x59, 0x57, 0x7f, 0xa2},
  1164  		[]byte{0xaf, 0x37, 0xfb, 0x42, 0x1f, 0x8c, 0x40, 0x95}},
  1165  	{ // 5
  1166  		[]byte{
  1167  			0x01, 0x13, 0xb9, 0x70, 0xfd, 0x34, 0xf2, 0xce,
  1168  			0x01, 0x13, 0xb9, 0x70, 0xfd, 0x34, 0xf2, 0xce,
  1169  			0x01, 0x13, 0xb9, 0x70, 0xfd, 0x34, 0xf2, 0xce},
  1170  		[]byte{0x05, 0x9b, 0x5e, 0x08, 0x51, 0xcf, 0x14, 0x3a},
  1171  		[]byte{0x86, 0xa5, 0x60, 0xf1, 0x0e, 0xc6, 0xd8, 0x5b}},
  1172  	{ // 6
  1173  		[]byte{
  1174  			0x01, 0x70, 0xf1, 0x75, 0x46, 0x8f, 0xb5, 0xe6,
  1175  			0x01, 0x70, 0xf1, 0x75, 0x46, 0x8f, 0xb5, 0xe6,
  1176  			0x01, 0x70, 0xf1, 0x75, 0x46, 0x8f, 0xb5, 0xe6},
  1177  		[]byte{0x07, 0x56, 0xd8, 0xe0, 0x77, 0x47, 0x61, 0xd2},
  1178  		[]byte{0x0c, 0xd3, 0xda, 0x02, 0x00, 0x21, 0xdc, 0x09}},
  1179  	{ // 7
  1180  		[]byte{
  1181  			0x43, 0x29, 0x7f, 0xad, 0x38, 0xe3, 0x73, 0xfe,
  1182  			0x43, 0x29, 0x7f, 0xad, 0x38, 0xe3, 0x73, 0xfe,
  1183  			0x43, 0x29, 0x7f, 0xad, 0x38, 0xe3, 0x73, 0xfe},
  1184  		[]byte{0x76, 0x25, 0x14, 0xb8, 0x29, 0xbf, 0x48, 0x6a},
  1185  		[]byte{0xea, 0x67, 0x6b, 0x2c, 0xb7, 0xdb, 0x2b, 0x7a}},
  1186  	{ // 8
  1187  		[]byte{
  1188  			0x07, 0xa7, 0x13, 0x70, 0x45, 0xda, 0x2a, 0x16,
  1189  			0x07, 0xa7, 0x13, 0x70, 0x45, 0xda, 0x2a, 0x16,
  1190  			0x07, 0xa7, 0x13, 0x70, 0x45, 0xda, 0x2a, 0x16},
  1191  		[]byte{0x3b, 0xdd, 0x11, 0x90, 0x49, 0x37, 0x28, 0x02},
  1192  		[]byte{0xdf, 0xd6, 0x4a, 0x81, 0x5c, 0xaf, 0x1a, 0x0f}},
  1193  	{ // 9
  1194  		[]byte{
  1195  			0x04, 0x68, 0x91, 0x04, 0xc2, 0xfd, 0x3b, 0x2f,
  1196  			0x04, 0x68, 0x91, 0x04, 0xc2, 0xfd, 0x3b, 0x2f,
  1197  			0x04, 0x68, 0x91, 0x04, 0xc2, 0xfd, 0x3b, 0x2f},
  1198  		[]byte{0x26, 0x95, 0x5f, 0x68, 0x35, 0xaf, 0x60, 0x9a},
  1199  		[]byte{0x5c, 0x51, 0x3c, 0x9c, 0x48, 0x86, 0xc0, 0x88}},
  1200  	{ // 10
  1201  		[]byte{
  1202  			0x37, 0xd0, 0x6b, 0xb5, 0x16, 0xcb, 0x75, 0x46,
  1203  			0x37, 0xd0, 0x6b, 0xb5, 0x16, 0xcb, 0x75, 0x46,
  1204  			0x37, 0xd0, 0x6b, 0xb5, 0x16, 0xcb, 0x75, 0x46},
  1205  		[]byte{0x16, 0x4d, 0x5e, 0x40, 0x4f, 0x27, 0x52, 0x32},
  1206  		[]byte{0x0a, 0x2a, 0xee, 0xae, 0x3f, 0xf4, 0xab, 0x77}},
  1207  	{ // 11
  1208  		[]byte{
  1209  			0x1f, 0x08, 0x26, 0x0d, 0x1a, 0xc2, 0x46, 0x5e,
  1210  			0x1f, 0x08, 0x26, 0x0d, 0x1a, 0xc2, 0x46, 0x5e,
  1211  			0x1f, 0x08, 0x26, 0x0d, 0x1a, 0xc2, 0x46, 0x5e},
  1212  		[]byte{0x6b, 0x05, 0x6e, 0x18, 0x75, 0x9f, 0x5c, 0xca},
  1213  		[]byte{0xef, 0x1b, 0xf0, 0x3e, 0x5d, 0xfa, 0x57, 0x5a}},
  1214  	{ // 12
  1215  		[]byte{
  1216  			0x58, 0x40, 0x23, 0x64, 0x1a, 0xba, 0x61, 0x76,
  1217  			0x58, 0x40, 0x23, 0x64, 0x1a, 0xba, 0x61, 0x76,
  1218  			0x58, 0x40, 0x23, 0x64, 0x1a, 0xba, 0x61, 0x76},
  1219  		[]byte{0x00, 0x4b, 0xd6, 0xef, 0x09, 0x17, 0x60, 0x62},
  1220  		[]byte{0x88, 0xbf, 0x0d, 0xb6, 0xd7, 0x0d, 0xee, 0x56}},
  1221  	{ // 13
  1222  		[]byte{
  1223  			0x02, 0x58, 0x16, 0x16, 0x46, 0x29, 0xb0, 0x07,
  1224  			0x02, 0x58, 0x16, 0x16, 0x46, 0x29, 0xb0, 0x07,
  1225  			0x02, 0x58, 0x16, 0x16, 0x46, 0x29, 0xb0, 0x07},
  1226  		[]byte{0x48, 0x0d, 0x39, 0x00, 0x6e, 0xe7, 0x62, 0xf2},
  1227  		[]byte{0xa1, 0xf9, 0x91, 0x55, 0x41, 0x02, 0x0b, 0x56}},
  1228  	{ // 14
  1229  		[]byte{
  1230  			0x49, 0x79, 0x3e, 0xbc, 0x79, 0xb3, 0x25, 0x8f,
  1231  			0x49, 0x79, 0x3e, 0xbc, 0x79, 0xb3, 0x25, 0x8f,
  1232  			0x49, 0x79, 0x3e, 0xbc, 0x79, 0xb3, 0x25, 0x8f},
  1233  		[]byte{0x43, 0x75, 0x40, 0xc8, 0x69, 0x8f, 0x3c, 0xfa},
  1234  		[]byte{0x6f, 0xbf, 0x1c, 0xaf, 0xcf, 0xfd, 0x05, 0x56}},
  1235  	{ // 15
  1236  		[]byte{
  1237  			0x4f, 0xb0, 0x5e, 0x15, 0x15, 0xab, 0x73, 0xa7,
  1238  			0x4f, 0xb0, 0x5e, 0x15, 0x15, 0xab, 0x73, 0xa7,
  1239  			0x4f, 0xb0, 0x5e, 0x15, 0x15, 0xab, 0x73, 0xa7},
  1240  		[]byte{0x07, 0x2d, 0x43, 0xa0, 0x77, 0x07, 0x52, 0x92},
  1241  		[]byte{0x2f, 0x22, 0xe4, 0x9b, 0xab, 0x7c, 0xa1, 0xac}},
  1242  	{ // 16
  1243  		[]byte{
  1244  			0x49, 0xe9, 0x5d, 0x6d, 0x4c, 0xa2, 0x29, 0xbf,
  1245  			0x49, 0xe9, 0x5d, 0x6d, 0x4c, 0xa2, 0x29, 0xbf,
  1246  			0x49, 0xe9, 0x5d, 0x6d, 0x4c, 0xa2, 0x29, 0xbf},
  1247  		[]byte{0x02, 0xfe, 0x55, 0x77, 0x81, 0x17, 0xf1, 0x2a},
  1248  		[]byte{0x5a, 0x6b, 0x61, 0x2c, 0xc2, 0x6c, 0xce, 0x4a}},
  1249  	{ // 17
  1250  		[]byte{
  1251  			0x01, 0x83, 0x10, 0xdc, 0x40, 0x9b, 0x26, 0xd6,
  1252  			0x01, 0x83, 0x10, 0xdc, 0x40, 0x9b, 0x26, 0xd6,
  1253  			0x01, 0x83, 0x10, 0xdc, 0x40, 0x9b, 0x26, 0xd6},
  1254  		[]byte{0x1d, 0x9d, 0x5c, 0x50, 0x18, 0xf7, 0x28, 0xc2},
  1255  		[]byte{0x5f, 0x4c, 0x03, 0x8e, 0xd1, 0x2b, 0x2e, 0x41}},
  1256  	{ // 18
  1257  		[]byte{
  1258  			0x1c, 0x58, 0x7f, 0x1c, 0x13, 0x92, 0x4f, 0xef,
  1259  			0x1c, 0x58, 0x7f, 0x1c, 0x13, 0x92, 0x4f, 0xef,
  1260  			0x1c, 0x58, 0x7f, 0x1c, 0x13, 0x92, 0x4f, 0xef},
  1261  		[]byte{0x30, 0x55, 0x32, 0x28, 0x6d, 0x6f, 0x29, 0x5a},
  1262  		[]byte{0x63, 0xfa, 0xc0, 0xd0, 0x34, 0xd9, 0xf7, 0x93}},
  1263  }
  1264  
  1265  func newCipher(key []byte) cipher.Block {
  1266  	c, err := des.NewCipher(key)
  1267  	if err != nil {
  1268  		panic("NewCipher failed: " + err.Error())
  1269  	}
  1270  	return c
  1271  }
  1272  
  1273  // Use the known weak keys to test DES implementation
  1274  func TestWeakKeys(t *testing.T) {
  1275  	for i, tt := range weakKeyTests {
  1276  		var encrypt = func(in []byte) (out []byte) {
  1277  			c := newCipher(tt.key)
  1278  			out = make([]byte, len(in))
  1279  			c.Encrypt(out, in)
  1280  			return
  1281  		}
  1282  
  1283  		// Encrypting twice with a DES weak
  1284  		// key should reproduce the original input
  1285  		result := encrypt(tt.in)
  1286  		result = encrypt(result)
  1287  
  1288  		if !bytes.Equal(result, tt.in) {
  1289  			t.Errorf("#%d: result: %x want: %x", i, result, tt.in)
  1290  		}
  1291  	}
  1292  }
  1293  
  1294  // Use the known semi-weak key pairs to test DES implementation
  1295  func TestSemiWeakKeyPairs(t *testing.T) {
  1296  	for i, tt := range semiWeakKeyTests {
  1297  		var encrypt = func(key, in []byte) (out []byte) {
  1298  			c := newCipher(key)
  1299  			out = make([]byte, len(in))
  1300  			c.Encrypt(out, in)
  1301  			return
  1302  		}
  1303  
  1304  		// Encrypting with one member of the semi-weak pair
  1305  		// and then encrypting the result with the other member
  1306  		// should reproduce the original input.
  1307  		result := encrypt(tt.key, tt.in)
  1308  		result = encrypt(tt.out, result)
  1309  
  1310  		if !bytes.Equal(result, tt.in) {
  1311  			t.Errorf("#%d: result: %x want: %x", i, result, tt.in)
  1312  		}
  1313  	}
  1314  }
  1315  
  1316  func TestDESEncryptBlock(t *testing.T) {
  1317  	for i, tt := range encryptDESTests {
  1318  		c := newCipher(tt.key)
  1319  		out := make([]byte, len(tt.in))
  1320  		c.Encrypt(out, tt.in)
  1321  
  1322  		if !bytes.Equal(out, tt.out) {
  1323  			t.Errorf("#%d: result: %x want: %x", i, out, tt.out)
  1324  		}
  1325  	}
  1326  }
  1327  
  1328  func TestDESDecryptBlock(t *testing.T) {
  1329  	for i, tt := range encryptDESTests {
  1330  		c := newCipher(tt.key)
  1331  		plain := make([]byte, len(tt.in))
  1332  		c.Decrypt(plain, tt.out)
  1333  
  1334  		if !bytes.Equal(plain, tt.in) {
  1335  			t.Errorf("#%d: result: %x want: %x", i, plain, tt.in)
  1336  		}
  1337  	}
  1338  }
  1339  
  1340  func TestEncryptTripleDES(t *testing.T) {
  1341  	for i, tt := range encryptTripleDESTests {
  1342  		c, _ := des.NewTripleDESCipher(tt.key)
  1343  		out := make([]byte, len(tt.in))
  1344  		c.Encrypt(out, tt.in)
  1345  
  1346  		if !bytes.Equal(out, tt.out) {
  1347  			t.Errorf("#%d: result: %x want: %x", i, out, tt.out)
  1348  		}
  1349  	}
  1350  }
  1351  
  1352  func TestDecryptTripleDES(t *testing.T) {
  1353  	for i, tt := range encryptTripleDESTests {
  1354  		c, _ := des.NewTripleDESCipher(tt.key)
  1355  
  1356  		plain := make([]byte, len(tt.in))
  1357  		c.Decrypt(plain, tt.out)
  1358  
  1359  		if !bytes.Equal(plain, tt.in) {
  1360  			t.Errorf("#%d: result: %x want: %x", i, plain, tt.in)
  1361  		}
  1362  	}
  1363  }
  1364  
  1365  // Defined in Pub 800-20
  1366  func TestVariablePlaintextKnownAnswer(t *testing.T) {
  1367  	for i, tt := range tableA1Tests {
  1368  		c, _ := des.NewTripleDESCipher(tableA1Key)
  1369  
  1370  		out := make([]byte, len(tt.in))
  1371  		c.Encrypt(out, tt.in)
  1372  
  1373  		if !bytes.Equal(out, tt.out) {
  1374  			t.Errorf("#%d: result: %x want: %x", i, out, tt.out)
  1375  		}
  1376  	}
  1377  }
  1378  
  1379  // Defined in Pub 800-20
  1380  func TestVariableCiphertextKnownAnswer(t *testing.T) {
  1381  	for i, tt := range tableA1Tests {
  1382  		c, _ := des.NewTripleDESCipher(tableA1Key)
  1383  
  1384  		plain := make([]byte, len(tt.out))
  1385  		c.Decrypt(plain, tt.out)
  1386  
  1387  		if !bytes.Equal(plain, tt.in) {
  1388  			t.Errorf("#%d: result: %x want: %x", i, plain, tt.in)
  1389  		}
  1390  	}
  1391  }
  1392  
  1393  // Defined in Pub 800-20
  1394  // Encrypting the Table A.1 ciphertext with the
  1395  // 0x01... key produces the original plaintext
  1396  func TestInversePermutationKnownAnswer(t *testing.T) {
  1397  	for i, tt := range tableA1Tests {
  1398  		c, _ := des.NewTripleDESCipher(tableA1Key)
  1399  
  1400  		plain := make([]byte, len(tt.in))
  1401  		c.Encrypt(plain, tt.out)
  1402  
  1403  		if !bytes.Equal(plain, tt.in) {
  1404  			t.Errorf("#%d: result: %x want: %x", i, plain, tt.in)
  1405  		}
  1406  	}
  1407  }
  1408  
  1409  // Defined in Pub 800-20
  1410  // Decrypting the Table A.1 plaintext with the
  1411  // 0x01... key produces the corresponding ciphertext
  1412  func TestInitialPermutationKnownAnswer(t *testing.T) {
  1413  	for i, tt := range tableA1Tests {
  1414  		c, _ := des.NewTripleDESCipher(tableA1Key)
  1415  
  1416  		out := make([]byte, len(tt.in))
  1417  		c.Decrypt(out, tt.in)
  1418  
  1419  		if !bytes.Equal(out, tt.out) {
  1420  			t.Errorf("#%d: result: %x want: %x", i, out, tt.out)
  1421  		}
  1422  	}
  1423  }
  1424  
  1425  // Defined in Pub 800-20
  1426  func TestVariableKeyKnownAnswerEncrypt(t *testing.T) {
  1427  	for i, tt := range tableA2Tests {
  1428  		c, _ := des.NewTripleDESCipher(tt.key)
  1429  
  1430  		out := make([]byte, len(tableA2Plaintext))
  1431  		c.Encrypt(out, tableA2Plaintext)
  1432  
  1433  		if !bytes.Equal(out, tt.out) {
  1434  			t.Errorf("#%d: result: %x want: %x", i, out, tt.out)
  1435  		}
  1436  	}
  1437  }
  1438  
  1439  // Defined in Pub 800-20
  1440  func TestVariableKeyKnownAnswerDecrypt(t *testing.T) {
  1441  	for i, tt := range tableA2Tests {
  1442  		c, _ := des.NewTripleDESCipher(tt.key)
  1443  
  1444  		out := make([]byte, len(tt.out))
  1445  		c.Decrypt(out, tt.out)
  1446  
  1447  		if !bytes.Equal(out, tableA2Plaintext) {
  1448  			t.Errorf("#%d: result: %x want: %x", i, out, tableA2Plaintext)
  1449  		}
  1450  	}
  1451  }
  1452  
  1453  // Defined in Pub 800-20
  1454  func TestPermutationOperationKnownAnswerEncrypt(t *testing.T) {
  1455  	for i, tt := range tableA3Tests {
  1456  		c, _ := des.NewTripleDESCipher(tt.key)
  1457  
  1458  		out := make([]byte, len(tableA3Plaintext))
  1459  		c.Encrypt(out, tableA3Plaintext)
  1460  
  1461  		if !bytes.Equal(out, tt.out) {
  1462  			t.Errorf("#%d: result: %x want: %x", i, out, tt.out)
  1463  		}
  1464  	}
  1465  }
  1466  
  1467  // Defined in Pub 800-20
  1468  func TestPermutationOperationKnownAnswerDecrypt(t *testing.T) {
  1469  	for i, tt := range tableA3Tests {
  1470  		c, _ := des.NewTripleDESCipher(tt.key)
  1471  
  1472  		out := make([]byte, len(tt.out))
  1473  		c.Decrypt(out, tt.out)
  1474  
  1475  		if !bytes.Equal(out, tableA3Plaintext) {
  1476  			t.Errorf("#%d: result: %x want: %x", i, out, tableA3Plaintext)
  1477  		}
  1478  	}
  1479  }
  1480  
  1481  // Defined in Pub 800-20
  1482  func TestSubstitutionTableKnownAnswerEncrypt(t *testing.T) {
  1483  	for i, tt := range tableA4Tests {
  1484  		c, _ := des.NewTripleDESCipher(tt.key)
  1485  
  1486  		out := make([]byte, len(tt.in))
  1487  		c.Encrypt(out, tt.in)
  1488  
  1489  		if !bytes.Equal(out, tt.out) {
  1490  			t.Errorf("#%d: result: %x want: %x", i, out, tt.out)
  1491  		}
  1492  	}
  1493  }
  1494  
  1495  // Defined in Pub 800-20
  1496  func TestSubstitutionTableKnownAnswerDecrypt(t *testing.T) {
  1497  	for i, tt := range tableA4Tests {
  1498  		c, _ := des.NewTripleDESCipher(tt.key)
  1499  
  1500  		out := make([]byte, len(tt.out))
  1501  		c.Decrypt(out, tt.out)
  1502  
  1503  		if !bytes.Equal(out, tt.in) {
  1504  			t.Errorf("#%d: result: %x want: %x", i, out, tt.in)
  1505  		}
  1506  	}
  1507  }
  1508  
  1509  func BenchmarkEncrypt(b *testing.B) {
  1510  	tt := encryptDESTests[0]
  1511  	c, err := des.NewCipher(tt.key)
  1512  	if err != nil {
  1513  		b.Fatal("NewCipher:", err)
  1514  	}
  1515  	out := make([]byte, len(tt.in))
  1516  	b.SetBytes(int64(len(out)))
  1517  	b.ResetTimer()
  1518  	for i := 0; i < b.N; i++ {
  1519  		c.Encrypt(out, tt.in)
  1520  	}
  1521  }
  1522  
  1523  func BenchmarkDecrypt(b *testing.B) {
  1524  	tt := encryptDESTests[0]
  1525  	c, err := des.NewCipher(tt.key)
  1526  	if err != nil {
  1527  		b.Fatal("NewCipher:", err)
  1528  	}
  1529  	out := make([]byte, len(tt.out))
  1530  	b.SetBytes(int64(len(out)))
  1531  	b.ResetTimer()
  1532  	for i := 0; i < b.N; i++ {
  1533  		c.Decrypt(out, tt.out)
  1534  	}
  1535  }
  1536  
  1537  func BenchmarkTDESEncrypt(b *testing.B) {
  1538  	tt := encryptTripleDESTests[0]
  1539  	c, err := des.NewTripleDESCipher(tt.key)
  1540  	if err != nil {
  1541  		b.Fatal("NewCipher:", err)
  1542  	}
  1543  	out := make([]byte, len(tt.in))
  1544  	b.SetBytes(int64(len(out)))
  1545  	b.ResetTimer()
  1546  	for i := 0; i < b.N; i++ {
  1547  		c.Encrypt(out, tt.in)
  1548  	}
  1549  }
  1550  
  1551  func BenchmarkTDESDecrypt(b *testing.B) {
  1552  	tt := encryptTripleDESTests[0]
  1553  	c, err := des.NewTripleDESCipher(tt.key)
  1554  	if err != nil {
  1555  		b.Fatal("NewCipher:", err)
  1556  	}
  1557  	out := make([]byte, len(tt.out))
  1558  	b.SetBytes(int64(len(out)))
  1559  	b.ResetTimer()
  1560  	for i := 0; i < b.N; i++ {
  1561  		c.Decrypt(out, tt.out)
  1562  	}
  1563  }
  1564  

View as plain text