SHA1CryptoServiceProvider.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. //
  2. // System.Security.Cryptography SHA1CryptoServiceProvider Class implementation
  3. //
  4. // Authors:
  5. // Matthew S. Ford ([email protected])
  6. // Sebastien Pouliot ([email protected])
  7. //
  8. // Copyright 2001 by Matthew S. Ford.
  9. //
  10. // Note:
  11. // The MS Framework includes two (almost) identical class for SHA1.
  12. // SHA1Managed is a 100% managed implementation.
  13. // SHA1CryptoServiceProvider (this file) is a wrapper on CryptoAPI.
  14. // Mono must provide those two class for binayry compatibility.
  15. // In our case both class are wrappers around a managed internal class SHA1Internal.
  16. namespace System.Security.Cryptography {
  17. /// <summary>
  18. /// C# implementation of the SHA1 cryptographic hash function.
  19. /// LAMESPEC?: Basically the same thing as SHA1Managed except for how its implemented.
  20. /// </summary>
  21. internal class SHA1Internal {
  22. private const int BLOCK_SIZE_BYTES = 64;
  23. private const int HASH_SIZE_BYTES = 20;
  24. private const int HASH_SIZE_BITS = 160;
  25. [CLSCompliant(false)] private uint[] _H; // these are my chaining variables
  26. [CLSCompliant(false)] private uint count;
  27. private byte[] _ProcessingBuffer; // Used to start data when passed less than a block worth.
  28. private int _ProcessingBufferCount; // Counts how much data we have stored that still needs processed.
  29. /// <summary>
  30. /// Creates a new SHA1CryptoServiceProvider.
  31. /// </summary>
  32. public SHA1Internal ()
  33. {
  34. _H = new uint[5];
  35. _ProcessingBuffer = new byte[BLOCK_SIZE_BYTES];
  36. Initialize();
  37. }
  38. /// <summary>
  39. /// Drives the hashing function.
  40. /// </summary>
  41. /// <param name="rgb">Byte array containing the data to hash.</param>
  42. /// <param name="start">Where in the input buffer to start.</param>
  43. /// <param name="size">Size in bytes of the data in the buffer to hash.</param>
  44. public void HashCore (byte[] rgb, int start, int size)
  45. {
  46. int i;
  47. if (_ProcessingBufferCount != 0) {
  48. if (size < (BLOCK_SIZE_BYTES - _ProcessingBufferCount)) {
  49. System.Buffer.BlockCopy (rgb, start, _ProcessingBuffer, _ProcessingBufferCount, size);
  50. _ProcessingBufferCount += size;
  51. return;
  52. }
  53. else {
  54. i = (BLOCK_SIZE_BYTES - _ProcessingBufferCount);
  55. System.Buffer.BlockCopy (rgb, start, _ProcessingBuffer, _ProcessingBufferCount, i);
  56. ProcessBlock (_ProcessingBuffer, 0);
  57. _ProcessingBufferCount = 0;
  58. start += i;
  59. size -= i;
  60. }
  61. }
  62. for (i=0; i<size-size%BLOCK_SIZE_BYTES; i += BLOCK_SIZE_BYTES) {
  63. ProcessBlock (rgb, start+i);
  64. }
  65. if (size%BLOCK_SIZE_BYTES != 0) {
  66. System.Buffer.BlockCopy (rgb, size-size%BLOCK_SIZE_BYTES+start, _ProcessingBuffer, 0, size%BLOCK_SIZE_BYTES);
  67. _ProcessingBufferCount = size%BLOCK_SIZE_BYTES;
  68. }
  69. }
  70. /// <summary>
  71. /// This finalizes the hash. Takes the data from the chaining variables and returns it.
  72. /// </summary>
  73. public byte[] HashFinal ()
  74. {
  75. byte[] hash = new byte[20];
  76. int i, j;
  77. ProcessFinalBlock(_ProcessingBuffer, 0, _ProcessingBufferCount);
  78. for (i=0; i<5; i++) {
  79. for (j=0; j<4; j++) {
  80. hash[i*4+j] = (byte)(_H[i] >> (8*(3-j)));
  81. }
  82. }
  83. return hash;
  84. }
  85. /// <summary>
  86. /// Resets the class after use. Called automatically after hashing is done.
  87. /// </summary>
  88. public void Initialize ()
  89. {
  90. count = 0;
  91. _ProcessingBufferCount = 0;
  92. _H[0] = 0x67452301;
  93. _H[1] = 0xefcdab89;
  94. _H[2] = 0x98badcfe;
  95. _H[3] = 0x10325476;
  96. _H[4] = 0xC3D2E1F0;
  97. }
  98. /// <summary>
  99. /// This is the meat of the hash function. It is what processes each block one at a time.
  100. /// </summary>
  101. /// <param name="inputBuffer">Byte array to process data from.</param>
  102. /// <param name="inputOffset">Where in the byte array to start processing.</param>
  103. public void ProcessBlock(byte[] inputBuffer, int inputOffset)
  104. {
  105. uint[] buff = new uint[80];
  106. uint a, b, c, d, e;
  107. int i;
  108. count += BLOCK_SIZE_BYTES;
  109. for (i=0; i<16; i++) {
  110. buff[i] = ((uint)(inputBuffer[inputOffset+4*i]) << 24)
  111. | ((uint)(inputBuffer[inputOffset+4*i+1]) << 16)
  112. | ((uint)(inputBuffer[inputOffset+4*i+2]) << 8)
  113. | ((uint)(inputBuffer[inputOffset+4*i+3]));
  114. }
  115. for (i=16; i<80; i++) {
  116. buff[i] = ((buff[i-3] ^ buff[i-8] ^ buff[i-14] ^ buff[i-16]) << 1)
  117. | ((buff[i-3] ^ buff[i-8] ^ buff[i-14] ^ buff[i-16]) >> 31);
  118. }
  119. a = _H[0];
  120. b = _H[1];
  121. c = _H[2];
  122. d = _H[3];
  123. e = _H[4];
  124. // This function was unrolled because it seems to be doubling our performance with current compiler/VM.
  125. // Possibly roll up if this changes.
  126. // ---- Round 1 --------
  127. e += ((a << 5) | (a >> 27)) + (((c ^ d) & b) ^ d) + 0x5A827999 + buff[0];
  128. b = (b << 30) | (b >> 2);
  129. d += ((e << 5) | (e >> 27)) + (((b ^ c) & a) ^ c) + 0x5A827999 + buff[1];
  130. a = (a << 30) | (a >> 2);
  131. c += ((d << 5) | (d >> 27)) + (((a ^ b) & e) ^ b) + 0x5A827999 + buff[2];
  132. e = (e << 30) | (e >> 2);
  133. b += ((c << 5) | (c >> 27)) + (((e ^ a) & d) ^ a) + 0x5A827999 + buff[3];
  134. d = (d << 30) | (d >> 2);
  135. a += ((b << 5) | (b >> 27)) + (((d ^ e) & c) ^ e) + 0x5A827999 + buff[4];
  136. c = (c << 30) | (c >> 2);
  137. e += ((a << 5) | (a >> 27)) + (((c ^ d) & b) ^ d) + 0x5A827999 + buff[5];
  138. b = (b << 30) | (b >> 2);
  139. d += ((e << 5) | (e >> 27)) + (((b ^ c) & a) ^ c) + 0x5A827999 + buff[6];
  140. a = (a << 30) | (a >> 2);
  141. c += ((d << 5) | (d >> 27)) + (((a ^ b) & e) ^ b) + 0x5A827999 + buff[7];
  142. e = (e << 30) | (e >> 2);
  143. b += ((c << 5) | (c >> 27)) + (((e ^ a) & d) ^ a) + 0x5A827999 + buff[8];
  144. d = (d << 30) | (d >> 2);
  145. a += ((b << 5) | (b >> 27)) + (((d ^ e) & c) ^ e) + 0x5A827999 + buff[9];
  146. c = (c << 30) | (c >> 2);
  147. e += ((a << 5) | (a >> 27)) + (((c ^ d) & b) ^ d) + 0x5A827999 + buff[10];
  148. b = (b << 30) | (b >> 2);
  149. d += ((e << 5) | (e >> 27)) + (((b ^ c) & a) ^ c) + 0x5A827999 + buff[11];
  150. a = (a << 30) | (a >> 2);
  151. c += ((d << 5) | (d >> 27)) + (((a ^ b) & e) ^ b) + 0x5A827999 + buff[12];
  152. e = (e << 30) | (e >> 2);
  153. b += ((c << 5) | (c >> 27)) + (((e ^ a) & d) ^ a) + 0x5A827999 + buff[13];
  154. d = (d << 30) | (d >> 2);
  155. a += ((b << 5) | (b >> 27)) + (((d ^ e) & c) ^ e) + 0x5A827999 + buff[14];
  156. c = (c << 30) | (c >> 2);
  157. e += ((a << 5) | (a >> 27)) + (((c ^ d) & b) ^ d) + 0x5A827999 + buff[15];
  158. b = (b << 30) | (b >> 2);
  159. d += ((e << 5) | (e >> 27)) + (((b ^ c) & a) ^ c) + 0x5A827999 + buff[16];
  160. a = (a << 30) | (a >> 2);
  161. c += ((d << 5) | (d >> 27)) + (((a ^ b) & e) ^ b) + 0x5A827999 + buff[17];
  162. e = (e << 30) | (e >> 2);
  163. b += ((c << 5) | (c >> 27)) + (((e ^ a) & d) ^ a) + 0x5A827999 + buff[18];
  164. d = (d << 30) | (d >> 2);
  165. a += ((b << 5) | (b >> 27)) + (((d ^ e) & c) ^ e) + 0x5A827999 + buff[19];
  166. c = (c << 30) | (c >> 2);
  167. // ---- Round 2 --------
  168. e += ((a << 5) | (a >> 27)) + (b ^ c ^ d) + 0x6ED9EBA1 + buff[20];
  169. b = (b << 30) | (b >> 2);
  170. d += ((e << 5) | (e >> 27)) + (a ^ b ^ c) + 0x6ED9EBA1 + buff[21];
  171. a = (a << 30) | (a >> 2);
  172. c += ((d << 5) | (d >> 27)) + (e ^ a ^ b) + 0x6ED9EBA1 + buff[22];
  173. e = (e << 30) | (e >> 2);
  174. b += ((c << 5) | (c >> 27)) + (d ^ e ^ a) + 0x6ED9EBA1 + buff[23];
  175. d = (d << 30) | (d >> 2);
  176. a += ((b << 5) | (b >> 27)) + (c ^ d ^ e) + 0x6ED9EBA1 + buff[24];
  177. c = (c << 30) | (c >> 2);
  178. e += ((a << 5) | (a >> 27)) + (b ^ c ^ d) + 0x6ED9EBA1 + buff[25];
  179. b = (b << 30) | (b >> 2);
  180. d += ((e << 5) | (e >> 27)) + (a ^ b ^ c) + 0x6ED9EBA1 + buff[26];
  181. a = (a << 30) | (a >> 2);
  182. c += ((d << 5) | (d >> 27)) + (e ^ a ^ b) + 0x6ED9EBA1 + buff[27];
  183. e = (e << 30) | (e >> 2);
  184. b += ((c << 5) | (c >> 27)) + (d ^ e ^ a) + 0x6ED9EBA1 + buff[28];
  185. d = (d << 30) | (d >> 2);
  186. a += ((b << 5) | (b >> 27)) + (c ^ d ^ e) + 0x6ED9EBA1 + buff[29];
  187. c = (c << 30) | (c >> 2);
  188. e += ((a << 5) | (a >> 27)) + (b ^ c ^ d) + 0x6ED9EBA1 + buff[30];
  189. b = (b << 30) | (b >> 2);
  190. d += ((e << 5) | (e >> 27)) + (a ^ b ^ c) + 0x6ED9EBA1 + buff[31];
  191. a = (a << 30) | (a >> 2);
  192. c += ((d << 5) | (d >> 27)) + (e ^ a ^ b) + 0x6ED9EBA1 + buff[32];
  193. e = (e << 30) | (e >> 2);
  194. b += ((c << 5) | (c >> 27)) + (d ^ e ^ a) + 0x6ED9EBA1 + buff[33];
  195. d = (d << 30) | (d >> 2);
  196. a += ((b << 5) | (b >> 27)) + (c ^ d ^ e) + 0x6ED9EBA1 + buff[34];
  197. c = (c << 30) | (c >> 2);
  198. e += ((a << 5) | (a >> 27)) + (b ^ c ^ d) + 0x6ED9EBA1 + buff[35];
  199. b = (b << 30) | (b >> 2);
  200. d += ((e << 5) | (e >> 27)) + (a ^ b ^ c) + 0x6ED9EBA1 + buff[36];
  201. a = (a << 30) | (a >> 2);
  202. c += ((d << 5) | (d >> 27)) + (e ^ a ^ b) + 0x6ED9EBA1 + buff[37];
  203. e = (e << 30) | (e >> 2);
  204. b += ((c << 5) | (c >> 27)) + (d ^ e ^ a) + 0x6ED9EBA1 + buff[38];
  205. d = (d << 30) | (d >> 2);
  206. a += ((b << 5) | (b >> 27)) + (c ^ d ^ e) + 0x6ED9EBA1 + buff[39];
  207. c = (c << 30) | (c >> 2);
  208. // ---- Round 3 --------
  209. e += ((a << 5) | (a >> 27)) + ((b&c) | (b&d) | (c&d)) + 0x8F1BBCDC + buff[40];
  210. b = (b << 30) | (b >> 2);
  211. d += ((e << 5) | (e >> 27)) + ((a&b) | (a&c) | (b&c)) + 0x8F1BBCDC + buff[41];
  212. a = (a << 30) | (a >> 2);
  213. c += ((d << 5) | (d >> 27)) + ((e&a) | (e&b) | (a&b)) + 0x8F1BBCDC + buff[42];
  214. e = (e << 30) | (e >> 2);
  215. b += ((c << 5) | (c >> 27)) + ((d&e) | (d&a) | (e&a)) + 0x8F1BBCDC + buff[43];
  216. d = (d << 30) | (d >> 2);
  217. a += ((b << 5) | (b >> 27)) + ((c&d) | (c&e) | (d&e)) + 0x8F1BBCDC + buff[44];
  218. c = (c << 30) | (c >> 2);
  219. e += ((a << 5) | (a >> 27)) + ((b&c) | (b&d) | (c&d)) + 0x8F1BBCDC + buff[45];
  220. b = (b << 30) | (b >> 2);
  221. d += ((e << 5) | (e >> 27)) + ((a&b) | (a&c) | (b&c)) + 0x8F1BBCDC + buff[46];
  222. a = (a << 30) | (a >> 2);
  223. c += ((d << 5) | (d >> 27)) + ((e&a) | (e&b) | (a&b)) + 0x8F1BBCDC + buff[47];
  224. e = (e << 30) | (e >> 2);
  225. b += ((c << 5) | (c >> 27)) + ((d&e) | (d&a) | (e&a)) + 0x8F1BBCDC + buff[48];
  226. d = (d << 30) | (d >> 2);
  227. a += ((b << 5) | (b >> 27)) + ((c&d) | (c&e) | (d&e)) + 0x8F1BBCDC + buff[49];
  228. c = (c << 30) | (c >> 2);
  229. e += ((a << 5) | (a >> 27)) + ((b&c) | (b&d) | (c&d)) + 0x8F1BBCDC + buff[50];
  230. b = (b << 30) | (b >> 2);
  231. d += ((e << 5) | (e >> 27)) + ((a&b) | (a&c) | (b&c)) + 0x8F1BBCDC + buff[51];
  232. a = (a << 30) | (a >> 2);
  233. c += ((d << 5) | (d >> 27)) + ((e&a) | (e&b) | (a&b)) + 0x8F1BBCDC + buff[52];
  234. e = (e << 30) | (e >> 2);
  235. b += ((c << 5) | (c >> 27)) + ((d&e) | (d&a) | (e&a)) + 0x8F1BBCDC + buff[53];
  236. d = (d << 30) | (d >> 2);
  237. a += ((b << 5) | (b >> 27)) + ((c&d) | (c&e) | (d&e)) + 0x8F1BBCDC + buff[54];
  238. c = (c << 30) | (c >> 2);
  239. e += ((a << 5) | (a >> 27)) + ((b&c) | (b&d) | (c&d)) + 0x8F1BBCDC + buff[55];
  240. b = (b << 30) | (b >> 2);
  241. d += ((e << 5) | (e >> 27)) + ((a&b) | (a&c) | (b&c)) + 0x8F1BBCDC + buff[56];
  242. a = (a << 30) | (a >> 2);
  243. c += ((d << 5) | (d >> 27)) + ((e&a) | (e&b) | (a&b)) + 0x8F1BBCDC + buff[57];
  244. e = (e << 30) | (e >> 2);
  245. b += ((c << 5) | (c >> 27)) + ((d&e) | (d&a) | (e&a)) + 0x8F1BBCDC + buff[58];
  246. d = (d << 30) | (d >> 2);
  247. a += ((b << 5) | (b >> 27)) + ((c&d) | (c&e) | (d&e)) + 0x8F1BBCDC + buff[59];
  248. c = (c << 30) | (c >> 2);
  249. // ---- Round 4 --------
  250. e += ((a << 5) | (a >> 27)) + (b ^ c ^ d) + 0xCA62C1D6 + buff[60];
  251. b = (b << 30) | (b >> 2);
  252. d += ((e << 5) | (e >> 27)) + (a ^ b ^ c) + 0xCA62C1D6 + buff[61];
  253. a = (a << 30) | (a >> 2);
  254. c += ((d << 5) | (d >> 27)) + (e ^ a ^ b) + 0xCA62C1D6 + buff[62];
  255. e = (e << 30) | (e >> 2);
  256. b += ((c << 5) | (c >> 27)) + (d ^ e ^ a) + 0xCA62C1D6 + buff[63];
  257. d = (d << 30) | (d >> 2);
  258. a += ((b << 5) | (b >> 27)) + (c ^ d ^ e) + 0xCA62C1D6 + buff[64];
  259. c = (c << 30) | (c >> 2);
  260. e += ((a << 5) | (a >> 27)) + (b ^ c ^ d) + 0xCA62C1D6 + buff[65];
  261. b = (b << 30) | (b >> 2);
  262. d += ((e << 5) | (e >> 27)) + (a ^ b ^ c) + 0xCA62C1D6 + buff[66];
  263. a = (a << 30) | (a >> 2);
  264. c += ((d << 5) | (d >> 27)) + (e ^ a ^ b) + 0xCA62C1D6 + buff[67];
  265. e = (e << 30) | (e >> 2);
  266. b += ((c << 5) | (c >> 27)) + (d ^ e ^ a) + 0xCA62C1D6 + buff[68];
  267. d = (d << 30) | (d >> 2);
  268. a += ((b << 5) | (b >> 27)) + (c ^ d ^ e) + 0xCA62C1D6 + buff[69];
  269. c = (c << 30) | (c >> 2);
  270. e += ((a << 5) | (a >> 27)) + (b ^ c ^ d) + 0xCA62C1D6 + buff[70];
  271. b = (b << 30) | (b >> 2);
  272. d += ((e << 5) | (e >> 27)) + (a ^ b ^ c) + 0xCA62C1D6 + buff[71];
  273. a = (a << 30) | (a >> 2);
  274. c += ((d << 5) | (d >> 27)) + (e ^ a ^ b) + 0xCA62C1D6 + buff[72];
  275. e = (e << 30) | (e >> 2);
  276. b += ((c << 5) | (c >> 27)) + (d ^ e ^ a) + 0xCA62C1D6 + buff[73];
  277. d = (d << 30) | (d >> 2);
  278. a += ((b << 5) | (b >> 27)) + (c ^ d ^ e) + 0xCA62C1D6 + buff[74];
  279. c = (c << 30) | (c >> 2);
  280. e += ((a << 5) | (a >> 27)) + (b ^ c ^ d) + 0xCA62C1D6 + buff[75];
  281. b = (b << 30) | (b >> 2);
  282. d += ((e << 5) | (e >> 27)) + (a ^ b ^ c) + 0xCA62C1D6 + buff[76];
  283. a = (a << 30) | (a >> 2);
  284. c += ((d << 5) | (d >> 27)) + (e ^ a ^ b) + 0xCA62C1D6 + buff[77];
  285. e = (e << 30) | (e >> 2);
  286. b += ((c << 5) | (c >> 27)) + (d ^ e ^ a) + 0xCA62C1D6 + buff[78];
  287. d = (d << 30) | (d >> 2);
  288. a += ((b << 5) | (b >> 27)) + (c ^ d ^ e) + 0xCA62C1D6 + buff[79];
  289. c = (c << 30) | (c >> 2);
  290. _H[0] += a;
  291. _H[1] += b;
  292. _H[2] += c;
  293. _H[3] += d;
  294. _H[4] += e;
  295. }
  296. /// <summary>
  297. /// Pads and then processes the final block.
  298. /// Non-standard.
  299. /// </summary>
  300. /// <param name="inputBuffer">Buffer to grab data from.</param>
  301. /// <param name="inputOffset">Position in buffer in bytes to get data from.</param>
  302. /// <param name="inputCount">How much data in bytes in the buffer to use.</param>
  303. public void ProcessFinalBlock(byte[] inputBuffer, int inputOffset, int inputCount)
  304. {
  305. byte[] fooBuffer;
  306. int paddingSize;
  307. int i;
  308. uint size;
  309. paddingSize = (int)(56 - (inputCount + count) % BLOCK_SIZE_BYTES);
  310. if (paddingSize < 1)
  311. paddingSize += BLOCK_SIZE_BYTES;
  312. fooBuffer = new byte[inputCount+paddingSize+8];
  313. for (i=0; i<inputCount; i++) {
  314. fooBuffer[i] = inputBuffer[i+inputOffset];
  315. }
  316. fooBuffer[inputCount] = 0x80;
  317. for (i=inputCount+1; i<inputCount+paddingSize; i++) {
  318. fooBuffer[i] = 0x00;
  319. }
  320. size = (uint)(count+inputCount);
  321. size *= 8; // I deal in bytes. They algorythm deals in bits.
  322. fooBuffer[inputCount+paddingSize] = 0x00;
  323. fooBuffer[inputCount+paddingSize+1] = 0x00;
  324. fooBuffer[inputCount+paddingSize+2] = 0x00;
  325. fooBuffer[inputCount+paddingSize+3] = 0x00;
  326. fooBuffer[inputCount+paddingSize+4] = (byte)((size) >> 24);
  327. fooBuffer[inputCount+paddingSize+5] = (byte)((size) >> 16);
  328. fooBuffer[inputCount+paddingSize+6] = (byte)((size) >> 8);
  329. fooBuffer[inputCount+paddingSize+7] = (byte)((size) >> 0);
  330. ProcessBlock(fooBuffer, 0);
  331. if (inputCount+paddingSize+8 == 128) {
  332. ProcessBlock(fooBuffer, 64);
  333. }
  334. }
  335. }
  336. public sealed class SHA1CryptoServiceProvider : SHA1 {
  337. private SHA1Internal sha;
  338. public SHA1CryptoServiceProvider ()
  339. {
  340. sha = new SHA1Internal ();
  341. }
  342. ~SHA1CryptoServiceProvider ()
  343. {
  344. Dispose (false);
  345. }
  346. protected override void Dispose (bool disposing)
  347. {
  348. // nothing new to do (managed implementation)
  349. base.Dispose (disposing);
  350. }
  351. protected override void HashCore (byte[] rgb, int start, int size)
  352. {
  353. State = 1;
  354. sha.HashCore (rgb, start, size);
  355. }
  356. protected override byte[] HashFinal ()
  357. {
  358. State = 0;
  359. return sha.HashFinal ();
  360. }
  361. public override void Initialize ()
  362. {
  363. sha.Initialize ();
  364. }
  365. private void ProcessBlock (byte[] inputBuffer, int inputOffset)
  366. {
  367. sha.ProcessBlock (inputBuffer, inputOffset);
  368. }
  369. private void ProcessFinalBlock (byte[] inputBuffer, int inputOffset, int inputCount)
  370. {
  371. sha.ProcessFinalBlock (inputBuffer, inputOffset, inputCount);
  372. }
  373. }
  374. }