/*
* Serpent
* (C) 1999-2007 Jack Lloyd
*
* Botan is released under the Simplified BSD License (see license.txt)
*/
#include "SerpentFast.h"
#include "SerpentFast_sbox.h"
#include "Common/Endian.h"
#if !defined(_UEFI)
#include <memory.h>
#include <stdlib.h>
#endif
#include "cpu.h"
#include "misc.h"
#if BYTE_ORDER == BIG_ENDIAN
#define BOTAN_ENDIAN_N2B(x) (x)
#define BOTAN_ENDIAN_B2N(x) (x)
#define BOTAN_ENDIAN_N2L(x) bswap_32(x)
#define BOTAN_ENDIAN_L2N(x) bswap_32(x)
#elif BYTE_ORDER == LITTLE_ENDIAN
#define BOTAN_ENDIAN_N2L(x) (x)
#define BOTAN_ENDIAN_L2N(x) (x)
#define BOTAN_ENDIAN_N2B(x) bswap_32(x)
#define BOTAN_ENDIAN_B2N(x) bswap_32(x)
#endif
#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE
extern void serpent_simd_encrypt_blocks_4(const unsigned __int8 in[], unsigned __int8 out[], unsigned __int32* round_key);
extern void serpent_simd_decrypt_blocks_4(const unsigned __int8 in[], unsigned __int8 out[], unsigned __int32* round_key);
#endif
/*
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long *//* XPM */
static const char *VeraCryptIcon48x48[] = {
"48 48 435 2",
" c None",
". c #FFFFFF",
"+ c #FEFFFF",
"@ c #FDFEFF",
"# c #FEFEFE",
"$ c #FEFFFE",
"% c #EFF9FC",
"& c #CDEEF7",
"* c #D5F1F8",
"= c #D3F0F8",
"- c #D1EFF8",
"; c #DBF2F9",
"> c #FDFEFE",
", c #E7F5F1",
"' c #E4F3EF",
") c #E5F4EF",
"! c #E4F3EE",
"~ c #EAF6F2",
"{ c #EDF6F3",
"] c #ECF6F3",
"^ c #EAF5F1",
"/ c #F8FCFA",
"( c #EAF8FC",
"_ c #1CB1DB",
": c #01A8D7",
"< c #07ABD8",
"[ c #04AAD8",
"} c #0DA8D5",
"| c #CFEDF6",
"1 c #CFECE4",
"2 c #5ABA9D",
"3 c #6CBFA4",
"4 c #69BEA3",
"5 c #8ACAB3",
"6 c #96CFBA",
"7 c #95CEB9",
"8 c #93CEB8",
"9 c #9BD2BE",
"0 c #F4FAF8",
"a c #FCFEFE",
"b c #99DCEF",
"c c #00A5D5",
"d c #0BADD9",
"e c #0DABD8",
"f c #00A1D0",
"g c #4EBEDF",
"h c #73C6AE",
"i c #4AB696",
"j c #6ABFA4",
"k c #6ABEA3",
"l c #7EC5AD",
"m c #86C9B2",
"n c #92CDB8",
"o c #99D0BC",
"p c #8FCCB5",
"q c #D0EAE0",
"r c #3ABBE0",
"s c #00A8D7",
"t c #10A8D5",
"u c #12A7D3",
"v c #01A1D1",
"w c #AEE1F0",
"x c #B7E2D5",
"y c #46B494",
"z c #53BA9C",
"A c #5ABB9E",
"B c #6CBFA5",
"C c #74C2A9",
"D c #88C9B3",
"E c #85C8B1",
"F c #8BCBB5",
"G c #A8D7C6",
"H c #FCFEFF",
"I c #BCE8F5",
"J c #03A6D5",
"K c #0FA7D3",
"L c #05A3D2",
"M c #2FB3D9",
"N c #F6FCFD",
"O c #F1F9F7",
"P c #61BFA3",
"Q c #4FB899",
"R c #54B99C",
"S c #53B99B",
"T c #5FBC9F",
"U c #7CC4AB",
"V c #80C5AE",
"W c #7FC5AD",
"X c #88C9B2",
"Y c #E1F1EB",
"Z c #63BFE1",
"` c #0898CF",
" . c #1AA0D3",
".. c #1BA1D3",
"+. c #0697CE",
"@. c #91CBE7",
"#. c #FCFDFE",
"$. c #91D5C4",
"%. c #3BB392",
"&. c #4BB99C",
"*. c #4BB99B",
"=. c #3CB393",
"-. c #8DD2BF",
";. c #E8F4EF",
">. c #DBEFE8",
",. c #DDF0E9",
"'. c #DCEFE8",
"). c #E2F2EC",
"!. c #DDF0F8",
"~. c #209ED2",
"{. c #199AD1",
"]. c #1C9DD2",
"^. c #1C94CF",
"/. c #2C90CF",
"(. c #E3F1F9",
"_. c #FEFEFF",
":. c #D9F1EB",
"<. c #31B394",
"[. c #3EB697",
"}. c #46B89A",
"|. c #40B697",
"1. c #4FBB9F",
"2. c #EDF8F5",
"3. c #89CCE7",
"4. c #0995CE",
"5. c #1E9DD1",
"6. c #2690CE",
"7. c #1585CA",
"8. c #72B6DF",
"9. c #6CC7B1",
"0. c #26AD8D",
"a. c #38B495",
"b. c #47B799",
"c. c #37B291",
"d. c #ACDFD2",
"e. c #FAFDFD",
"f. c #F4FAFD",
"g. c #34A9D7",
"h. c #1891CE",
"i. c #268DCD",
"j. c #248ECD",
"k. c #1C8ACC",
"l. c #C8E3F3",
"m. c #BEEAE0",
"n. c #2AB493",
"o. c #37B999",
"p. c #34B899",
"q. c #36B797",
"r. c #67C5AC",
"s. c #FBFDFD",
"t. c #ADD9ED",
"u. c #1785C8",
"v. c #288CCC",
"w. c #1A85C9",
"x. c #54A3D6",
"y. c #F9FCFD",
"z. c #4DA991",
"A. c #26987A",
"B. c #2F9C7F",
"C. c #249779",
"D. c #BCE2D8",
"E. c #FCFEFD",
"F. c #5CA2D4",
"G. c #1D80C4",
"H. c #2B87C8",
"I. c #2C89C8",
"J. c #1575BC",
"K. c #A8C9E4",
"L. c #9DD8DE",
"M. c #177A73",
"N. c #236046",
"O. c #20654D",
"P. c #22614A",
"Q. c #196F54",
"R. c #7FC5B3",
"S. c #CEE4F2",
"T. c #2384C6",
"U. c #2987C8",
"V. c #2884C6",
"W. c #1A73BA",
"X. c #3684C2",
"Y. c #EFF6FA",
"Z. c #E6F4F5",
"`. c #37A9B2",
" + c #2AA2AA",
".+ c #246F5B",
"++ c #21664D",
"@+ c #226951",
"#+ c #2E997C",
"$+ c #289E7F",
"%+ c #CCE7E0",
"&+ c #7BB4DC",
"*+ c #1A7FC4",
"=+ c #267DC0",
"-+ c #2378BC",
";+ c #106DB7",
">+ c #83B4DA",
",+ c #79C4CB",
"'+ c #1E9DA6",
")+ c #31AAB5",
"!+ c #29908D",
"~+ c #215F45",
"{+ c #288469",
"]+ c #33A586",
"^+ c #24997A",
"/+ c #5EB59E",
"(+ c #E8F3FA",
"_+ c #3187C6",
":+ c #1C74BB",
"<+ c #2278BD",
"[+ c #1D75BB",
"}+ c #2C7CC0",
"|+ c #ABD5E3",
"1+ c #2FA6AD",
"2+ c #2CA3AD",
"3+ c #2DA4AD",
"4+ c #2EA5AF",
"5+ c #1E7B6A",
"6+ c #2E9A7B",
"7+ c #30A082",
"8+ c #32A083",
"9+ c #229979",
"0+ c #B1DBD0",
"a+ c #F9FCFB",
"b+ c #FCFDFD",
"c+ c #FDFDFD",
"d+ c #9BBBDC",
"e+ c #1960AD",
"f+ c #2D6EB4",
"g+ c #296CB3",
"h+ c #2768B1",
"i+ c #1A7798",
"j+ c #2F9DAF",
"k+ c #2F99AF",
"l+ c #309AAF",
"m+ c #2B98B0",
"n+ c #81C2C3",
"o+ c #329374",
"p+ c #298E72",
"q+ c #2C8F72",
"r+ c #298E71",
"s+ c #309174",
"t+ c #4DA78F",
"u+ c #4AA78E",
"v+ c #4BA88F",
"w+ c #49A58C",
"x+ c #4FB098",
"y+ c #E3F5F1",
"z+ c #FAFBFD",
"A+ c #4C80BD",
"B+ c #2263AD",
"C+ c #2E6AB5",
"D+ c #21689E",
"E+ c #0B6274",
"F+ c #278AA2",
"G+ c #349CB3",
"H+ c #2492AA",
"I+ c #5BADBF",
"J+ c #77B6A3",
"K+ c #1B8466",
"L+ c #2D8E72",
"M+ c #2A8C6F",
"N+ c #258565",
"O+ c #238D6E",
"P+ c #28987A",
"Q+ c #279577",
"R+ c #2A987B",
"S+ c #17A282",
"T+ c #77CAB8",
"U+ c #BCD0E6",
"V+ c #2062AE",
"W+ c #2F6DB2",
"X+ c #156983",
"Y+ c #0F6578",
"Z+ c #187187",
"`+ c #349CB2",
" @ c #2995AD",
".@ c #CBE5EB",
"+@ c #E3F0ED",
"@@ c #329276",
"#@ c #2A8D71",
"$@ c #2D8C6E",
"%@ c #2B896A",
"&@ c #2C8A6C",
"*@ c #329A7E",
"=@ c #339A7E",
"-@ c #32A68A",
";@ c #31B094",
">@ c #29AB8D",
",@ c #CDEBE5",
"'@ c #6894CB",
")@ c #005487",
"!@ c #015C6D",
"~@ c #015B72",
"{@ c #01586E",
"]@ c #04728B",
"^@ c #7DC1D0",
"/@ c #F9FCFC",
"(@ c #99C9BB",
"_@ c #0E7D5B",
":@ c #197F5E",
"<@ c #177E5D",
"[@ c #177D5C",
"}@ c #1A8463",
"|@ c #1E9778",
"1@ c #1CA687",
"2@ c #1FA788",
"3@ c #12A282",
"4@ c #49B89F",
"5@ c #FCFCFC",
"6@ c #DDE7F1",
"7@ c #79A9B8",
"8@ c #7EADB7",
"9@ c #7EACB7",
"0@ c #7DABB6",
"a@ c #7DAEBA",
"b@ c #E5F2F4",
"c@ c #F3F9F7",
"d@ c #91C3B3",
"e@ c #89BDAD",
"f@ c #8CBEAE",
"g@ c #8BBEAE",
"h@ c #8BBDAD",
"i@ c #8DCDBD",
"j@ c #8DD3C4",
"k@ c #8CD1C2",
"l@ c #8FD3C4",
"m@ c #86D0BF",
"n@ c #E2F4EF",
"o@ c #FCFCFB",
"p@ c #C5C5C4",
"q@ c #949493",
"r@ c #989897",
"s@ c #C4C4C4",
"t@ c #F8F9F9",
"u@ c #A5A5A5",
"v@ c #8E8E8D",
"w@ c #CBCBCB",
"x@ c #FAFCFC",
"y@ c #FAFCFB",
"z@ c #F0F1F0",
"A@ c #FBFEFD",
"B@ c #D2D2D2",
"C@ c #323230",
"D@ c #F0F0EF",
"E@ c #3A3A38",
"F@ c #CCCCCC",
"G@ c #A8A8A7",
"H@ c #ABABAB",
"I@ c #EEEEEE",
"J@ c #A3A3A3",
"K@ c #ACACAB",
"L@ c #C1C1C0",
"M@ c #898988",
"N@ c #E6E6E6",
"O@ c #A5A5A4",
"P@ c #F5F5F5",
"Q@ c #C0C0BF",
"R@ c #B6B6B5",
"S@ c #CACAC9",
"T@ c #FBFBFB",
"U@ c #C9C9C8",
"V@ c #A6A6A6",
"W@ c #BFBFBE",
"X@ c #D3D3D2",
"Y@ c #5D5D5C",
"Z@ c #E7E7E7",
"`@ c #5A5A58",
" # c #7D7D7C",
".# c #717170",
"+# c #969695",
"@# c #4B4B49",
"## c #434342",
"$# c #959594",
"%# c #2C2C2A",
"&# c #AAAAAA",
"*# c #B5B5B4",
"=# c #393938",
"-# c #646463",
";# c #8A8A89",
"># c #E2E2E1",
",# c #666664",
"'# c #DCDCDC",
")# c #8B8B8A",
"!# c #B7B7B7",
"~# c #9C9C9B",
"{# c #80807F",
"]# c #CDCDCD",
"^# c #979796",
"/# c #888887",
"(# c #010100",
"_# c #B7B7B6",
":# c #8D8D8C",
"<# c #3B3B39",
"[# c #939392",
"}# c #AFAFAE",
"|# c #444442",
"1# c #F3F3F3",
"2# c #474746",
"3# c #626261",
"4# c #585856",
"5# c #A1A1A0",
"6# c #A4A4A3",
"7# c #555553",
"8# c #E1E1E1",
"9# c #8C8C8B",
"0# c #EFEFEF",
"a# c #A4A4A4",
"b# c #A9A9A8",
"c# c #929291",
"d# c #E0E0E0",
"e# c #6F6F6D",
"f# c #ECECEC",
"g# c #F1F1F1",
"h# c #818180",
"i# c #DADADA",
"j# c #7E7E7D",
"k# c #9F9F9E",
"l# c #9C9C9C",
"m# c #8F8F8E",
"n# c #CACACA",
"o# c #BCBCBC",
"p# c #E5E5E5",
"q# c #6A6A69",
"r# c #7C7C7B",
"s# c #A7A7A6",
"t# c #D8D8D8",
"u# c #9A9A99",
"v# c #CDCDCC",
"w# c #A0A09F",
"x# c #F0F0F0",
"y# c #FFFFFE",
"z# c #FDFDFC",
"A# c #FEFEFD",
"B# c #F6F6F6",
" ",
" ",
" ",
" . ",
" . . . . . . . . . . . . . . . . . . . . . . . . ",
" . . . . . . . . . . . . . . . . . . . . . . . . . . ",
" . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
" . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
" + @ @ @ @ @ . . . . . . . . . . . . . . . # # # # # $ $ $ $ $ . ",
" . . . . . . + . . . . . . . . . . . . . $ . . . . . . . . . . . ",
" . % & * = - ; + . . . . . . . . . . . . . > , ' ) ) ! ~ { ] { ^ / . ",
" @ . ( _ : < [ } | . @ . . . . . . . . . > . 1 2 3 4 4 3 5 6 7 8 9 0 . $ ",
" . a . b c d e f g . @ . . . . . . . . . . $ h i j 3 k l m n o p q . # . ",
" . . . . + r s t u v w . a . . . . . . . > . x y z A B C D E F 8 G > . . . . ",
" . . . H . I J K K L M N . + . . . . . + . O P Q R S T U V W l X Y . # . . . ",
" . . . . . a . Z ` ...+.@.. #.. . . . . a . $.%.&.*.=.-.;.>.,.'.).$ . . . . . . ",
" . . . . . @ . !.~.{.].^./.(.. _.. . . > . :.<.[.}.|.1.2.. $ . . . + . . . . . . ",
" . . . . . . . a . 3.4.5.6.7.8.. a . . . > . 9.0.a.b.c.d.. e.> > > # . . . . . . . . ",
" . . . . . . . . + . f.g.h.i.j.k.l.. @ . > . m.n.o.p.q.r.s.. . . . . . . . . . . . . . . ",
" . . . . . . . . . a . t.u.v.v.w.x.. + + . y.z.A.B.B.C.D.. E.. . . . . . . . . . . . . . ",
" . . . . . . . . . . . _.. F.G.H.I.J.K.. y.. L.M.N.O.P.Q.R.. > . . . . . . . . . . . . . . . ",
" . . . . . . . . . . . > . S.T.U.V.W.X.Y.. Z.`. +.+++@+#+$+%+. > + + + + . . . . . . . . . . ",
" . . . . . . . . . . . . #.. &+*+=+-+;+>+. ,+'+)+!+~+{+]+^+/+. . . . . + + . . . . . . . . . ",
" . . . . . . . . . . . . _.. (+_+:+<+[+}+|+1+2+3+4+5+6+7+8+9+0+. a+b+b+c+$ . . . . . . . . . ",
" . . . . . . . . . . . . #.. d+e+f+g+h+i+j+k+l+m+n+o+p+q+r+s+t+u+v+w+x+y+. # . . . . . . ",
" . . . . . . . . . . . . . . z+A+B+C+D+E+F+G+H+I+. J+K+L+M+N+O+P+Q+R+S+T+. a . . . . . . ",
" . . . . . . . . . . . . #.. U+V+W+X+Y+Z+`+ @.@. +@@@#@$@%@&@*@=@-@;@>@,@. > . . . . ",
" . . . . . . . . . . . . > . '@)@!@~@{@]@^@. /@. (@_@:@<@[@}@|@1@2@3@4@> . + . . ",
" . . . . . . # 5@. c+# . # . 6@7@8@9@0@a@b@. c+. c@d@e@f@g@h@i@j@k@l@m@n@. # . . ",
" . . . . . . . # . . o@5@# 5@. . . . . . . . 5@5@. . . . . . . . . . . . . . ",
" . . . c+. p@q@. r@s@. c+. . _.# . + t@u@v@w@. c+> x@> $ . . y@z@+ A@+ . . . ",
" . . c+. B@C@D@E@F@G@H@I@J@K@L@M@N@G@O@. P@Q@R@S@T@U@w@V@W@X@Y@Z@. # . . ",
" . . . # . `@ #.#+#@###$#%#&#*#=#-#;#>#. c+,#'#)#!#~#{#]#^#G@/#T@. . . . ",
" . . T@. r@(#_#:#<#[#}#|#1#2#3#4#5#6#. I@ #. w@7#8#9#0#a#b#c#. c+. . ",
" . # . d#e#f#g#h#9#i#[#c+q@j#k#T@l#m#n#o#. p#q#. r#/#s#. +#t#. # ",
" . . . # . # . . . . . . . . . # . . . # . u#v#. w#x#. # . . . . ",
" . . # 5@y## 5@c+# z#. 5@5@z#. 5@# # A## B## . . # c+# c+. . ",
" . . . . . . . . . . . . . . . . . . . . # # . # . . . . . . ",
" . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
" . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
" . . . . . . . . . . . . . . . . . . . . . . . . . . ",
" . . . . . . . . . . . . . . . . . . . . . . . . ",
" . ",
" ",
" ",
" "};