(************** Content-type: application/mathematica ************** CreatedBy='Mathematica 5.0' Mathematica-Compatible Notebook This notebook can be used with any Mathematica-compatible application, such as Mathematica, MathReader or Publicon. The data for the notebook starts with the line containing stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. *******************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 23532, 758]*) (*NotebookOutlinePosition[ 24163, 780]*) (* CellTagsIndexPosition[ 24119, 776]*) (*WindowFrame->Normal*) Notebook[{ Cell[BoxData[ \(Off[General::spell, General::spell1]\)], "Input"], Cell[CellGroupData[{ Cell["DES Function", "Title"], Cell[CellGroupData[{ Cell["The Code", "Section"], Cell[CellGroupData[{ Cell["E-box", "Subsection"], Cell[BoxData[ \(\(Expansion::"\" = "\";\)\)], "Input"], Cell[BoxData[ \(Expansion[x_Integer] := Expansion[IntegerDigits[x, 2, 32]]\)], "Input"], Cell[BoxData[ \(Expansion[bits_?VectorQ] := Module[{len}, len = Length[bits]; If[32 != len, Message[Expansion::"\", 32, len], bits[\([{32, 1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 8, 9, 10, 11, 12, 13, 12, 13, 14, 15, 16, 17, 16, 17, 18, 19, 20, 21, 20, 21, 22, 23, 24, 25, 24, 25, 26, 27, 28, 29, 28, 29, 30, 31, 32, 1}]\)]]]\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["S-boxes", "Subsection"], Cell[BoxData[ \(\(s1 = {{14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7}, {0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8}, {4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0}, {15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13}};\)\)], "Input"], Cell[BoxData[ \(\(s2 = {{15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10}, {3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5}, {0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15}, {13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9}};\)\)], "Input"], Cell[BoxData[ \(\(s3 = {{10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8}, {13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1}, {13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7}, {1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12}};\)\)], "Input"], Cell[BoxData[ \(\(s4 = {{7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15}, {13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9}, {10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4}, {3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14}};\)\)], "Input"], Cell[BoxData[ \(\(s5 = {{2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9}, {14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6}, {4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14}, {11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3}};\)\)], "Input"], Cell[BoxData[ \(\(s6 = {{12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11}, {10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8}, {9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6}, {4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13}};\)\)], "Input"], Cell[BoxData[ \(\(s7 = {{4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1}, {13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6}, {1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2}, {6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12}};\)\)], "Input"], Cell[BoxData[ \(\(s8 = {{13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7}, {1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2}, {7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8}, {2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11}};\)\)], "Input"], Cell[BoxData[ \(SBox[s_?MatrixQ, z_?VectorQ] := Module[{row, column}, row = 1 + FromDigits[Drop[z, {2, 5}], 2]; column = 1 + FromDigits[Take[z, {2, 5}], 2]; s[\([row, column]\)]]\)], "Input"], Cell[BoxData[ \(ApplySBoxes[z_?MatrixQ] := Module[{tmp}, tmp = Transpose[{{s1, s2, s3, s4, s5, s6, s7, s8}, z}]; tmp = Apply[SBox, tmp, {1}]; Map[IntegerDigits[#, 2, 4] &, tmp]]\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["P-box", "Subsection"], Cell[BoxData[ \(\(FP::"\" = "\";\)\)], "Input"], Cell[BoxData[ \(FP[c_Integer] := FP[IntegerDigits[c, 2, 32]]\)], "Input"], Cell[BoxData[ \(FP[bits_?VectorQ] := Module[{len}, len = Length[bits]; If[32 != len, Message[FP::"\", 32, len], bits[\([{16, 7, 20, 21, 29, 12, 28, 17, 1, 15, 23, 26, 5, 18, 31, 10, 2, 8, 24, 14, 32, 27, 3, 9, 19, 13, 30, 6, 22, 11, 4, 25}]\)]]]\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["DES Function", "Subsection"], Cell[BoxData[ \(\(f::"\" = "\";\)\)], "Input"], Cell[BoxData[ \(\(f::"\" = "\";\)\)], "Input"], Cell[BoxData[ \(f[x_Integer, y_Integer] := f[IntegerDigits[x, 2, 32], IntegerDigits[y, 2, 48]]\)], "Input"], Cell[BoxData[ \(f[xbits_?VectorQ, y_Integer] := f[xbits, IntegerDigits[y, 2, 48]]\)], "Input"], Cell[BoxData[ \(f[x_Integer, ybits_?VectorQ] := f[IntegerDigits[x, 2, 32], ybits]\)], "Input"], Cell[BoxData[ \(f[xbits_?VectorQ, ybits_?VectorQ] := Module[{tmp, len}, len = Length[xbits]; If[32 != len, Message[f::"\", 32, len]; Return[]]; len = Length[ybits]; If[48 != len, Message[f::"\", 48, len]; Return[]]; tmp = Mod[Expansion[xbits] + ybits, 2]; tmp = Partition[tmp, 6]; tmp = ApplySBoxes[tmp]; FP[Flatten[tmp]]]\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["Key Schedule", "Subsection"], Cell[BoxData[ \(\(PC1::"\" = "\";\)\)], "Input"], Cell[BoxData[ \(PC1[bits_?VectorQ] := Module[{len}, len = Length[bits]; If[64 != len, Message[PC1::"\", 64, len], bits[\([{57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18, 10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60, 52, 44, 36, 63, 55, 47, 39, 31, 23, 15, 7, 62, 54, 46, 38, 30, 22, 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4}]\)]]]\)], "Input"], Cell[BoxData[ \(PC1[k_Integer] := PC1[IntegerDigits[k, 2, 64]]\)], "Input"], Cell[BoxData[ \(\(PC2::"\" = "\";\)\)], "Input"], Cell[BoxData[ \(PC2[bits_?VectorQ] := Module[{len}, len = Length[bits]; If[56 != len, Message[PC2::"\", 56, len], bits[\([{14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21, 10, 23, 19, 12, 4, 26, 8, 16, 7, 27, 20, 13, 2, 41, 52, 31, 37, 47, 55, 30, 40, 51, 45, 33, 48, 44, 49, 39, 56, 34, 53, 46, 42, 50, 36, 29, 32}]\)]]]\)], "Input"], Cell[BoxData[ \(PC2[k_Integer] := PC2[IntegerDigits[k, 2, 56]]\)], "Input"], Cell[BoxData[ \(\(KeyShift::"\" = "\";\)\)], "Input"], Cell[BoxData[ \(KeyShift[key_?VectorQ, round_Integer, opts___Rule] := Module[{left, right, len}, len = Length[key]; If[56 != len, Message[KeyShift::"\", 56, len]; Return[]]; left = Take[key, 28]; right = Take[key, \(-28\)]; If[MemberQ[{1, 2, 9, 16}, round], Join[RotateLeft[left], RotateLeft[right]], Join[RotateLeft[left, 2], RotateLeft[right, 2]]]]\)], "Input"], Cell[BoxData[ \(KeyShift[key_Integer, round_Integer] := KeyShift[IntegerDigits[key, 2, 56], round]\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["Initial Permutation", "Subsection"], Cell[BoxData[ \(\(IP::"\" = "\";\)\)], "Input"], Cell[BoxData[ \(\(IPInv::"\" = "\";\)\)], "Input"], Cell[BoxData[ \(IP[x_Integer] := IP[IntegerDigits[x, 2, 64]]\)], "Input"], Cell[BoxData[ \(IP[bits_?VectorQ] := Module[{len}, len = Length[bits]; If[64 != len, Message[IP::"\", 64, len], bits[\([{58, 50, 42, 34, 26, 18, 10, 2, 60, 52, 44, 36, 28, 20, 12, 4, 62, 54, 46, 38, 30, 22, 14, 6, 64, 56, 48, 40, 32, 24, 16, 8, 57, 49, 41, 33, 25, 17, 9, 1, 59, 51, 43, 35, 27, 19, 11, 3, 61, 53, 45, 37, 29, 21, 13, 5, 63, 55, 47, 39, 31, 23, 15, 7}]\)]]]\)], "Input"], Cell[BoxData[ \(IPInv[x_Integer] := IPInv[IntegerDigits[x, 2, 64]]\)], "Input"], Cell[BoxData[ \(IPInv[bits_?VectorQ] := Module[{len}, len = Length[bits]; If[64 != len, Message[IPInv::"\", 64, len], bits[\([{40, 8, 48, 16, 56, 24, 64, 32, 39, 7, 47, 15, 55, 23, 63, 31, 38, 6, 46, 14, 54, 22, 62, 30, 37, 5, 45, 13, 53, 21, 61, 29, 36, 4, 44, 12, 52, 20, 60, 28, 35, 3, 43, 11, 51, 19, 59, 27, 34, 2, 42, 10, 50, 18, 58, 26, 33, 1, 41, 9, 49, 17, 57, 25}]\)]]]\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["Rounds", "Subsection"], Cell[BoxData[ \(\(DESRound::"\" = "\";\)\)], "Input"], Cell[BoxData[ \(\(DESRound::"\" = "\";\)\)], "Input"], Cell[BoxData[ \(DESRound[bits_?VectorQ, key_?VectorQ] := Module[{len, left, right}, len = Length[bits]; If[64 != len, Message[DESRound::"\", 64, len]; Return[]]; len = Length[key]; If[48 != len, Message[DESRound::"\", 48, len]; Return[]]; left = Take[bits, 32]; right = Take[bits, \(-32\)]; Join[right, Mod[left + f[right, key], 2]]]\)], "Input"], Cell[BoxData[ \(DESRound[x_Integer, key_?VectorQ] := DESRound[IntegerDigits[x, 2, 64], key]\)], "Input"], Cell[BoxData[ \(DESRound[bits_?VectorQ, key_Integer] := DESRound[bits, IntegerDigits[key, 2, 48]]\)], "Input"], Cell[BoxData[ \(DESRound[x_Integer, key_Integer] := DESRound[IntegerDigits[x, 2, 64], IntegerDigits[key, 2, 48]]\)], "Input"], Cell[BoxData[ \(\(DESEncrypt::"\" = "\";\)\)], "Input"], Cell[BoxData[ \(\(DESEncrypt::"\" = "\";\)\)], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(Options[DESEncrypt] = {Verbose \[Rule] False, Base \[Rule] 16}\)], "Input"], Cell[BoxData[ \({Verbose \[Rule] False, Base \[Rule] 16}\)], "Output"] }, Open ]], Cell[BoxData[ \(DESEncrypt[plaintext_?VectorQ, key_?VectorQ, opts___Rule] := Module[{len, verbosity, pt, keyn, base}, len = Length[plaintext]; If[64 != len, Message[DESEncrypt::"\", 64, len]; Return[]]; len = Length[key]; If[64 != len, Message[DESEncrypt::"\", 64, len]; Return[]]; verbosity = \(Verbose /. {opts}\) /. Options[DESEncrypt]; base = \(Base /. {opts}\) /. Options[DESEncrypt]; pt = IP[plaintext]; keyn = PC1[key]; If[verbosity, Print["\", BaseForm[FromDigits[plaintext, 2], base], "\<, Initial Permutation: \>", BaseForm[FromDigits[pt, 2], base]]]; Do[keyn = KeyShift[keyn, j]; pt = DESRound[pt, PC2[keyn]]; If[verbosity, Print["\", j, "\<.\nkey = \>", BaseForm[FromDigits[PC2[keyn], 2], base], "\<, bit string = \>", BaseForm[FromDigits[pt, 2], base]]], {j, 1, 16, 1}]; pt = Join[Take[pt, \(-32\)], Take[pt, 32]]; IPInv[pt]]\)], "Input"], Cell[BoxData[ \(DESEncrypt[plaintext_Integer, key_?VectorQ, opts___Rule] := DESEncrypt[IntegerDigits[plaintext, 2, 64], key, opts]\)], "Input"], Cell[BoxData[ \(DESEncrypt[plaintext_?VectorQ, key_Integer, opts___Rule] := DESEncrypt[plaintext, IntegerDigits[key, 2, 64], opts]\)], "Input"], Cell[BoxData[ \(DESEncrypt[plaintext_Integer, key_Integer, opts___Rule] := DESEncrypt[IntegerDigits[plaintext, 2, 64], IntegerDigits[key, 2, 64], opts]\)], "Input"], Cell[BoxData[ \(\(DESDecrypt::"\" = "\";\)\)], "Input"], Cell[BoxData[ \(\(DESDecrypt::"\" = "\";\)\)], "Input"], Cell[BoxData[ \(DESDecrypt[ciphertext_?VectorQ, key_?VectorQ, opts___Rule] := Module[{len, verbosity, pt, keyc, keys, base}, len = Length[ciphertext]; If[64 != len, Message[DESDecrypt::"\", 64, len]; Return[]]; len = Length[key]; If[64 != len, Message[DESDecrypt::"\", 64, len]; Return[]]; verbosity = \(Verbose /. {opts}\) /. Options[DESEncrypt]; base = \(Base /. {opts}\) /. Options[DESEncrypt]; pt = IP[ciphertext]; keys = {}; keyc = PC1[key]; Do[keyc = KeyShift[keyc, j]; keys = Prepend[keys, PC2[keyc]], {j, 1, 16, 1}]; Do[pt = DESRound[pt, keys[\([j]\)]]; If[verbosity, Print["\", j, "\<.\nkey = \>", BaseForm[FromDigits[keys[\([j]\)], 2], base], "\<, bit string = \>", BaseForm[FromDigits[pt, 2], base]]], {j, 1, 16, 1}]; pt = Join[Take[pt, \(-32\)], Take[pt, 32]]; IPInv[pt]]\)], "Input"], Cell[BoxData[ \(DESDecrypt[plaintext_Integer, key_?VectorQ, opts___Rule] := DESDecrypt[IntegerDigits[plaintext, 2, 64], key, opts]\)], "Input"], Cell[BoxData[ \(DESDecrypt[plaintext_?VectorQ, key_Integer, opts___Rule] := DESDecrypt[plaintext, IntegerDigits[key, 2, 64], opts]\)], "Input"], Cell[BoxData[ \(DESDecrypt[plaintext_Integer, key_Integer, opts___Rule] := DESDecrypt[IntegerDigits[plaintext, 2, 64], IntegerDigits[key, 2, 64], opts]\)], "Input"] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell["Example 1", "Section"], Cell[BoxData[ \(\(x = 16^^BEEFCAFE;\)\)], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(BaseForm[x, 2]\)], "Input"], Cell[BoxData[ TagBox[ InterpretationBox[\("10111110111011111100101011111110"\_"2"\), 3203386110, Editable->False], (BaseForm[ #, 2]&)]], "Output"] }, Open ]], Cell[BoxData[ \(\(y = 16^^010101010101;\)\)], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(BaseForm[y, 2]\)], "Input"], Cell[BoxData[ TagBox[ InterpretationBox[\("10000000100000001000000010000000100000001"\_"2"\), 1103823438081, Editable->False], (BaseForm[ #, 2]&)]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["Expansion Step", "Subsection"], Cell[CellGroupData[{ Cell[BoxData[ \(r = Expansion[x]\)], "Input"], Cell[BoxData[ \({0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1}\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(BaseForm[FromDigits[r, 2], 2]\)], "Input"], Cell[BoxData[ TagBox[ InterpretationBox[\("10111111101011101011111111001010101011111111101"\_\ "2"\), 105378631473149, Editable->False], (BaseForm[ #, 2]&)]], "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Addition Modulo 2 Step", "Subsection"], Cell[CellGroupData[{ Cell[BoxData[ \(b = Mod[r + y, 2]\)], "Input"], Cell[BoxData[ \({1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0}\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Partition[b, 6]\)], "Input"], Cell[BoxData[ \({{1, 0, 1, 0, 0, 0}, {0, 0, 0, 0, 1, 0}, {1, 0, 0, 0, 1, 0}, {1, 0, 0, 0, 0, 0}, {0, 0, 0, 1, 1, 0}, {1, 0, 1, 0, 1, 0}, {1, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 1, 0}}\)], "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["S-Boxes", "Subsection"], Cell[CellGroupData[{ Cell[BoxData[ \(ApplySBoxes[%]\)], "Input"], Cell[BoxData[ \({{1, 1, 0, 1}, {0, 0, 0, 1}, {0, 1, 1, 0}, {1, 0, 1, 0}, {0, 0, 0, 1}, {1, 0, 0, 0}, {0, 0, 0, 1}, {0, 0, 1, 0}}\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(c = Flatten[%]\)], "Input"], Cell[BoxData[ \({1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0}\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(BaseForm[FromDigits[c, 2], 2]\)], "Input"], Cell[BoxData[ TagBox[ InterpretationBox[\("11010001011010100001100000010010"\_"2"\), 3513391122, Editable->False], (BaseForm[ #, 2]&)]], "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Final Permutation Step", "Subsection"], Cell[CellGroupData[{ Cell[BoxData[ \(z = FP[c]\)], "Input"], Cell[BoxData[ \({0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0}\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(BaseForm[FromDigits[z, 2], 2]\)], "Input"], Cell[BoxData[ TagBox[ InterpretationBox[\("110010110000111100000001000110"\_"2"\), 851689542, Editable->False], (BaseForm[ #, 2]&)]], "Output"] }, Open ]], Cell[BoxData[ \(Clear[b, c, r, x, y]\)], "Input"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["Example 2", "Section"], Cell[BoxData[ \(\(x = 16^^ABCD0123;\)\)], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(BaseForm[x, 2]\)], "Input"], Cell[BoxData[ TagBox[ InterpretationBox[\("10101011110011010000000100100011"\_"2"\), 2882339107, Editable->False], (BaseForm[ #, 2]&)]], "Output"] }, Open ]], Cell[BoxData[ \(\(y = 16^^0123456789AB;\)\)], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(BaseForm[y, 2]\)], "Input"], Cell[BoxData[ TagBox[ InterpretationBox[\("10010001101000101011001111000100110101011"\_"2"\), 1250999896491, Editable->False], (BaseForm[ #, 2]&)]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["Expansion Step", "Subsection"], Cell[CellGroupData[{ Cell[BoxData[ \(r = Expansion[x]\)], "Input"], Cell[BoxData[ \({1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1}\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(BaseForm[FromDigits[r, 2], 2]\)], "Input"], Cell[BoxData[ TagBox[ InterpretationBox[\("110101010111111001011010100000000010100100000111"\_\ "2"\), 234738660944135, Editable->False], (BaseForm[ #, 2]&)]], "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Addition Modulo 2 Step", "Subsection"], Cell[CellGroupData[{ Cell[BoxData[ \(b = Mod[r + y, 2]\)], "Input"], Cell[BoxData[ \({0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0}\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Partition[b, 6]\)], "Input"], Cell[BoxData[ \({{0, 0, 1, 0, 1, 0}, {1, 0, 1, 0, 0, 0}, {0, 0, 0, 1, 1, 0}, {1, 0, 0, 1, 0, 1}, {0, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 0, 1}, {0, 1, 1, 0, 1, 1}, {1, 1, 1, 0, 0, 0}}\)], "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["S-Boxes", "Subsection"], Cell[CellGroupData[{ Cell[BoxData[ \(ApplySBoxes[%]\)], "Input"], Cell[BoxData[ \({{1, 1, 1, 1}, {1, 0, 1, 0}, {1, 1, 1, 0}, {0, 0, 0, 0}, {0, 1, 1, 0}, {1, 0, 0, 0}, {1, 1, 1, 1}, {1, 1, 1, 1}}\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(c = Flatten[%]\)], "Input"], Cell[BoxData[ \({1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1}\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(BaseForm[FromDigits[c, 2], 2]\)], "Input"], Cell[BoxData[ TagBox[ InterpretationBox[\("11111010111000000110100011111111"\_"2"\), 4209010943, Editable->False], (BaseForm[ #, 2]&)]], "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Final Permutation Step", "Subsection"], Cell[CellGroupData[{ Cell[BoxData[ \(z = FP[c]\)], "Input"], Cell[BoxData[ \({0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1}\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(BaseForm[FromDigits[z, 2], 2]\)], "Input"], Cell[BoxData[ TagBox[ InterpretationBox[\("1011010100111111000111110100111"\_"2"\), 1520406439, Editable->False], (BaseForm[ #, 2]&)]], "Output"] }, Open ]], Cell[BoxData[ \(Clear[b, c, r, x, y]\)], "Input"] }, Open ]] }, Closed]] }, Open ]] }, FrontEndVersion->"5.0 for X", ScreenRectangle->{{0, 1280}, {0, 1024}}, WindowSize->{520, 600}, WindowMargins->{{172, Automatic}, {Automatic, 77}} ] (******************************************************************* Cached data follows. If you edit this Notebook file directly, not using Mathematica, you must remove the line containing CacheID at the top of the file. The cache data will then be recreated when you save this file from within Mathematica. *******************************************************************) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[1754, 51, 69, 1, 27, "Input"], Cell[CellGroupData[{ Cell[1848, 56, 29, 0, 96, "Title"], Cell[CellGroupData[{ Cell[1902, 60, 27, 0, 72, "Section"], Cell[CellGroupData[{ Cell[1954, 64, 27, 0, 38, "Subsection"], Cell[1984, 66, 181, 3, 75, "Input"], Cell[2168, 71, 91, 1, 43, "Input"], Cell[2262, 74, 425, 7, 123, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[2724, 86, 29, 0, 30, "Subsection"], Cell[2756, 88, 306, 4, 75, "Input"], Cell[3065, 94, 306, 4, 75, "Input"], Cell[3374, 100, 306, 4, 75, "Input"], Cell[3683, 106, 306, 4, 75, "Input"], Cell[3992, 112, 306, 4, 75, "Input"], Cell[4301, 118, 306, 4, 75, "Input"], Cell[4610, 124, 306, 4, 75, "Input"], Cell[4919, 130, 306, 4, 75, "Input"], Cell[5228, 136, 220, 4, 91, "Input"], Cell[5451, 142, 219, 4, 91, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[5707, 151, 27, 0, 30, "Subsection"], Cell[5737, 153, 165, 2, 75, "Input"], Cell[5905, 157, 77, 1, 27, "Input"], Cell[5985, 160, 335, 6, 107, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[6357, 171, 34, 0, 30, "Subsection"], Cell[6394, 173, 187, 3, 75, "Input"], Cell[6584, 178, 188, 3, 75, "Input"], Cell[6775, 183, 118, 2, 43, "Input"], Cell[6896, 187, 105, 2, 43, "Input"], Cell[7004, 191, 105, 2, 43, "Input"], Cell[7112, 195, 417, 7, 139, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[7566, 207, 34, 0, 30, "Subsection"], Cell[7603, 209, 142, 2, 59, "Input"], Cell[7748, 213, 452, 7, 139, "Input"], Cell[8203, 222, 79, 1, 27, "Input"], Cell[8285, 225, 142, 2, 59, "Input"], Cell[8430, 229, 419, 7, 123, "Input"], Cell[8852, 238, 79, 1, 27, "Input"], Cell[8934, 241, 152, 2, 59, "Input"], Cell[9089, 245, 435, 7, 139, "Input"], Cell[9527, 254, 122, 2, 43, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[9686, 261, 41, 0, 30, "Subsection"], Cell[9730, 263, 140, 2, 59, "Input"], Cell[9873, 267, 146, 2, 59, "Input"], Cell[10022, 271, 77, 1, 27, "Input"], Cell[10102, 274, 497, 8, 155, "Input"], Cell[10602, 284, 83, 1, 27, "Input"], Cell[10688, 287, 503, 8, 155, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[11228, 300, 28, 0, 30, "Subsection"], Cell[11259, 302, 166, 2, 59, "Input"], Cell[11428, 306, 152, 2, 59, "Input"], Cell[11583, 310, 426, 7, 139, "Input"], Cell[12012, 319, 115, 2, 43, "Input"], Cell[12130, 323, 121, 2, 43, "Input"], Cell[12254, 327, 136, 2, 59, "Input"], Cell[12393, 331, 156, 2, 59, "Input"], Cell[12552, 335, 193, 3, 75, "Input"], Cell[CellGroupData[{ Cell[12770, 342, 104, 2, 27, "Input"], Cell[12877, 346, 74, 1, 70, "Output"] }, Open ]], Cell[12966, 350, 1142, 21, 379, "Input"], Cell[14111, 373, 154, 2, 59, "Input"], Cell[14268, 377, 154, 2, 59, "Input"], Cell[14425, 381, 184, 3, 75, "Input"], Cell[14612, 386, 156, 2, 59, "Input"], Cell[14771, 390, 195, 3, 75, "Input"], Cell[14969, 395, 1041, 19, 331, "Input"], Cell[16013, 416, 154, 2, 59, "Input"], Cell[16170, 420, 154, 2, 59, "Input"], Cell[16327, 424, 184, 3, 75, "Input"] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell[16560, 433, 28, 0, 42, "Section"], Cell[16591, 435, 54, 1, 27, "Input"], Cell[CellGroupData[{ Cell[16670, 440, 47, 1, 27, "Input"], Cell[16720, 443, 178, 5, 70, "Output"] }, Open ]], Cell[16913, 451, 58, 1, 27, "Input"], Cell[CellGroupData[{ Cell[16996, 456, 47, 1, 27, "Input"], Cell[17046, 459, 190, 5, 70, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[17273, 469, 36, 0, 38, "Subsection"], Cell[CellGroupData[{ Cell[17334, 473, 49, 1, 27, "Input"], Cell[17386, 476, 192, 3, 70, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[17615, 484, 62, 1, 27, "Input"], Cell[17680, 487, 200, 6, 70, "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[17929, 499, 44, 0, 38, "Subsection"], Cell[CellGroupData[{ Cell[17998, 503, 50, 1, 27, "Input"], Cell[18051, 506, 192, 3, 70, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[18280, 514, 48, 1, 27, "Input"], Cell[18331, 517, 212, 3, 70, "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[18592, 526, 29, 0, 38, "Subsection"], Cell[CellGroupData[{ Cell[18646, 530, 47, 1, 27, "Input"], Cell[18696, 533, 155, 2, 70, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[18888, 540, 47, 1, 27, "Input"], Cell[18938, 543, 137, 2, 70, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[19112, 550, 62, 1, 27, "Input"], Cell[19177, 553, 178, 5, 70, "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[19404, 564, 44, 0, 38, "Subsection"], Cell[CellGroupData[{ Cell[19473, 568, 42, 1, 27, "Input"], Cell[19518, 571, 137, 2, 70, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[19692, 578, 62, 1, 27, "Input"], Cell[19757, 581, 175, 5, 70, "Output"] }, Open ]], Cell[19947, 589, 53, 1, 27, "Input"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[20049, 596, 28, 0, 42, "Section"], Cell[20080, 598, 54, 1, 27, "Input"], Cell[CellGroupData[{ Cell[20159, 603, 47, 1, 27, "Input"], Cell[20209, 606, 178, 5, 70, "Output"] }, Open ]], Cell[20402, 614, 58, 1, 27, "Input"], Cell[CellGroupData[{ Cell[20485, 619, 47, 1, 27, "Input"], Cell[20535, 622, 190, 5, 70, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[20762, 632, 36, 0, 38, "Subsection"], Cell[CellGroupData[{ Cell[20823, 636, 49, 1, 27, "Input"], Cell[20875, 639, 192, 3, 70, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[21104, 647, 62, 1, 27, "Input"], Cell[21169, 650, 201, 6, 70, "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[21419, 662, 44, 0, 38, "Subsection"], Cell[CellGroupData[{ Cell[21488, 666, 50, 1, 27, "Input"], Cell[21541, 669, 192, 3, 70, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[21770, 677, 48, 1, 27, "Input"], Cell[21821, 680, 212, 3, 70, "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[22082, 689, 29, 0, 38, "Subsection"], Cell[CellGroupData[{ Cell[22136, 693, 47, 1, 27, "Input"], Cell[22186, 696, 155, 2, 70, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[22378, 703, 47, 1, 27, "Input"], Cell[22428, 706, 137, 2, 70, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[22602, 713, 62, 1, 27, "Input"], Cell[22667, 716, 178, 5, 70, "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[22894, 727, 44, 0, 38, "Subsection"], Cell[CellGroupData[{ Cell[22963, 731, 42, 1, 27, "Input"], Cell[23008, 734, 137, 2, 70, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[23182, 741, 62, 1, 27, "Input"], Cell[23247, 744, 177, 5, 70, "Output"] }, Open ]], Cell[23439, 752, 53, 1, 27, "Input"] }, Open ]] }, Closed]] }, Open ]] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************)