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

View as plain text