CBZip2InputStream.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. /*
  4. * Licensed to the Apache Software Foundation (ASF) under one or more
  5. * contributor license agreements. See the NOTICE file distributed with
  6. * this work for additional information regarding copyright ownership.
  7. * The ASF licenses this file to You under the Apache License, Version 2.0
  8. * (the "License"); you may not use this file except in compliance with
  9. * the License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. */
  20. /*
  21. * This package is based on the work done by Keiron Liddle, Aftex Software
  22. * <keiron@aftexsw.com> to whom the Ant project is very grateful for his
  23. * great code.
  24. */
  25. using System;
  26. using System.Diagnostics;
  27. using System.IO;
  28. using Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO;
  29. namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.Bzip2
  30. {
  31. /**
  32. * An input stream that decompresses from the BZip2 format (with the file
  33. * header chars) to be read as any other stream.
  34. *
  35. * @author <a href="mailto:keiron@aftexsw.com">Keiron Liddle</a>
  36. *
  37. * <b>NB:</b> note this class has been modified to read the leading BZ from the
  38. * start of the BZIP2 stream to make it compatible with other PGP programs.
  39. */
  40. public class CBZip2InputStream
  41. : BaseInputStream
  42. {
  43. /*
  44. index of the last char in the block, so
  45. the block size == last + 1.
  46. */
  47. private int last;
  48. /*
  49. index in zptr[] of original string after sorting.
  50. */
  51. private int origPtr;
  52. /*
  53. always: in the range 0 .. 9.
  54. The current block size is 100000 * this number.
  55. */
  56. private int blockSize100k;
  57. private int bsBuff;
  58. private int bsLive;
  59. private readonly CRC m_blockCrc = new CRC();
  60. private int nInUse;
  61. private byte[] seqToUnseq = new byte[256];
  62. private byte[] m_selectors = new byte[BZip2Constants.MAX_SELECTORS];
  63. private int[] tt;
  64. private byte[] ll8;
  65. /*
  66. freq table collected to save a pass over the data
  67. during decompression.
  68. */
  69. private int[] unzftab = new int[256];
  70. private int[][] limit = CreateIntArray(BZip2Constants.N_GROUPS, BZip2Constants.MAX_CODE_LEN + 1);
  71. private int[][] basev = CreateIntArray(BZip2Constants.N_GROUPS, BZip2Constants.MAX_CODE_LEN + 1);
  72. private int[][] perm = CreateIntArray(BZip2Constants.N_GROUPS, BZip2Constants.MAX_ALPHA_SIZE);
  73. private int[] minLens = new int[BZip2Constants.N_GROUPS];
  74. private Stream bsStream;
  75. private bool streamEnd = false;
  76. private int currentByte = -1;
  77. private const int RAND_PART_B_STATE = 1;
  78. private const int RAND_PART_C_STATE = 2;
  79. private const int NO_RAND_PART_B_STATE = 3;
  80. private const int NO_RAND_PART_C_STATE = 4;
  81. private int currentState = 0;
  82. private int m_expectedBlockCrc, m_expectedStreamCrc, m_streamCrc;
  83. int i2, count, chPrev, ch2;
  84. int i, tPos;
  85. int rNToGo = 0;
  86. int rTPos = 0;
  87. int j2;
  88. int z;
  89. public CBZip2InputStream(Stream zStream)
  90. {
  91. ll8 = null;
  92. tt = null;
  93. bsStream = zStream;
  94. bsLive = 0;
  95. bsBuff = 0;
  96. int magic1 = bsStream.ReadByte();
  97. int magic2 = bsStream.ReadByte();
  98. int version = bsStream.ReadByte();
  99. int level = bsStream.ReadByte();
  100. if (level < 0)
  101. throw new EndOfStreamException();
  102. if (magic1 != 'B' | magic2 != 'Z' | version != 'h' | level < '1' | level > '9')
  103. throw new IOException("Invalid stream header");
  104. blockSize100k = level - '0';
  105. int n = BZip2Constants.baseBlockSize * blockSize100k;
  106. ll8 = new byte[n];
  107. tt = new int[n];
  108. m_streamCrc = 0;
  109. BeginBlock();
  110. }
  111. public override int Read(byte[] buffer, int offset, int count)
  112. {
  113. Streams.ValidateBufferArguments(buffer, offset, count);
  114. /*
  115. * TODO The base class implementation allows to return partial data if/when ReadByte throws. That would be
  116. * be preferable here too (so don't override), but it would require that exceptions cause this instance to
  117. * permanently fail, and that needs review.
  118. */
  119. int pos = 0;
  120. while (pos < count)
  121. {
  122. int b = ReadByte();
  123. if (b < 0)
  124. break;
  125. buffer[offset + pos++] = (byte)b;
  126. }
  127. return pos;
  128. }
  129. public override int ReadByte()
  130. {
  131. if (streamEnd)
  132. return -1;
  133. int result = currentByte;
  134. switch (currentState)
  135. {
  136. case RAND_PART_B_STATE:
  137. SetupRandPartB();
  138. break;
  139. case RAND_PART_C_STATE:
  140. SetupRandPartC();
  141. break;
  142. case NO_RAND_PART_B_STATE:
  143. SetupNoRandPartB();
  144. break;
  145. case NO_RAND_PART_C_STATE:
  146. SetupNoRandPartC();
  147. break;
  148. default:
  149. throw new InvalidOperationException();
  150. }
  151. return result;
  152. }
  153. private void BeginBlock()
  154. {
  155. long magic48 = BsGetLong48();
  156. if (magic48 != 0x314159265359L)
  157. {
  158. if (magic48 != 0x177245385090L)
  159. throw new IOException("Block header error");
  160. m_expectedStreamCrc = BsGetInt32();
  161. if (m_expectedStreamCrc != m_streamCrc)
  162. throw new IOException("Stream CRC error");
  163. BsFinishedWithStream();
  164. streamEnd = true;
  165. return;
  166. }
  167. m_expectedBlockCrc = BsGetInt32();
  168. bool blockRandomised = BsGetBit() == 1;
  169. GetAndMoveToFrontDecode();
  170. m_blockCrc.Initialise();
  171. int[] cftab = new int[257];
  172. {
  173. int accum = 0;
  174. cftab[0] = 0;
  175. for (i = 0; i < 256; ++i)
  176. {
  177. accum += unzftab[i];
  178. cftab[i + 1] = accum;
  179. }
  180. if (accum != (last + 1))
  181. throw new InvalidOperationException();
  182. }
  183. for (i = 0; i <= last; i++)
  184. {
  185. byte ch = ll8[i];
  186. tt[cftab[ch]++] = i;
  187. }
  188. tPos = tt[origPtr];
  189. count = 0;
  190. i2 = 0;
  191. ch2 = 256; /* not a char and not EOF */
  192. if (blockRandomised)
  193. {
  194. rNToGo = 0;
  195. rTPos = 0;
  196. SetupRandPartA();
  197. }
  198. else
  199. {
  200. SetupNoRandPartA();
  201. }
  202. }
  203. private void EndBlock()
  204. {
  205. int blockFinalCrc = m_blockCrc.GetFinal();
  206. if (m_expectedBlockCrc != blockFinalCrc)
  207. throw new IOException("Block CRC error");
  208. m_streamCrc = Integers.RotateLeft(m_streamCrc, 1) ^ blockFinalCrc;
  209. }
  210. private void BsFinishedWithStream()
  211. {
  212. try
  213. {
  214. if (this.bsStream != null)
  215. {
  216. this.bsStream.Dispose();
  217. this.bsStream = null;
  218. }
  219. }
  220. catch
  221. {
  222. //ignore
  223. }
  224. }
  225. private int BsGetBit()
  226. {
  227. if (bsLive == 0)
  228. {
  229. bsBuff = RequireByte();
  230. bsLive = 7;
  231. return (int)((uint)bsBuff >> 7);
  232. }
  233. --bsLive;
  234. return (bsBuff >> bsLive) & 1;
  235. }
  236. private int BsGetBits(int n)
  237. {
  238. Debug.Assert(1 <= n && n <= 24);
  239. while (bsLive < n)
  240. {
  241. bsBuff = (bsBuff << 8) | RequireByte();
  242. bsLive += 8;
  243. }
  244. bsLive -= n;
  245. return (bsBuff >> bsLive) & ((1 << n) - 1);
  246. }
  247. private int BsGetBitsSmall(int n)
  248. {
  249. Debug.Assert(1 <= n && n <= 8);
  250. if (bsLive < n)
  251. {
  252. bsBuff = (bsBuff << 8) | RequireByte();
  253. bsLive += 8;
  254. }
  255. bsLive -= n;
  256. return (bsBuff >> bsLive) & ((1 << n) - 1);
  257. }
  258. private int BsGetInt32()
  259. {
  260. int u = BsGetBits(16) << 16;
  261. return u | BsGetBits(16);
  262. }
  263. private long BsGetLong48()
  264. {
  265. long u = (long)BsGetBits(24) << 24;
  266. return u | (long)BsGetBits(24);
  267. }
  268. private void HbCreateDecodeTables(int[] limit, int[] basev, int[] perm, byte[] length, int minLen, int maxLen,
  269. int alphaSize)
  270. {
  271. Array.Clear(basev, 0, basev.Length);
  272. Array.Clear(limit, 0, limit.Length);
  273. int pp = 0, baseVal = 0;
  274. for (int i = minLen; i <= maxLen; i++)
  275. {
  276. for (int j = 0; j < alphaSize; j++)
  277. {
  278. if (length[j] == i)
  279. {
  280. perm[pp++] = j;
  281. }
  282. }
  283. basev[i] = baseVal;
  284. limit[i] = baseVal + pp;
  285. baseVal += baseVal + pp;
  286. }
  287. }
  288. private int RecvDecodingTables()
  289. {
  290. int i, j;
  291. nInUse = 0;
  292. /* Receive the mapping table */
  293. int inUse16 = BsGetBits(16);
  294. for (i = 0; i < 16; ++i)
  295. {
  296. if ((inUse16 & (0x8000 >> i)) != 0)
  297. {
  298. int inUse = BsGetBits(16);
  299. int i16 = i * 16;
  300. for (j = 0; j < 16; ++j)
  301. {
  302. if ((inUse & (0x8000 >> j)) != 0)
  303. {
  304. seqToUnseq[nInUse++] = (byte)(i16 + j);
  305. }
  306. }
  307. }
  308. }
  309. if (nInUse < 1)
  310. throw new InvalidOperationException();
  311. int alphaSize = nInUse + 2;
  312. /* Now the selectors */
  313. int nGroups = BsGetBitsSmall(3);
  314. if (nGroups < 2 || nGroups > BZip2Constants.N_GROUPS)
  315. throw new InvalidOperationException();
  316. int nSelectors = BsGetBits(15);
  317. if (nSelectors < 1)
  318. throw new InvalidOperationException();
  319. uint mtfGroups = 0x00543210U;
  320. for (i = 0; i < nSelectors; i++)
  321. {
  322. int mtfSelector = 0;
  323. while (BsGetBit() == 1)
  324. {
  325. if (++mtfSelector >= nGroups)
  326. throw new InvalidOperationException();
  327. }
  328. // Ignore declared selectors in excess of the maximum usable number
  329. if (i >= BZip2Constants.MAX_SELECTORS)
  330. continue;
  331. // Undo the MTF value for the selector.
  332. switch (mtfSelector)
  333. {
  334. case 0:
  335. break;
  336. case 1:
  337. mtfGroups = (mtfGroups >> 4) & 0x00000FU | (mtfGroups << 4) & 0x0000F0U | mtfGroups & 0xFFFF00U;
  338. break;
  339. case 2:
  340. mtfGroups = (mtfGroups >> 8) & 0x00000FU | (mtfGroups << 4) & 0x000FF0U | mtfGroups & 0xFFF000U;
  341. break;
  342. case 3:
  343. mtfGroups = (mtfGroups >> 12) & 0x00000FU | (mtfGroups << 4) & 0x00FFF0U | mtfGroups & 0xFF0000U;
  344. break;
  345. case 4:
  346. mtfGroups = (mtfGroups >> 16) & 0x00000FU | (mtfGroups << 4) & 0x0FFFF0U | mtfGroups & 0xF00000U;
  347. break;
  348. case 5:
  349. mtfGroups = (mtfGroups >> 20) & 0x00000FU | (mtfGroups << 4) & 0xFFFFF0U;
  350. break;
  351. default:
  352. throw new InvalidOperationException();
  353. }
  354. m_selectors[i] = (byte)(mtfGroups & 0xF);
  355. }
  356. byte[] len_t = new byte[alphaSize];
  357. /* Now the coding tables */
  358. for (int t = 0; t < nGroups; t++)
  359. {
  360. int maxLen = 0, minLen = 32;
  361. int curr = BsGetBitsSmall(5);
  362. if ((curr < 1) | (curr > BZip2Constants.MAX_CODE_LEN))
  363. throw new InvalidOperationException();
  364. for (i = 0; i < alphaSize; i++)
  365. {
  366. int markerBit = BsGetBit();
  367. while (markerBit != 0)
  368. {
  369. int nextTwoBits = BsGetBitsSmall(2);
  370. curr += 1 - (nextTwoBits & 2);
  371. if ((curr < 1) | (curr > BZip2Constants.MAX_CODE_LEN))
  372. throw new InvalidOperationException();
  373. markerBit = nextTwoBits & 1;
  374. }
  375. len_t[i] = (byte)curr;
  376. maxLen = System.Math.Max(maxLen, curr);
  377. minLen = System.Math.Min(minLen, curr);
  378. }
  379. /* Create the Huffman decoding tables */
  380. HbCreateDecodeTables(limit[t], basev[t], perm[t], len_t, minLen, maxLen, alphaSize);
  381. minLens[t] = minLen;
  382. }
  383. return nSelectors;
  384. }
  385. private void GetAndMoveToFrontDecode()
  386. {
  387. int i, j, nextSym;
  388. int limitLast = BZip2Constants.baseBlockSize * blockSize100k;
  389. origPtr = BsGetBits(24);
  390. if (origPtr > 10 + limitLast)
  391. throw new InvalidOperationException();
  392. int nSelectors = RecvDecodingTables();
  393. int alphaSize = nInUse + 2;
  394. int EOB = nInUse + 1;
  395. /*
  396. Setting up the unzftab entries here is not strictly
  397. necessary, but it does save having to do it later
  398. in a separate pass, and so saves a block's worth of
  399. cache misses.
  400. */
  401. Array.Clear(unzftab, 0, unzftab.Length);
  402. byte[] yy = new byte[nInUse];
  403. for (i = 0; i < nInUse; ++i)
  404. {
  405. yy[i] = seqToUnseq[i];
  406. }
  407. last = -1;
  408. int groupNo = 0;
  409. int groupPos = BZip2Constants.G_SIZE - 1;
  410. int groupSel = m_selectors[groupNo];
  411. int groupMinLen = minLens[groupSel];
  412. int[] groupLimits = limit[groupSel];
  413. int[] groupPerm = perm[groupSel];
  414. int[] groupBase = basev[groupSel];
  415. {
  416. int zn = groupMinLen;
  417. int zvec = BsGetBits(groupMinLen);
  418. while (zvec >= groupLimits[zn])
  419. {
  420. if (++zn > BZip2Constants.MAX_CODE_LEN)
  421. throw new InvalidOperationException();
  422. zvec = (zvec << 1) | BsGetBit();
  423. }
  424. int permIndex = zvec - groupBase[zn];
  425. if (permIndex >= alphaSize)
  426. throw new InvalidOperationException();
  427. nextSym = groupPerm[permIndex];
  428. }
  429. while (nextSym != EOB)
  430. {
  431. //if (nextSym == BZip2Constants.RUNA || nextSym == BZip2Constants.RUNB)
  432. if (nextSym <= BZip2Constants.RUNB)
  433. {
  434. int n = 1, s = 0;
  435. do
  436. {
  437. if (n > 1024 * 1024)
  438. throw new InvalidOperationException();
  439. s += n << nextSym;
  440. n <<= 1;
  441. {
  442. if (groupPos == 0)
  443. {
  444. if (++groupNo >= nSelectors)
  445. throw new InvalidOperationException();
  446. groupPos = BZip2Constants.G_SIZE;
  447. groupSel = m_selectors[groupNo];
  448. groupMinLen = minLens[groupSel];
  449. groupLimits = limit[groupSel];
  450. groupPerm = perm[groupSel];
  451. groupBase = basev[groupSel];
  452. }
  453. groupPos--;
  454. int zn = groupMinLen;
  455. int zvec = BsGetBits(groupMinLen);
  456. while (zvec >= groupLimits[zn])
  457. {
  458. if (++zn > BZip2Constants.MAX_CODE_LEN)
  459. throw new InvalidOperationException();
  460. zvec = (zvec << 1) | BsGetBit();
  461. }
  462. int permIndex = zvec - groupBase[zn];
  463. if (permIndex >= alphaSize)
  464. throw new InvalidOperationException();
  465. nextSym = groupPerm[permIndex];
  466. }
  467. }
  468. //while (nextSym == BZip2Constants.RUNA || nextSym == BZip2Constants.RUNB);
  469. while (nextSym <= BZip2Constants.RUNB);
  470. byte ch = yy[0];
  471. unzftab[ch] += s;
  472. if (last >= limitLast - s)
  473. throw new InvalidOperationException("Block overrun");
  474. while (--s >= 0)
  475. {
  476. ll8[++last] = ch;
  477. }
  478. continue;
  479. }
  480. else
  481. {
  482. if (++last >= limitLast)
  483. throw new InvalidOperationException("Block overrun");
  484. byte tmp = yy[nextSym - 1];
  485. unzftab[tmp]++;
  486. ll8[last] = tmp;
  487. /*
  488. * This loop is hammered during decompression, hence avoid
  489. * native method call overhead of Array.Copy for very
  490. * small ranges to copy.
  491. */
  492. if (nextSym <= 16)
  493. {
  494. for (j = nextSym - 1; j > 0; --j)
  495. {
  496. yy[j] = yy[j - 1];
  497. }
  498. }
  499. else
  500. {
  501. Array.Copy(yy, 0, yy, 1, nextSym - 1);
  502. }
  503. yy[0] = tmp;
  504. {
  505. if (groupPos == 0)
  506. {
  507. if (++groupNo >= nSelectors)
  508. throw new InvalidOperationException();
  509. groupPos = BZip2Constants.G_SIZE;
  510. groupSel = m_selectors[groupNo];
  511. groupMinLen = minLens[groupSel];
  512. groupLimits = limit[groupSel];
  513. groupPerm = perm[groupSel];
  514. groupBase = basev[groupSel];
  515. }
  516. groupPos--;
  517. int zn = groupMinLen;
  518. int zvec = BsGetBits(groupMinLen);
  519. while (zvec >= groupLimits[zn])
  520. {
  521. if (++zn > BZip2Constants.MAX_CODE_LEN)
  522. throw new InvalidOperationException();
  523. zvec = (zvec << 1) | BsGetBit();
  524. }
  525. int permIndex = zvec - groupBase[zn];
  526. if (permIndex >= alphaSize)
  527. throw new InvalidOperationException();
  528. nextSym = groupPerm[permIndex];
  529. }
  530. continue;
  531. }
  532. }
  533. if (origPtr > last)
  534. throw new InvalidOperationException();
  535. // Check unzftab entries are in range.
  536. {
  537. int nblock = last + 1;
  538. int check = 0;
  539. for (i = 0; i <= 255; i++)
  540. {
  541. int t = unzftab[i];
  542. check |= t;
  543. check |= nblock - t;
  544. }
  545. if (check < 0)
  546. throw new InvalidOperationException();
  547. }
  548. }
  549. private int RequireByte()
  550. {
  551. int b = bsStream.ReadByte();
  552. if (b < 0)
  553. throw new EndOfStreamException();
  554. return b & 0xFF;
  555. }
  556. private void SetupRandPartA()
  557. {
  558. if (i2 <= last)
  559. {
  560. chPrev = ch2;
  561. ch2 = ll8[tPos];
  562. tPos = tt[tPos];
  563. if (rNToGo == 0)
  564. {
  565. rNToGo = CBZip2OutputStream.RNums[rTPos++];
  566. rTPos &= 0x1FF;
  567. }
  568. rNToGo--;
  569. ch2 ^= rNToGo == 1 ? 1 : 0;
  570. i2++;
  571. currentByte = ch2;
  572. currentState = RAND_PART_B_STATE;
  573. m_blockCrc.Update((byte)ch2);
  574. }
  575. else
  576. {
  577. EndBlock();
  578. BeginBlock();
  579. }
  580. }
  581. private void SetupNoRandPartA()
  582. {
  583. if (i2 <= last)
  584. {
  585. chPrev = ch2;
  586. ch2 = ll8[tPos];
  587. tPos = tt[tPos];
  588. i2++;
  589. currentByte = ch2;
  590. currentState = NO_RAND_PART_B_STATE;
  591. m_blockCrc.Update((byte)ch2);
  592. }
  593. else
  594. {
  595. EndBlock();
  596. BeginBlock();
  597. }
  598. }
  599. private void SetupRandPartB()
  600. {
  601. if (ch2 != chPrev)
  602. {
  603. count = 1;
  604. SetupRandPartA();
  605. }
  606. else if (++count < 4)
  607. {
  608. SetupRandPartA();
  609. }
  610. else
  611. {
  612. z = ll8[tPos];
  613. tPos = tt[tPos];
  614. if (rNToGo == 0)
  615. {
  616. rNToGo = CBZip2OutputStream.RNums[rTPos++];
  617. rTPos &= 0x1FF;
  618. }
  619. rNToGo--;
  620. z ^= rNToGo == 1 ? 1 : 0;
  621. j2 = 0;
  622. currentState = RAND_PART_C_STATE;
  623. SetupRandPartC();
  624. }
  625. }
  626. private void SetupNoRandPartB()
  627. {
  628. if (ch2 != chPrev)
  629. {
  630. count = 1;
  631. SetupNoRandPartA();
  632. }
  633. else if (++count < 4)
  634. {
  635. SetupNoRandPartA();
  636. }
  637. else
  638. {
  639. z = ll8[tPos];
  640. tPos = tt[tPos];
  641. currentState = NO_RAND_PART_C_STATE;
  642. j2 = 0;
  643. SetupNoRandPartC();
  644. }
  645. }
  646. private void SetupRandPartC()
  647. {
  648. if (j2 < z)
  649. {
  650. currentByte = ch2;
  651. m_blockCrc.Update((byte)ch2);
  652. j2++;
  653. }
  654. else
  655. {
  656. i2++;
  657. count = 0;
  658. SetupRandPartA();
  659. }
  660. }
  661. private void SetupNoRandPartC()
  662. {
  663. if (j2 < z)
  664. {
  665. currentByte = ch2;
  666. m_blockCrc.Update((byte)ch2);
  667. j2++;
  668. }
  669. else
  670. {
  671. i2++;
  672. count = 0;
  673. SetupNoRandPartA();
  674. }
  675. }
  676. internal static int[][] CreateIntArray(int n1, int n2)
  677. {
  678. int[][] a = new int[n1][];
  679. for (int k = 0; k < n1; ++k)
  680. {
  681. a[k] = new int[n2];
  682. }
  683. return a;
  684. }
  685. }
  686. }
  687. #pragma warning restore
  688. #endif