TigerDigest
using Org.BouncyCastle.Crypto.Utilities;
using Org.BouncyCastle.Utilities;
using System;
namespace Org.BouncyCastle.Crypto.Digests
{
public class TigerDigest : IDigest, IMemoable
{
private const int MyByteLength = 64;
private static readonly long[] t1 = new long[256] {
192161084409973854,
-6034178070669973268,
8272369121297300691,
7854730284916899642,
-3631738584360316525,
8463286011307239906,
-5664346993730092093,
5082381371487377520,
-1536603760329757466,
-4232985935611735204,
5541490850629862524,
766444128913191948,
1204553577021685498,
-4121719295987045526,
1401289229890216703,
1893918052108309022,
5461170853188208586,
2807403890869420487,
-8822417684582283338,
5699452412975025298,
-2914262034798377397,
-8199292901130911363,
7624427211800470465,
-5330070367527189138,
9043806901924967914,
7231827479902542914,
-4667804575905660192,
6875646691050945796,
-954047427515838778,
7786398710221814956,
8167597339425066981,
1830707105885056415,
-192929137551915557,
-4000909680243679221,
-8790383730744944306,
-6559119868654993229,
-8046943608939121133,
-2635222011098072079,
1783120314242633559,
248005612187258982,
7688500634458409525,
-799055769434250085,
8591138587399736033,
-2813706756098348539,
-4803442773389201549,
5042603696143252264,
2053990370701680515,
-8434990628116389527,
3741955435321465241,
4334407786093429776,
-5399798173115342087,
1449859124008718907,
-259597992345095852,
-2299784421946890745,
-8624947886301142065,
-7850603641235491331,
3847074041673952000,
4649400157396704725,
-4273499526689310132,
-3840742565288711634,
2909491499011162061,
4458122598401901638,
7071481730398905774,
6725294491764459774,
-6201551736110472662,
-4372530048007926361,
1226483701329067140,
-2522035007050864557,
-3676115808446124170,
-4975751036383735295,
-1831728144282101387,
-7732658914112356844,
479582384021555544,
8040612334407127321,
-2798227069691230528,
-1334228551670664750,
8751740296797632830,
6603430683508552489,
8942924799792477540,
3573742753214737511,
-2419519573825602302,
6349030933445924429,
-2501945979441900175,
-6177453506703404958,
-7885857697280165792,
5194369709296555225,
7174555471952375656,
7982812746821821468,
-8707669106532426453,
3232013613859041307,
-5747376245209101971,
-2231459388012946321,
3112410413624570453,
-2336602742119691332,
6658792778814911418,
6126246269502162262,
-6070952467612144753,
4721051187472420532,
-5533619424469951182,
-4853025588084287359,
2663576151211431276,
928112258657309258,
5664920977038299994,
2704699625848084345,
2312925355491498803,
-528812816973409076,
2964761606854114992,
4148718494125202372,
4082542483235864459,
5171535286737311423,
2166137813939512309,
8844224567096109974,
-6373247044080797239,
-8133614489572350707,
7053919794999990929,
5576291611870337032,
-1374825740467639573,
-734453569254161202,
-705972172313107935,
-6688726126811769884,
-7468621655906046812,
-3527580439205474383,
-6956282119872554589,
-6281089153129775081,
853355433004222246,
-1924221946255713479,
2124075034376372323,
5881355904936746717,
1033318428544969251,
1692585388818821524,
-1245985052454466526,
1107424405919510210,
-9211670503851965599,
-5975256720516651978,
963191604767572015,
4506934758573727688,
-6511972687387035778,
-6714534832456272315,
7421261837586505858,
3318186242040429129,
-4402061108394378299,
1910808081503,
4771413979138012118,
-3357965141731676491,
-6811660122601107496,
3247421105326436348,
-1009844908434318049,
8353265116968520410,
-5881406294935394735,
-7574869783018555510,
6528592316425799439,
-3049672598698961616,
-3303981966096002009,
7320455443630736945,
-7351974990356818097,
2539802313181221187,
-7307523792611951465,
6084456898448652712,
1615327116689102472,
8126548348642832045,
-1094214848903295726,
6320848846662414801,
-1163799684465161365,
3439926484095136410,
-7218302546559918104,
4583261464596863494,
5278432013075676693,
672210957064462075,
-5420889727701263133,
-3948047341652367807,
3753742208681096767,
-5185515461782971584,
-460252340867529358,
111470777923844445,
1951374535466601971,
-8875343681432095955,
-4493729248843343338,
4830799035278983864,
-5224728565293047538,
6842302225500364445,
-7111193868311747516,
-2729919277420993032,
-5582278241003401657,
-126421769187551098,
-4035721366655415313,
-1986169280154305277,
3977519900599801820,
9148781857317432677,
6468933130968205401,
8516219711084257782,
1539015908620793624,
7527026033758878374,
-1647949680688450337,
3088835283432281588,
3651919061693825289,
-8985256062000155568,
-423165018983337331,
-7032056788937726985,
308165109378616703,
8884692927086426203,
2438838841395254149,
-3550173447755953499,
2823241734971430590,
3896218688877146334,
393786506094771122,
-3117973570538943511,
-7973569017697024389,
-8368763565314219996,
6934559736714979565,
-589348163057397487,
-7554853961030558080,
-6878676038788161577,
-3798065817641571893,
-9101961441510934879,
-4559443103670756675,
-7665374195348870830,
-8336074436196531783,
4236391428300945648,
555138268555536248,
5351590591369890935,
4306521946498657944,
-7151482210676895604,
4901816398460471456,
-9033789479800328823,
7485939926152528684,
-5105994143555176462,
6245128712556390173,
-4718679834244078161,
-325273111308121687,
7772052866533484500,
639373189613950878,
2515940555210603828,
-2058685867725021174,
9187445612742136046,
-5771987833248487369,
-2125811817212952004,
-3204735567712096048,
-3393897870002714342,
1313621308117380133,
3526835097255131285,
-4953033604042954265,
8704164972314360376,
-920137909863202916,
5969067443919232116,
5791404459833380522,
-1682712826007985785,
6001456072058810555,
-8273861206301250160,
2241175407069758350,
-2962551490920225208,
8359644330926224055,
-8523485772611717717,
-5183265553382750,
-1789270636298447811,
-6471656072873752544,
-1458735953920612486
};
private static readonly long[] t2 = new long[256] {
-1826563305001377480,
-5358963986493047656,
6213947727727520144,
5496303794639560149,
-2795981259149962188,
642450021946863605,
-2925749420550550287,
-4252676236223476327,
-2372897249057438062,
-2455723000952046826,
8011611286970690052,
5372247966639775667,
-6490268738015937967,
-265982677241022690,
-1711898199407229911,
-2553549223344005918,
-3655427155680827379,
1788379855404599063,
3792259505844355329,
857793142685420274,
2176386753693503798,
-2281187609587102471,
-12877901320348396,
6070247714570225101,
7358743242340641331,
-8703516059324417162,
1522910625901990663,
-2134847759353728262,
5235630359010597374,
-5774648161970196758,
277273466943670671,
3580831169916433691,
-1032406685548103719,
4657750985732713388,
1177149711660596421,
8685721698255572101,
-3227632359902186326,
-6349410231276355429,
-4809500581665772080,
-7923309769729008016,
-6726740716384263588,
-4587792071496920925,
-658271017113840853,
3834592178494549117,
-3853851402329989932,
-8865288174312808228,
8774750272303345432,
-8428026360225307604,
-3404183201405868250,
6519077675840655372,
1009372798613472243,
-4504928615151511518,
7670504156571609794,
-9068448121725124008,
7481699948221361317,
2131352009749933493,
7854556580946198495,
5848046147829288198,
6811751916476253359,
-635956774299390418,
-4737535235939835750,
-1614809042241653147,
8245611441321613668,
8087057586628171618,
5058061449640751271,
-5151918184365513026,
7212395796113148780,
8872633840395976086,
8602726521519041395,
-5885490816789515276,
6042660761688602872,
1642367900117110883,
25924001596622557,
7531865058110106323,
4223621278438660202,
3926684511422013614,
-2064363959953346089,
5939130201053773422,
8312208923375399755,
5278156969609628584,
-5712322089306707131,
3610014133393185213,
-8850224129823554669,
-7989215126425784091,
7953444341930717599,
-5072589324995998940,
-3677986556148923193,
5127306049615917691,
9121210965518562125,
8462056263389103903,
-743704981880018871,
5658738406708581754,
3084862250275496789,
-2839477530259368618,
-3966384508771725354,
-3487534071112132806,
-123994483119243460,
-1345606558677941971,
-8999779576894164844,
-4191785782441631580,
1116769798908306816,
1871732813531574911,
-5639228995346094013,
2050857069623328786,
942713319182180155,
-8555767913901511542,
-1938713800388260250,
7028952989422544417,
9018945159409650955,
-9098571702620193189,
512456053301416255,
-4053543709501018729,
-4330900206871259305,
-1512795427272957464,
-3102984968199159270,
-7389706432295929941,
-6638196300801425917,
-7112719166685012944,
4569666897377300404,
-7151449437793514816,
4462677101358564049,
3679240545963649394,
-4129112553160565951,
776201060342576796,
-1202834617519492059,
-842133208882402856,
-8445297248460022090,
3458390008116962295,
-8107400727032609416,
6618311662604863029,
4790267690900900096,
1716087693007726108,
4148457837926911568,
-5418957485852076861,
8968309666649857421,
-2611360075161572255,
6968029403465067289,
-3584187592496365262,
500987773930853904,
-8168172799095912208,
2355660670689429871,
3178293543037890097,
-5583593033549110520,
-6297125087914569009,
894835714693979080,
-5305826774090122525,
-348051181029808153,
352461093517089771,
5441805419015688358,
-3049381223523647492,
3501129463520285556,
-4980126173351398283,
-8303518980934164731,
-7446347735086057113,
2615208954064994172,
-522603252265687058,
2237558221535645089,
-3911919600557704777,
-5210711461681408094,
7102368496127332321,
-7719366717024918019,
399232473491847935,
7140013836546489399,
-8234741283244511424,
-2231392863125672626,
-7060197492102713059,
5038446221635409553,
6294769326316815049,
-387802090031244907,
-3350046130045840024,
-2666808022981539793,
-6161723600240465717,
2783168786742146440,
1986639352536355296,
-1988727118208302602,
8799325730492140254,
7305467695957075406,
2551364576700533681,
-6081001307066006598,
-4889804522683628146,
-7324859595388608820,
-6885748294050442179,
5760535140236403614,
1501217875009212803,
-1291632093432900094,
-7706153952057205239,
6454505253869455699,
4319683495060363885,
-6244922308576078969,
-6818767823778904188,
2960027307368769952,
8570410701452901115,
160427886842421800,
-4969938860820756853,
-4627442630994782527,
-3285648034072744413,
-7606118162332863056,
6176075057452006273,
7582622308322968760,
6649763778434249567,
-183456705028906550,
2699628156079216836,
-1767231947251866451,
2945653313023238585,
2813841150172635667,
8163160757531991904,
-7212422464109809801,
-5924618728816493121,
649720531103423106,
6394120152722619742,
-934965811117111118,
4753049982369101610,
2408845162401379802,
1253140645631747605,
-7799048643966905049,
-1584266091164108743,
-456002869645138839,
8367255505928917714,
91400768704631494,
-4464375255980341934,
1938401838693046941,
-7520293791609324052,
-8636597607271566304,
3990523136699180870,
7731749711829208666,
4875740361372990282,
9173201802070489451,
7834799413446679311,
-6433392137177717442,
3325271250982575439,
-8730608807451740020,
-2389358865336045484,
-9209652622095187875,
4359958813756723849,
4539467735137059035,
-5508531677782308793,
1312945880979454078,
-947428475416758718,
4958176066159770025,
1374196081931091686,
-6918434684938959032,
-1095184559281703237,
-1411469442470588444,
3145683508650593868,
-6039522865352658195,
-3804467173852034031,
-6563710254104815428,
6868326517302426863,
6758043032196830276,
5827167051130463242,
4074828688890126937,
3293442170241026694,
-8065760984084440343,
5618223731912049521,
-3014545685365689991,
2520538699101199374
};
private static readonly long[] t3 = new long[256] {
-819712100864953445,
5224129141031473793,
-1683494792012715969,
3214246200928423523,
-2720183745931134014,
3432136347919366758,
-6844377996819786796,
-4697838837464539535,
-3480123136110369641,
-5257202687841710057,
-3160671586143389472,
-8143604544638974599,
-7582212342885995579,
7399204607179264370,
2410740665327626235,
-5531319028708868287,
-1132011872800708955,
-8244108713684067595,
-8100030830173699490,
-865042824158552761,
-1406263208487841571,
-743744098937138031,
-7255025749313877870,
5293216666010209768,
-6686350151342941087,
505172698323928814,
-8504163865352868456,
-6039198373597746942,
2102395425312436973,
-1480681786698906867,
6364975572501938982,
-7035658141633266754,
-8022507636838873565,
-4480433668109774745,
2328871106231838244,
1378680973804076623,
-3586772320324138908,
-2755027987269747529,
7519553577929664460,
460638964809724379,
-99820877092259348,
6562793443469826132,
1580997072160885165,
859005579845670993,
-3058956174016989192,
-3379814835910611228,
-3936971176641920257,
-8723858077265400670,
3784640730692549981,
-2514946515147142870,
-718211188705137671,
5877026246039211124,
-8623573777109189598,
-6383628662057423219,
4036482174343220762,
-6451625591996463702,
-5974472282720051687,
-4119613249555124729,
-4204805774663870152,
1637614953354483776,
1768420517056302872,
-6063481615036972513,
4469119677486524438,
6862084742702193339,
2666591392741323510,
1958911907595193257,
2078226524874004819,
9182514826368667184,
-5667455777910095811,
-6961112304229951815,
7984583406477441100,
5152724216922222472,
-2011927023009527807,
-212234053999724107,
4838452819165657451,
-8437636414480207278,
-4364095106444861094,
-8843563141488759799,
-952547977505311611,
7192165871822020282,
-8957588412064574366,
4293149567017494192,
6266031685674981260,
3297360663327026118,
-7424220229153493459,
1848411117523063487,
4803542876947788811,
-6514007507455064743,
3918859449562378630,
7730455268829558643,
2300310138214025757,
5073098731442674389,
-1867327214174801803,
-5119713925479725192,
2481833961960165662,
3483465760582650171,
-3799159280037322961,
-2614176868807805682,
3683901813415452623,
-6586240258798896426,
-6280196637815307286,
-6878770741467980580,
-8649528727307138543,
1263269478536931145,
-7419991789716909164,
-5769815365846261236,
7280608515770959015,
7790930297845911262,
-5059374975740702796,
-6705059931318638429,
8900403996915095151,
8816891275549542045,
-476483339080012016,
-1232282160203339243,
3119849171172694992,
7662494604586420558,
149203013753700084,
5530308158539891708,
4143436129840869576,
-3411623459852687238,
-1026352410626214551,
-8324492521276276327,
6707891355510602429,
5715986277202524800,
-393206988093480487,
4600951196636466039,
-4593511655318796512,
9065747437067558111,
-8901650410637853864,
2592076422926394627,
228032410479194937,
6667480117540136779,
588648581915253038,
-2336950474993240516,
3634608293302267354,
1202024298738736502,
6299068367672194603,
1932346445954743183,
7573861666572117031,
-61815566784892605,
3549459440654955014,
8158286332358861718,
-7670372790848096527,
-515956617046547146,
-3963219078081420846,
8464707252757847009,
397230465775035974,
-4957137534187579283,
675316509725923312,
2628613740627889320,
-2532211618462009391,
5345232712238813773,
-4776658006885916949,
3062009004852183467,
-2381228231588757251,
74184876899443393,
-1882978417976974457,
9131956796466541322,
8604540880985875509,
22099178757704754,
-1755823172185693422,
-7115222264497037070,
2945473010562318822,
-3264392033958139096,
2789803412788518275,
-5023951698716947073,
-2879016497062593138,
1017933909609308228,
-2136777458168640962,
8230916861376446652,
-4050239832011059757,
8983610917420146076,
8543542228473779244,
1721876046845854392,
-2252284190053484385,
5559864569757380000,
4937681992884682033,
-5441254327629638811,
-9066842030330493037,
5670390740934713304,
2219071780988037499,
7008521987288882964,
6028345117330418825,
-7500176903196747008,
7071075452076274675,
-1604175089662029304,
1445978213955986826,
-7979034942316814172,
951333080223670799,
6099155138413436065,
-4305900099056973791,
-6236769450809946705,
-2912898243239114769,
-2065740773420267803,
-3827177893057145596,
1340472571717533606,
-3648363291767490877,
-5756567784146095673,
4461163794677446508,
-5848717005041324781,
3341940384398866564,
-4882598382547103543,
3829921822543532494,
899996630714791418,
6478536468284266291,
2994597028103565543,
6124895672834828926,
-8376542604899771579,
-4412652237062246342,
-7724700941812371646,
728866099714851926,
339635816873858970,
-1153572816294167456,
-592215260546165052,
-7150089944179092253,
8700134485486622004,
-5552633324984327062,
-1298517758115136471,
8749621007278605595,
-6133576477421907076,
4199955888901663150,
-5341432795218012713,
-239890188217778377,
8106773277103211697,
-2229320058079270256,
5930619164422717276,
4368075505682949467,
4623369983466747106,
8403817438537116875,
-5327756068839670070,
1151085119119418028,
6933250016240323664,
6814675599201764477,
-2995490164984896514,
5778917359701360712,
-7334472845550608018,
-9212347808668562614,
-7786744047088363785,
4025584697920591189,
5446500518121291045,
-7866665254384488512,
-352887593087136842,
8290028954029701554,
-9087549732707247512,
7234639242841923679,
2860911103167493259,
-3716770017321781837,
7444204691177324181,
8012224255291120002,
6549509778060988165,
-4656265058823564969,
-1532696805485516055,
4993489137437819341,
4727924503904151836,
-3180601338503688336,
7858325008468642462
};
private static readonly long[] t4 = new long[256] {
6561287832113134677,
1893413629145602549,
-6205320776685678598,
7334764389497132503,
421942495471316930,
-9085229951450268347,
5948965432456907277,
-6872877502453521409,
4831763938021002582,
-4272888574428519313,
5678704711006605406,
4536654317168965104,
802439540090739142,
1728614842704535657,
7852250862810361152,
-2970083550513149273,
6999787169451700297,
327545298748531618,
-2764213178345403342,
9213801181845131435,
-5950018878971805109,
-2186876610533351532,
-3100863505161590557,
-194921935069456237,
2629011484744925146,
679658461659738748,
-3068808746888436091,
2845612796809381245,
-7722098226173915145,
7273530125705028225,
4410076014410041819,
-2304212329100317967,
-45936371244098582,
-5712723046817425393,
8922873767131958175,
-3382299200423854708,
-3236816455951139535,
-4036747678298392505,
5226125132195873799,
2940247444995640068,
-4418018165041970817,
6671397049608501367,
8821388386505911040,
-3580187736799586652,
-1447046360908978430,
2147098610462912262,
-1956265881574637814,
-2856917834249223582,
5141735866072457044,
3265027362719053310,
-6450920645962515936,
6017965846669640613,
4287051124723328232,
8655371236021312991,
-1156847972119148173,
2365060307249772354,
1630631832073154105,
1828719980936758421,
2674037562503248056,
-7295616781251116690,
-1363141094472255887,
204405347605452144,
5797523068258732423,
8122903338174012641,
8739821670855295734,
961841682317282412,
3487881148722869326,
-7995384159388863717,
7665614591556333409,
-7831409025227614873,
-822907162794399275,
-1691135090558933875,
3797048810173566205,
-2578904300750297763,
-3410711173298709536,
577633178325057199,
-7379212936790430923,
-9035774148364232240,
2754939666238358593,
8444132705799138470,
-7894221632442939675,
3065464070595795438,
-6610449357786147779,
3184382822055416328,
5740274767717360273,
6179930651821454089,
-4826152258144849421,
5115645765347262247,
4602739923119569497,
-3465801151231271281,
-6359599548771540712,
-1926152657970122275,
-8468989295385802946,
-6500580506154635033,
4125629484990072616,
-6834670983768857044,
-4845179353893108027,
4230689665262407186,
-1849684427061896393,
9047540561879224854,
1112218670439199625,
8426162753992594376,
-5990769681480860131,
-2503790423972405993,
4028912247909671416,
-409156412951274838,
-8377831951645714695,
-1152570669068554652,
-6327418252815316840,
-3725559206061705268,
1964465731879646024,
-2441760721249263597,
6946242362685775318,
-3298979752616086841,
-7236283555339513389,
-1419193050620496778,
-93735727476260563,
-5905399081030416230,
2507248404937789251,
7581261321693772141,
-8836566033099333598,
520172056875071564,
3738403388662150470,
-2357506837776452040,
-5002739851233418934,
930169001927683533,
6889748805645999668,
-1031349426815687751,
7941113837267854943,
-1243211017071393764,
-2154628650105719635,
6332043450707792835,
3386824618901547762,
7130458179308482168,
1271522336860346025,
-997034324337437613,
4823850509807911142,
3107332511049695348,
5437793788182680416,
-8315628002795417155,
1494290439970088554,
-8609438560643873897,
-8207953325454440687,
-5432621302919780015,
1159256241058966379,
1026141471931805870,
-8215608786054685932,
-609691062749569444,
7511556330643118785,
-3915792337899679783,
3932170512244996561,
6834333685245251200,
4355290964656419152,
6487547078612259600,
6267880520331323438,
-1545475867304599653,
8190919284549556346,
3366895789332200348,
2444540809879438627,
6459524513146455969,
4077716903750958194,
-6168929569432701476,
-6973483665415634802,
-5197441416039796052,
7734160491610189202,
7910254887717195099,
3836881802794822270,
8311228008842563790,
730509642500215940,
-650400159804944995,
-5124223765383482859,
3579688877020158541,
8591780283260295173,
5028082178778891827,
-498814760953987530,
-2709709455026140056,
5487541034902828271,
8530400576707172340,
-7604535187505054453,
-869656751120750718,
4656569414526204412,
491061932033469878,
8035458231926703496,
137019260109594401,
7421708309958176805,
8223709417363553275,
5401705824239018731,
-7162608250562934562,
5308870500428712900,
-5508949737295341638,
1376856236535589493,
-5655908917112005032,
-7100674984259216372,
1332977380922036690,
3015788518022419172,
-6718854486329987908,
6396540069380292132,
2034188120276215631,
-1655134238111203034,
-509741179510489141,
3623665942510192329,
-9164935270648710301,
1765784450088366494,
5837777785993897047,
1564973338399864744,
-2605395199060435761,
4964475598524693274,
-5312043978489901415,
6706291041494563888,
-789946623649963734,
-8091303779971721549,
7456716478970921562,
-335263357675197259,
-8515348892102079999,
-7048796562806032069,
-233028078259189719,
284725780453796946,
-3832073186324226638,
-4921235094493811069,
-5089093504863659344,
-5607539644671350465,
-8911681616096439592,
-4743899514573401058,
-7664321526450198170,
-4599281686566632149,
2560491659082246267,
8971180328015050686,
2265540171276805379,
6093561527083620308,
12169565841013306,
9128413284208255679,
-4178722056535276608,
-8960148414521589626,
-4216952774774654326,
-5374970407177951367,
-6668788646589711127,
-2946910590031425822,
-8674853389405194592,
-7535980417822448849,
-6115357923114297461,
-8065837346967928004,
-7487037274649424496,
-2061373546992596293,
-5783192355322733388,
7153300451507295513,
-8779488031786375734,
2187906506867626476,
5612681432830855607,
-4653220181978985551,
4688837593722596333,
-3815667051463559517,
-1779743783662362556,
-3650491565905270770,
-4529053496248414107,
-4021111997381021802,
-4350414089199835873
};
private const int DigestLength = 24;
private long a;
private long b;
private long c;
private long byteCount;
private byte[] m_buffer = new byte[8];
private int bOff;
private long[] x = new long[8];
private int xOff;
public string AlgorithmName => "Tiger";
public TigerDigest()
{
Reset();
}
public TigerDigest(TigerDigest t)
{
Reset(t);
}
public int GetDigestSize()
{
return 24;
}
public int GetByteLength()
{
return 64;
}
private void ProcessWord(byte[] b, int off)
{
x[xOff++] = (long)Pack.LE_To_UInt64(b, off);
if (xOff == x.Length)
ProcessBlock();
bOff = 0;
}
private void ProcessWord(ReadOnlySpan<byte> b)
{
x[xOff++] = (long)Pack.LE_To_UInt64(b);
if (xOff == x.Length)
ProcessBlock();
bOff = 0;
}
public void Update(byte input)
{
m_buffer[bOff++] = input;
if (bOff == m_buffer.Length)
ProcessWord(m_buffer, 0);
byteCount++;
}
public void BlockUpdate(byte[] input, int inOff, int length)
{
while (bOff != 0 && length > 0) {
Update(input[inOff]);
inOff++;
length--;
}
while (length >= 8) {
ProcessWord(input, inOff);
inOff += 8;
length -= 8;
byteCount += 8;
}
while (length > 0) {
Update(input[inOff]);
inOff++;
length--;
}
}
public void BlockUpdate(ReadOnlySpan<byte> input)
{
int num = 0;
int num2 = input.Length;
while (bOff != 0 && num2 > 0) {
Update(input[num]);
num++;
num2--;
}
while (num2 >= 8) {
int num3 = num;
ProcessWord(input.Slice(num3, input.Length - num3));
num += 8;
num2 -= 8;
byteCount += 8;
}
while (num2 > 0) {
Update(input[num]);
num++;
num2--;
}
}
private void RoundABC(long x, long mul)
{
c ^= x;
a -= (t1[(int)c & 255] ^ t2[(int)(c >> 16) & 255] ^ t3[(int)(c >> 32) & 255] ^ t4[(int)(c >> 48) & 255]);
b += (t4[(int)(c >> 8) & 255] ^ t3[(int)(c >> 24) & 255] ^ t2[(int)(c >> 40) & 255] ^ t1[(int)(c >> 56) & 255]);
b *= mul;
}
private void RoundBCA(long x, long mul)
{
a ^= x;
b -= (t1[(int)a & 255] ^ t2[(int)(a >> 16) & 255] ^ t3[(int)(a >> 32) & 255] ^ t4[(int)(a >> 48) & 255]);
c += (t4[(int)(a >> 8) & 255] ^ t3[(int)(a >> 24) & 255] ^ t2[(int)(a >> 40) & 255] ^ t1[(int)(a >> 56) & 255]);
c *= mul;
}
private void RoundCAB(long x, long mul)
{
b ^= x;
c -= (t1[(int)b & 255] ^ t2[(int)(b >> 16) & 255] ^ t3[(int)(b >> 32) & 255] ^ t4[(int)(b >> 48) & 255]);
a += (t4[(int)(b >> 8) & 255] ^ t3[(int)(b >> 24) & 255] ^ t2[(int)(b >> 40) & 255] ^ t1[(int)(b >> 56) & 255]);
a *= mul;
}
private void KeySchedule()
{
x[0] -= (x[7] ^ -6510615555426900571);
x[1] ^= x[0];
x[2] += x[1];
x[3] -= (x[2] ^ (~x[1] << 19));
x[4] ^= x[3];
x[5] += x[4];
x[6] -= (x[5] ^ (long)((ulong)(~x[4]) >> 23));
x[7] ^= x[6];
x[0] += x[7];
x[1] -= (x[0] ^ (~x[7] << 19));
x[2] ^= x[1];
x[3] += x[2];
x[4] -= (x[3] ^ (long)((ulong)(~x[2]) >> 23));
x[5] ^= x[4];
x[6] += x[5];
x[7] -= (x[6] ^ 81985529216486895);
}
private void ProcessBlock()
{
long num = a;
long num2 = b;
long num3 = c;
RoundABC(x[0], 5);
RoundBCA(x[1], 5);
RoundCAB(x[2], 5);
RoundABC(x[3], 5);
RoundBCA(x[4], 5);
RoundCAB(x[5], 5);
RoundABC(x[6], 5);
RoundBCA(x[7], 5);
KeySchedule();
RoundCAB(x[0], 7);
RoundABC(x[1], 7);
RoundBCA(x[2], 7);
RoundCAB(x[3], 7);
RoundABC(x[4], 7);
RoundBCA(x[5], 7);
RoundCAB(x[6], 7);
RoundABC(x[7], 7);
KeySchedule();
RoundBCA(x[0], 9);
RoundCAB(x[1], 9);
RoundABC(x[2], 9);
RoundBCA(x[3], 9);
RoundCAB(x[4], 9);
RoundABC(x[5], 9);
RoundBCA(x[6], 9);
RoundCAB(x[7], 9);
a ^= num;
b -= num2;
c += num3;
xOff = 0;
for (int i = 0; i != x.Length; i++) {
x[i] = 0;
}
}
private void ProcessLength(long bitLength)
{
x[7] = bitLength;
}
private void Finish()
{
long bitLength = byteCount << 3;
Update(1);
while (bOff != 0) {
Update(0);
}
ProcessLength(bitLength);
ProcessBlock();
}
public int DoFinal(byte[] output, int outOff)
{
Finish();
Pack.UInt64_To_LE((ulong)a, output, outOff);
Pack.UInt64_To_LE((ulong)b, output, outOff + 8);
Pack.UInt64_To_LE((ulong)c, output, outOff + 16);
Reset();
return 24;
}
public int DoFinal(Span<byte> output)
{
Finish();
Pack.UInt64_To_LE((ulong)a, output);
Pack.UInt64_To_LE((ulong)b, output.Slice(8, output.Length - 8));
Pack.UInt64_To_LE((ulong)c, output.Slice(16, output.Length - 16));
Reset();
return 24;
}
public void Reset()
{
a = 81985529216486895;
b = -81985529216486896;
c = -1110518062304271993;
xOff = 0;
for (int i = 0; i != x.Length; i++) {
x[i] = 0;
}
bOff = 0;
for (int j = 0; j != m_buffer.Length; j++) {
m_buffer[j] = 0;
}
byteCount = 0;
}
public IMemoable Copy()
{
return new TigerDigest(this);
}
public void Reset(IMemoable other)
{
TigerDigest tigerDigest = (TigerDigest)other;
a = tigerDigest.a;
b = tigerDigest.b;
c = tigerDigest.c;
Array.Copy(tigerDigest.x, 0, x, 0, tigerDigest.x.Length);
xOff = tigerDigest.xOff;
Array.Copy(tigerDigest.m_buffer, 0, m_buffer, 0, tigerDigest.m_buffer.Length);
bOff = tigerDigest.bOff;
byteCount = tigerDigest.byteCount;
}
}
}