OKlibrary  0.2.1.6
Sboxes.mac
Go to the documentation of this file.
00001 /* Matthew Gwynne, 26.3.2011 (Swansea) */
00002 /* Copyright 2011 Oliver Kullmann
00003 This file is part of the OKlibrary. OKlibrary is free software; you can redistribute
00004 it and/or modify it under the terms of the GNU General Public License as published by
00005 the Free Software Foundation and included in this library; either version 3 of the
00006 License, or any later version. */
00007 
00022 oklib_include("OKlib/ComputerAlgebra/TestSystem/Lisp/Asserts.mac")$
00023 
00024 kill(f)$
00025 
00026 okltest_des_sbox_fulldnf_cl(f) := block(
00027   assert(f(1) =
00028     [{-10,-6,-5,-4,-3,-2,-1,7,8,9},
00029      {-10,-9,-8,-7,-5,-4,-3,-2,-1,6},
00030      {-10,-9,-7,-6,-4,-3,-2,-1,5,8},{-4,-3,-2,-1,5,6,7,8,9,10},
00031      {-9,-6,-5,-3,-2,-1,4,7,8,10},{-7,-5,-3,-2,-1,4,6,8,9,10},
00032      {-9,-8,-7,-6,-3,-2,-1,4,5,10},{-10,-9,-7,-3,-2,-1,4,5,6,8},
00033      {-10,-8,-7,-6,-5,-4,-2,-1,3,9},{-10,-5,-4,-2,-1,3,6,7,8,9},
00034      {-6,-4,-2,-1,3,5,7,8,9,10},{-10,-8,-7,-4,-2,-1,3,5,6,9},
00035      {-8,-6,-5,-2,-1,3,4,7,9,10},{-9,-5,-2,-1,3,4,6,7,8,10},
00036      {-10,-9,-8,-6,-2,-1,3,4,5,7},{-9,-8,-7,-2,-1,3,4,5,6,10},
00037      {-8,-7,-6,-5,-4,-3,-1,2,9,10},{-10,-8,-5,-4,-3,-1,2,6,7,9},
00038      {-10,-8,-6,-4,-3,-1,2,5,7,9},{-10,-7,-4,-3,-1,2,5,6,8,9},
00039      {-10,-7,-6,-5,-3,-1,2,4,8,9},{-10,-9,-5,-3,-1,2,4,6,7,8},
00040      {-10,-9,-6,-3,-1,2,4,5,7,8},{-8,-3,-1,2,4,5,6,7,9,10},
00041      {-9,-7,-6,-5,-4,-1,2,3,8,10},{-9,-8,-5,-4,-1,2,3,6,7,10},
00042      {-9,-8,-6,-4,-1,2,3,5,7,10},{-9,-7,-4,-1,2,3,5,6,8,10},
00043      {-10,-9,-8,-7,-6,-5,-1,2,3,4},{-8,-7,-5,-1,2,3,4,6,9,10},
00044      {-7,-6,-1,2,3,4,5,8,9,10},{-10,-9,-8,-1,2,3,4,5,6,7},
00045      {-10,-9,-7,-6,-5,-4,-3,-2,1,8},{-5,-4,-3,-2,1,6,7,8,9,10},
00046      {-9,-8,-7,-6,-4,-3,-2,1,5,10},{-10,-9,-4,-3,-2,1,5,6,7,8},
00047      {-10,-6,-5,-3,-2,1,4,7,8,9},{-10,-9,-8,-5,-3,-2,1,4,6,7},
00048      {-10,-9,-8,-6,-3,-2,1,4,5,7},{-10,-8,-7,-3,-2,1,4,5,6,9},
00049      {-9,-6,-5,-4,-2,1,3,7,8,10},{-10,-9,-7,-5,-4,-2,1,3,6,8},
00050      {-10,-7,-6,-4,-2,1,3,5,8,9},{-9,-8,-4,-2,1,3,5,6,7,10},
00051      {-10,-8,-7,-6,-5,-2,1,3,4,9},{-9,-8,-7,-5,-2,1,3,4,6,10},
00052      {-8,-6,-2,1,3,4,5,7,9,10},{-7,-2,1,3,4,5,6,8,9,10},
00053      {-6,-5,-4,-3,1,2,7,8,9,10},{-9,-7,-5,-4,-3,1,2,6,8,10},
00054      {-10,-9,-6,-4,-3,1,2,5,7,8},{-8,-4,-3,1,2,5,6,7,9,10},
00055      {-9,-8,-6,-5,-3,1,2,4,7,10},{-8,-7,-5,-3,1,2,4,6,9,10},
00056      {-7,-6,-3,1,2,4,5,8,9,10},{-10,-3,1,2,4,5,6,7,8,9},
00057      {-8,-7,-6,-5,-4,1,2,3,9,10},{-10,-8,-5,-4,1,2,3,6,7,9},
00058      {-10,-8,-6,-4,1,2,3,5,7,9},{-10,-9,-8,-7,-4,1,2,3,5,6},
00059      {-9,-7,-6,-5,1,2,3,4,8,10},{-10,-7,-5,1,2,3,4,6,8,9},
00060      {-10,-9,-8,-7,-6,1,2,3,4,5},{-9,1,2,3,4,5,6,7,8,10}]),
00061   assert(f(5) =
00062     [{-10,-8,-7,-6,-5,-4,-3,-2,-1,9},{-10,-5,-4,-3,-2,-1,6,7,8,9},
00063      {-10,-9,-6,-4,-3,-2,-1,5,7,8},{-8,-4,-3,-2,-1,5,6,7,9,10},
00064      {-10,-9,-7,-6,-5,-3,-2,-1,4,8},{-10,-8,-7,-5,-3,-2,-1,4,6,9},
00065      {-9,-8,-7,-6,-3,-2,-1,4,5,10},{-10,-9,-3,-2,-1,4,5,6,7,8},
00066      {-7,-6,-5,-4,-2,-1,3,8,9,10},{-10,-9,-7,-5,-4,-2,-1,3,6,8},
00067      {-10,-8,-6,-4,-2,-1,3,5,7,9},{-7,-4,-2,-1,3,5,6,8,9,10},
00068      {-8,-6,-5,-2,-1,3,4,7,9,10},{-9,-5,-2,-1,3,4,6,7,8,10},
00069      {-10,-7,-6,-2,-1,3,4,5,8,9},{-9,-8,-7,-2,-1,3,4,5,6,10},
00070      {-10,-9,-8,-6,-5,-4,-3,-1,2,7},{-9,-7,-5,-4,-3,-1,2,6,8,10},
00071      {-9,-7,-6,-4,-3,-1,2,5,8,10},{-10,-9,-8,-7,-4,-3,-1,2,5,6},
00072      {-8,-7,-6,-5,-3,-1,2,4,9,10},{-5,-3,-1,2,4,6,7,8,9,10},
00073      {-6,-3,-1,2,4,5,7,8,9,10},{-10,-8,-3,-1,2,4,5,6,7,9},
00074      {-9,-6,-5,-4,-1,2,3,7,8,10},{-8,-7,-5,-4,-1,2,3,6,9,10},
00075      {-10,-9,-8,-7,-6,-4,-1,2,3,5},{-9,-8,-4,-1,2,3,5,6,7,10},
00076      {-10,-6,-5,-1,2,3,4,7,8,9},{-10,-9,-8,-5,-1,2,3,4,6,7},
00077      {-9,-8,-6,-1,2,3,4,5,7,10},{-10,-7,-1,2,3,4,5,6,8,9},
00078      {-10,-9,-7,-6,-5,-4,-3,-2,1,8},{-8,-5,-4,-3,-2,1,6,7,9,10},
00079      {-10,-8,-7,-6,-4,-3,-2,1,5,9},{-10,-9,-8,-4,-3,-2,1,5,6,7},
00080      {-9,-8,-7,-6,-5,-3,-2,1,4,10},{-10,-9,-5,-3,-2,1,4,6,7,8},
00081      {-8,-6,-3,-2,1,4,5,7,9,10},{-7,-3,-2,1,4,5,6,8,9,10},
00082      {-10,-8,-6,-5,-4,-2,1,3,7,9},{-9,-8,-7,-5,-4,-2,1,3,6,10},
00083      {-9,-6,-4,-2,1,3,5,7,8,10},{-10,-4,-2,1,3,5,6,7,8,9},
00084      {-7,-6,-5,-2,1,3,4,8,9,10},{-10,-8,-7,-5,-2,1,3,4,6,9},
00085      {-10,-9,-8,-6,-2,1,3,4,5,7},{-9,-2,1,3,4,5,6,7,8,10},
00086      {-6,-5,-4,-3,1,2,7,8,9,10},{-10,-7,-5,-4,-3,1,2,6,8,9},
00087      {-9,-8,-6,-4,-3,1,2,5,7,10},{-4,-3,1,2,5,6,7,8,9,10},
00088      {-10,-9,-6,-5,-3,1,2,4,7,8},{-10,-9,-8,-7,-5,-3,1,2,4,6},
00089      {-9,-7,-6,-3,1,2,4,5,8,10},{-9,-8,-3,1,2,4,5,6,7,10},
00090      {-10,-7,-6,-5,-4,1,2,3,8,9},{-10,-8,-5,-4,1,2,3,6,7,9},
00091      {-8,-7,-6,-4,1,2,3,5,9,10},{-10,-9,-7,-4,1,2,3,5,6,8},
00092      {-10,-9,-8,-7,-6,-5,1,2,3,4},{-9,-7,-5,1,2,3,4,6,8,10},
00093      {-10,-6,1,2,3,4,5,7,8,9},{-8,-7,1,2,3,4,5,6,9,10}]),
00094   true)$
00095 
00096 okltest_des_sbox_fullcnf_fcs(f) := block([cnf_fcl],
00097   cnf_fcl : f(1),
00098   assert(cnf_fcl[1] = {1,2,3,4,5,6,7,8,9,10}),
00099   assert(length(cnf_fcl[2]) = 960),
00100   assert(listify(cnf_fcl[2])[1] = {-10,-9,-8,-7,-6,-5,-4,-3,-2,-1}),
00101   assert(listify(cnf_fcl[2])[960] = {1,2,3,4,5,6,7,8,9,10}),
00102   cnf_fcl : f(5),
00103   assert(cnf_fcl[1] = {1,2,3,4,5,6,7,8,9,10}),
00104   assert(length(cnf_fcl[2]) = 960),
00105   assert(listify(cnf_fcl[2])[1] = {-10,-9,-8,-7,-6,-5,-4,-3,-2,-1}),
00106   assert(listify(cnf_fcl[2])[960] = {1,2,3,4,5,6,7,8,9,10}),
00107   true)$
00108 
00109 okltest_des_sbox_bit_fulldnf_cl(f) := block(
00110   assert(f(1,1) =
00111     [{-6,-5,-4,-3,-2,-1,7},{-7,-5,-4,-3,-2,-1,6},{-7,-6,-4,-3,-2,-1,5},
00112      {-4,-3,-2,-1,5,6,7},{-6,-5,-3,-2,-1,4,7},{-7,-5,-3,-2,-1,4,6},
00113      {-7,-6,-3,-2,-1,4,5},{-7,-3,-2,-1,4,5,6},{-7,-6,-5,-4,-2,-1,3},
00114      {-5,-4,-2,-1,3,6,7},{-6,-4,-2,-1,3,5,7},{-7,-4,-2,-1,3,5,6},
00115      {-6,-5,-2,-1,3,4,7},{-5,-2,-1,3,4,6,7},{-6,-2,-1,3,4,5,7},
00116      {-7,-2,-1,3,4,5,6},{-7,-6,-5,-4,-3,-1,2},{-5,-4,-3,-1,2,6,7},
00117      {-6,-4,-3,-1,2,5,7},{-7,-4,-3,-1,2,5,6},{-7,-6,-5,-3,-1,2,4},
00118      {-5,-3,-1,2,4,6,7},{-6,-3,-1,2,4,5,7},{-3,-1,2,4,5,6,7},
00119      {-7,-6,-5,-4,-1,2,3},{-5,-4,-1,2,3,6,7},{-6,-4,-1,2,3,5,7},
00120      {-7,-4,-1,2,3,5,6},{-7,-6,-5,-1,2,3,4},{-7,-5,-1,2,3,4,6},
00121      {-7,-6,-1,2,3,4,5},{-1,2,3,4,5,6,7},{-7,-6,-5,-4,-3,-2,1},
00122      {-5,-4,-3,-2,1,6,7},{-7,-6,-4,-3,-2,1,5},{-4,-3,-2,1,5,6,7},
00123      {-6,-5,-3,-2,1,4,7},{-5,-3,-2,1,4,6,7},{-6,-3,-2,1,4,5,7},
00124      {-7,-3,-2,1,4,5,6},{-6,-5,-4,-2,1,3,7},{-7,-5,-4,-2,1,3,6},
00125      {-7,-6,-4,-2,1,3,5},{-4,-2,1,3,5,6,7},{-7,-6,-5,-2,1,3,4},
00126      {-7,-5,-2,1,3,4,6},{-6,-2,1,3,4,5,7},{-7,-2,1,3,4,5,6},
00127      {-6,-5,-4,-3,1,2,7},{-7,-5,-4,-3,1,2,6},{-6,-4,-3,1,2,5,7},
00128      {-4,-3,1,2,5,6,7},{-6,-5,-3,1,2,4,7},{-7,-5,-3,1,2,4,6},
00129      {-7,-6,-3,1,2,4,5},{-3,1,2,4,5,6,7},{-7,-6,-5,-4,1,2,3},
00130      {-5,-4,1,2,3,6,7},{-6,-4,1,2,3,5,7},{-7,-4,1,2,3,5,6},
00131      {-7,-6,-5,1,2,3,4},{-7,-5,1,2,3,4,6},{-7,-6,1,2,3,4,5},
00132      {1,2,3,4,5,6,7}]),
00133   assert(f(4,4) =
00134     [{-6,-5,-4,-3,-2,-1,7},{-5,-4,-3,-2,-1,6,7},{-6,-4,-3,-2,-1,5,7},
00135      {-7,-4,-3,-2,-1,5,6},{-7,-6,-5,-3,-2,-1,4},{-5,-3,-2,-1,4,6,7},
00136      {-6,-3,-2,-1,4,5,7},{-3,-2,-1,4,5,6,7},{-7,-6,-5,-4,-2,-1,3},
00137      {-7,-5,-4,-2,-1,3,6},{-7,-6,-4,-2,-1,3,5},{-4,-2,-1,3,5,6,7},
00138      {-6,-5,-2,-1,3,4,7},{-7,-5,-2,-1,3,4,6},{-7,-6,-2,-1,3,4,5},
00139      {-2,-1,3,4,5,6,7},{-6,-5,-4,-3,-1,2,7},{-7,-5,-4,-3,-1,2,6},
00140      {-7,-6,-4,-3,-1,2,5},{-4,-3,-1,2,5,6,7},{-7,-6,-5,-3,-1,2,4},
00141      {-7,-5,-3,-1,2,4,6},{-6,-3,-1,2,4,5,7},{-7,-3,-1,2,4,5,6},
00142      {-6,-5,-4,-1,2,3,7},{-5,-4,-1,2,3,6,7},{-7,-6,-4,-1,2,3,5},
00143      {-7,-4,-1,2,3,5,6},{-7,-6,-5,-1,2,3,4},{-7,-5,-1,2,3,4,6},
00144      {-6,-1,2,3,4,5,7},{-1,2,3,4,5,6,7},{-7,-6,-5,-4,-3,-2,1},
00145      {-5,-4,-3,-2,1,6,7},{-7,-6,-4,-3,-2,1,5},{-4,-3,-2,1,5,6,7},
00146      {-6,-5,-3,-2,1,4,7},{-7,-5,-3,-2,1,4,6},{-7,-6,-3,-2,1,4,5},
00147      {-7,-3,-2,1,4,5,6},{-7,-6,-5,-4,-2,1,3},{-7,-5,-4,-2,1,3,6},
00148      {-6,-4,-2,1,3,5,7},{-4,-2,1,3,5,6,7},{-6,-5,-2,1,3,4,7},
00149      {-5,-2,1,3,4,6,7},{-6,-2,1,3,4,5,7},{-7,-2,1,3,4,5,6},
00150      {-6,-5,-4,-3,1,2,7},{-5,-4,-3,1,2,6,7},{-6,-4,-3,1,2,5,7},
00151      {-7,-4,-3,1,2,5,6},{-6,-5,-3,1,2,4,7},{-5,-3,1,2,4,6,7},
00152      {-7,-6,-3,1,2,4,5},{-3,1,2,4,5,6,7},{-6,-5,-4,1,2,3,7},
00153      {-7,-5,-4,1,2,3,6},{-7,-6,-4,1,2,3,5},{-4,1,2,3,5,6,7},
00154      {-7,-6,-5,1,2,3,4},{-7,-5,1,2,3,4,6},{-7,-6,1,2,3,4,5},
00155      {-7,1,2,3,4,5,6}]),
00156   true)$
00157 
00158 okltest_des_sbox_bit_fullcnf_fcs(f) := block([cnf_fcl],
00159   cnf_fcl : f(1,1),
00160   assert(cnf_fcl[1] = {1,2,3,4,5,6,7}),
00161   assert(length(cnf_fcl[2]) = 64),
00162   assert(listify(cnf_fcl[2])[1] = {-7,-6,-5,-4,-3,-1,2}),
00163   assert(listify(cnf_fcl[2])[64] = {1,2,3,4,5,6,7}),
00164   cnf_fcl : f(5,4),
00165   assert(cnf_fcl[1] = {1,2,3,4,5,6,7}),
00166   assert(length(cnf_fcl[2]) = 64),
00167   assert(listify(cnf_fcl[2])[1] = {-7,-6,-5,-4,-3,-2,1}),
00168   assert(listify(cnf_fcl[2])[64] = {-2,-1,3,4,5,6,7}),
00169   true)$
00170 
00171 
00172