]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseLib/CheckSum.c
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Library / BaseLib / CheckSum.c
CommitLineData
e1f414b6 1/** @file\r
2 Utility functions to generate checksum based on 2's complement\r
3 algorithm.\r
4\r
9095d37b 5 Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
9344f092 6 SPDX-License-Identifier: BSD-2-Clause-Patent\r
e1f414b6 7\r
e1f414b6 8**/\r
9\r
47fc17d8 10#include "BaseLibInternals.h"\r
f734a10a 11\r
e1f414b6 12/**\r
9aa049d9 13 Returns the sum of all elements in a buffer in unit of UINT8.\r
e1f414b6 14 During calculation, the carry bits are dropped.\r
15\r
9aa049d9 16 This function calculates the sum of all elements in a buffer\r
17 in unit of UINT8. The carry bits in result of addition are dropped.\r
18 The result is returned as UINT8. If Length is Zero, then Zero is\r
e1f414b6 19 returned.\r
9aa049d9 20\r
e1f414b6 21 If Buffer is NULL, then ASSERT().\r
9aa049d9 22 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
e1f414b6 23\r
127010dd 24 @param Buffer The pointer to the buffer to carry out the sum operation.\r
9aa049d9 25 @param Length The size, in bytes, of Buffer.\r
e1f414b6 26\r
9aa049d9 27 @return Sum The sum of Buffer with carry bits dropped during additions.\r
e1f414b6 28\r
29**/\r
30UINT8\r
31EFIAPI\r
32CalculateSum8 (\r
2fc60b70 33 IN CONST UINT8 *Buffer,\r
34 IN UINTN Length\r
e1f414b6 35 )\r
36{\r
37 UINT8 Sum;\r
38 UINTN Count;\r
39\r
40 ASSERT (Buffer != NULL);\r
41 ASSERT (Length <= (MAX_ADDRESS - ((UINTN) Buffer) + 1));\r
42\r
43 for (Sum = 0, Count = 0; Count < Length; Count++) {\r
44 Sum = (UINT8) (Sum + *(Buffer + Count));\r
45 }\r
9095d37b 46\r
e1f414b6 47 return Sum;\r
48}\r
49\r
50\r
51/**\r
9aa049d9 52 Returns the two's complement checksum of all elements in a buffer\r
e1f414b6 53 of 8-bit values.\r
54\r
9aa049d9 55 This function first calculates the sum of the 8-bit values in the\r
56 buffer specified by Buffer and Length. The carry bits in the result\r
57 of addition are dropped. Then, the two's complement of the sum is\r
e1f414b6 58 returned. If Length is 0, then 0 is returned.\r
9aa049d9 59\r
e1f414b6 60 If Buffer is NULL, then ASSERT().\r
61 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
62\r
127010dd 63 @param Buffer The pointer to the buffer to carry out the checksum operation.\r
1106ffe1 64 @param Length The size, in bytes, of Buffer.\r
e1f414b6 65\r
9aa049d9 66 @return Checksum The 2's complement checksum of Buffer.\r
e1f414b6 67\r
68**/\r
69UINT8\r
70EFIAPI\r
71CalculateCheckSum8 (\r
2fc60b70 72 IN CONST UINT8 *Buffer,\r
73 IN UINTN Length\r
e1f414b6 74 )\r
75{\r
76 UINT8 CheckSum;\r
77\r
78 CheckSum = CalculateSum8 (Buffer, Length);\r
79\r
80 //\r
81 // Return the checksum based on 2's complement.\r
82 //\r
83 return (UINT8) (0x100 - CheckSum);\r
84}\r
85\r
86/**\r
9aa049d9 87 Returns the sum of all elements in a buffer of 16-bit values. During\r
e1f414b6 88 calculation, the carry bits are dropped.\r
89\r
9aa049d9 90 This function calculates the sum of the 16-bit values in the buffer\r
91 specified by Buffer and Length. The carry bits in result of addition are dropped.\r
92 The 16-bit result is returned. If Length is 0, then 0 is returned.\r
93\r
e1f414b6 94 If Buffer is NULL, then ASSERT().\r
95 If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r
96 If Length is not aligned on a 16-bit boundary, then ASSERT().\r
97 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
98\r
127010dd 99 @param Buffer The pointer to the buffer to carry out the sum operation.\r
1106ffe1 100 @param Length The size, in bytes, of Buffer.\r
e1f414b6 101\r
9aa049d9 102 @return Sum The sum of Buffer with carry bits dropped during additions.\r
e1f414b6 103\r
104**/\r
105UINT16\r
106EFIAPI\r
107CalculateSum16 (\r
2fc60b70 108 IN CONST UINT16 *Buffer,\r
109 IN UINTN Length\r
e1f414b6 110 )\r
111{\r
112 UINT16 Sum;\r
113 UINTN Count;\r
f9cea76b 114 UINTN Total;\r
e1f414b6 115\r
116 ASSERT (Buffer != NULL);\r
117 ASSERT (((UINTN) Buffer & 0x1) == 0);\r
118 ASSERT ((Length & 0x1) == 0);\r
119 ASSERT (Length <= (MAX_ADDRESS - ((UINTN) Buffer) + 1));\r
120\r
f9cea76b 121 Total = Length / sizeof (*Buffer);\r
122 for (Sum = 0, Count = 0; Count < Total; Count++) {\r
e1f414b6 123 Sum = (UINT16) (Sum + *(Buffer + Count));\r
124 }\r
9095d37b 125\r
e1f414b6 126 return Sum;\r
127}\r
128\r
129\r
130/**\r
9aa049d9 131 Returns the two's complement checksum of all elements in a buffer of\r
e1f414b6 132 16-bit values.\r
133\r
9aa049d9 134 This function first calculates the sum of the 16-bit values in the buffer\r
135 specified by Buffer and Length. The carry bits in the result of addition\r
136 are dropped. Then, the two's complement of the sum is returned. If Length\r
e1f414b6 137 is 0, then 0 is returned.\r
9aa049d9 138\r
e1f414b6 139 If Buffer is NULL, then ASSERT().\r
140 If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r
141 If Length is not aligned on a 16-bit boundary, then ASSERT().\r
9aa049d9 142 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
e1f414b6 143\r
127010dd 144 @param Buffer The pointer to the buffer to carry out the checksum operation.\r
1106ffe1 145 @param Length The size, in bytes, of Buffer.\r
e1f414b6 146\r
9aa049d9 147 @return Checksum The 2's complement checksum of Buffer.\r
e1f414b6 148\r
149**/\r
150UINT16\r
151EFIAPI\r
152CalculateCheckSum16 (\r
2fc60b70 153 IN CONST UINT16 *Buffer,\r
154 IN UINTN Length\r
e1f414b6 155 )\r
156{\r
157 UINT16 CheckSum;\r
158\r
159 CheckSum = CalculateSum16 (Buffer, Length);\r
160\r
161 //\r
162 // Return the checksum based on 2's complement.\r
163 //\r
164 return (UINT16) (0x10000 - CheckSum);\r
165}\r
166\r
167\r
168/**\r
9aa049d9 169 Returns the sum of all elements in a buffer of 32-bit values. During\r
e1f414b6 170 calculation, the carry bits are dropped.\r
171\r
9aa049d9 172 This function calculates the sum of the 32-bit values in the buffer\r
173 specified by Buffer and Length. The carry bits in result of addition are dropped.\r
174 The 32-bit result is returned. If Length is 0, then 0 is returned.\r
175\r
e1f414b6 176 If Buffer is NULL, then ASSERT().\r
177 If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r
178 If Length is not aligned on a 32-bit boundary, then ASSERT().\r
179 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
180\r
127010dd 181 @param Buffer The pointer to the buffer to carry out the sum operation.\r
1106ffe1 182 @param Length The size, in bytes, of Buffer.\r
e1f414b6 183\r
9aa049d9 184 @return Sum The sum of Buffer with carry bits dropped during additions.\r
e1f414b6 185\r
186**/\r
187UINT32\r
188EFIAPI\r
189CalculateSum32 (\r
2fc60b70 190 IN CONST UINT32 *Buffer,\r
191 IN UINTN Length\r
e1f414b6 192 )\r
193{\r
194 UINT32 Sum;\r
195 UINTN Count;\r
f9cea76b 196 UINTN Total;\r
e1f414b6 197\r
198 ASSERT (Buffer != NULL);\r
199 ASSERT (((UINTN) Buffer & 0x3) == 0);\r
200 ASSERT ((Length & 0x3) == 0);\r
201 ASSERT (Length <= (MAX_ADDRESS - ((UINTN) Buffer) + 1));\r
202\r
f9cea76b 203 Total = Length / sizeof (*Buffer);\r
204 for (Sum = 0, Count = 0; Count < Total; Count++) {\r
e1f414b6 205 Sum = Sum + *(Buffer + Count);\r
206 }\r
9095d37b 207\r
e1f414b6 208 return Sum;\r
209}\r
210\r
211\r
212/**\r
9aa049d9 213 Returns the two's complement checksum of all elements in a buffer of\r
e1f414b6 214 32-bit values.\r
215\r
9aa049d9 216 This function first calculates the sum of the 32-bit values in the buffer\r
217 specified by Buffer and Length. The carry bits in the result of addition\r
218 are dropped. Then, the two's complement of the sum is returned. If Length\r
e1f414b6 219 is 0, then 0 is returned.\r
9aa049d9 220\r
e1f414b6 221 If Buffer is NULL, then ASSERT().\r
222 If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r
223 If Length is not aligned on a 32-bit boundary, then ASSERT().\r
9aa049d9 224 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
e1f414b6 225\r
127010dd 226 @param Buffer The pointer to the buffer to carry out the checksum operation.\r
1106ffe1 227 @param Length The size, in bytes, of Buffer.\r
e1f414b6 228\r
9aa049d9 229 @return Checksum The 2's complement checksum of Buffer.\r
e1f414b6 230\r
231**/\r
232UINT32\r
233EFIAPI\r
234CalculateCheckSum32 (\r
2fc60b70 235 IN CONST UINT32 *Buffer,\r
236 IN UINTN Length\r
e1f414b6 237 )\r
238{\r
239 UINT32 CheckSum;\r
240\r
241 CheckSum = CalculateSum32 (Buffer, Length);\r
242\r
243 //\r
244 // Return the checksum based on 2's complement.\r
245 //\r
246 return (UINT32) ((UINT32)(-1) - CheckSum + 1);\r
247}\r
248\r
249\r
250/**\r
9aa049d9 251 Returns the sum of all elements in a buffer of 64-bit values. During\r
e1f414b6 252 calculation, the carry bits are dropped.\r
253\r
9aa049d9 254 This function calculates the sum of the 64-bit values in the buffer\r
255 specified by Buffer and Length. The carry bits in result of addition are dropped.\r
256 The 64-bit result is returned. If Length is 0, then 0 is returned.\r
257\r
e1f414b6 258 If Buffer is NULL, then ASSERT().\r
259 If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r
260 If Length is not aligned on a 64-bit boundary, then ASSERT().\r
261 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
262\r
127010dd 263 @param Buffer The pointer to the buffer to carry out the sum operation.\r
1106ffe1 264 @param Length The size, in bytes, of Buffer.\r
e1f414b6 265\r
9aa049d9 266 @return Sum The sum of Buffer with carry bits dropped during additions.\r
e1f414b6 267\r
268**/\r
269UINT64\r
270EFIAPI\r
271CalculateSum64 (\r
2fc60b70 272 IN CONST UINT64 *Buffer,\r
273 IN UINTN Length\r
e1f414b6 274 )\r
275{\r
276 UINT64 Sum;\r
277 UINTN Count;\r
f9cea76b 278 UINTN Total;\r
e1f414b6 279\r
280 ASSERT (Buffer != NULL);\r
281 ASSERT (((UINTN) Buffer & 0x7) == 0);\r
282 ASSERT ((Length & 0x7) == 0);\r
283 ASSERT (Length <= (MAX_ADDRESS - ((UINTN) Buffer) + 1));\r
284\r
f9cea76b 285 Total = Length / sizeof (*Buffer);\r
286 for (Sum = 0, Count = 0; Count < Total; Count++) {\r
e1f414b6 287 Sum = Sum + *(Buffer + Count);\r
288 }\r
9095d37b 289\r
e1f414b6 290 return Sum;\r
291}\r
292\r
293\r
294/**\r
9aa049d9 295 Returns the two's complement checksum of all elements in a buffer of\r
e1f414b6 296 64-bit values.\r
297\r
9aa049d9 298 This function first calculates the sum of the 64-bit values in the buffer\r
299 specified by Buffer and Length. The carry bits in the result of addition\r
300 are dropped. Then, the two's complement of the sum is returned. If Length\r
e1f414b6 301 is 0, then 0 is returned.\r
9aa049d9 302\r
e1f414b6 303 If Buffer is NULL, then ASSERT().\r
304 If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r
305 If Length is not aligned on a 64-bit boundary, then ASSERT().\r
9aa049d9 306 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
e1f414b6 307\r
127010dd 308 @param Buffer The pointer to the buffer to carry out the checksum operation.\r
1106ffe1 309 @param Length The size, in bytes, of Buffer.\r
e1f414b6 310\r
9aa049d9 311 @return Checksum The 2's complement checksum of Buffer.\r
e1f414b6 312\r
313**/\r
314UINT64\r
315EFIAPI\r
316CalculateCheckSum64 (\r
2fc60b70 317 IN CONST UINT64 *Buffer,\r
318 IN UINTN Length\r
e1f414b6 319 )\r
320{\r
321 UINT64 CheckSum;\r
322\r
323 CheckSum = CalculateSum64 (Buffer, Length);\r
324\r
325 //\r
326 // Return the checksum based on 2's complement.\r
327 //\r
328 return (UINT64) ((UINT64)(-1) - CheckSum + 1);\r
329}\r
330\r
0a8e6f79
LG
331GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT32 mCrcTable[256] = {\r
332 0x00000000,\r
333 0x77073096,\r
334 0xEE0E612C,\r
335 0x990951BA,\r
336 0x076DC419,\r
337 0x706AF48F,\r
338 0xE963A535,\r
339 0x9E6495A3,\r
340 0x0EDB8832,\r
341 0x79DCB8A4,\r
342 0xE0D5E91E,\r
343 0x97D2D988,\r
344 0x09B64C2B,\r
345 0x7EB17CBD,\r
346 0xE7B82D07,\r
347 0x90BF1D91,\r
348 0x1DB71064,\r
349 0x6AB020F2,\r
350 0xF3B97148,\r
351 0x84BE41DE,\r
352 0x1ADAD47D,\r
353 0x6DDDE4EB,\r
354 0xF4D4B551,\r
355 0x83D385C7,\r
356 0x136C9856,\r
357 0x646BA8C0,\r
358 0xFD62F97A,\r
359 0x8A65C9EC,\r
360 0x14015C4F,\r
361 0x63066CD9,\r
362 0xFA0F3D63,\r
363 0x8D080DF5,\r
364 0x3B6E20C8,\r
365 0x4C69105E,\r
366 0xD56041E4,\r
367 0xA2677172,\r
368 0x3C03E4D1,\r
369 0x4B04D447,\r
370 0xD20D85FD,\r
371 0xA50AB56B,\r
372 0x35B5A8FA,\r
373 0x42B2986C,\r
374 0xDBBBC9D6,\r
375 0xACBCF940,\r
376 0x32D86CE3,\r
377 0x45DF5C75,\r
378 0xDCD60DCF,\r
379 0xABD13D59,\r
380 0x26D930AC,\r
381 0x51DE003A,\r
382 0xC8D75180,\r
383 0xBFD06116,\r
384 0x21B4F4B5,\r
385 0x56B3C423,\r
386 0xCFBA9599,\r
387 0xB8BDA50F,\r
388 0x2802B89E,\r
389 0x5F058808,\r
390 0xC60CD9B2,\r
391 0xB10BE924,\r
392 0x2F6F7C87,\r
393 0x58684C11,\r
394 0xC1611DAB,\r
395 0xB6662D3D,\r
396 0x76DC4190,\r
397 0x01DB7106,\r
398 0x98D220BC,\r
399 0xEFD5102A,\r
400 0x71B18589,\r
401 0x06B6B51F,\r
402 0x9FBFE4A5,\r
403 0xE8B8D433,\r
404 0x7807C9A2,\r
405 0x0F00F934,\r
406 0x9609A88E,\r
407 0xE10E9818,\r
408 0x7F6A0DBB,\r
409 0x086D3D2D,\r
410 0x91646C97,\r
411 0xE6635C01,\r
412 0x6B6B51F4,\r
413 0x1C6C6162,\r
414 0x856530D8,\r
415 0xF262004E,\r
416 0x6C0695ED,\r
417 0x1B01A57B,\r
418 0x8208F4C1,\r
419 0xF50FC457,\r
420 0x65B0D9C6,\r
421 0x12B7E950,\r
422 0x8BBEB8EA,\r
423 0xFCB9887C,\r
424 0x62DD1DDF,\r
425 0x15DA2D49,\r
426 0x8CD37CF3,\r
427 0xFBD44C65,\r
428 0x4DB26158,\r
429 0x3AB551CE,\r
430 0xA3BC0074,\r
431 0xD4BB30E2,\r
432 0x4ADFA541,\r
433 0x3DD895D7,\r
434 0xA4D1C46D,\r
435 0xD3D6F4FB,\r
436 0x4369E96A,\r
437 0x346ED9FC,\r
438 0xAD678846,\r
439 0xDA60B8D0,\r
440 0x44042D73,\r
441 0x33031DE5,\r
442 0xAA0A4C5F,\r
443 0xDD0D7CC9,\r
444 0x5005713C,\r
445 0x270241AA,\r
446 0xBE0B1010,\r
447 0xC90C2086,\r
448 0x5768B525,\r
449 0x206F85B3,\r
450 0xB966D409,\r
451 0xCE61E49F,\r
452 0x5EDEF90E,\r
453 0x29D9C998,\r
454 0xB0D09822,\r
455 0xC7D7A8B4,\r
456 0x59B33D17,\r
457 0x2EB40D81,\r
458 0xB7BD5C3B,\r
459 0xC0BA6CAD,\r
460 0xEDB88320,\r
461 0x9ABFB3B6,\r
462 0x03B6E20C,\r
463 0x74B1D29A,\r
464 0xEAD54739,\r
465 0x9DD277AF,\r
466 0x04DB2615,\r
467 0x73DC1683,\r
468 0xE3630B12,\r
469 0x94643B84,\r
470 0x0D6D6A3E,\r
471 0x7A6A5AA8,\r
472 0xE40ECF0B,\r
473 0x9309FF9D,\r
474 0x0A00AE27,\r
475 0x7D079EB1,\r
476 0xF00F9344,\r
477 0x8708A3D2,\r
478 0x1E01F268,\r
479 0x6906C2FE,\r
480 0xF762575D,\r
481 0x806567CB,\r
482 0x196C3671,\r
483 0x6E6B06E7,\r
484 0xFED41B76,\r
485 0x89D32BE0,\r
486 0x10DA7A5A,\r
487 0x67DD4ACC,\r
488 0xF9B9DF6F,\r
489 0x8EBEEFF9,\r
490 0x17B7BE43,\r
491 0x60B08ED5,\r
492 0xD6D6A3E8,\r
493 0xA1D1937E,\r
494 0x38D8C2C4,\r
495 0x4FDFF252,\r
496 0xD1BB67F1,\r
497 0xA6BC5767,\r
498 0x3FB506DD,\r
499 0x48B2364B,\r
500 0xD80D2BDA,\r
501 0xAF0A1B4C,\r
502 0x36034AF6,\r
503 0x41047A60,\r
504 0xDF60EFC3,\r
505 0xA867DF55,\r
506 0x316E8EEF,\r
507 0x4669BE79,\r
508 0xCB61B38C,\r
509 0xBC66831A,\r
510 0x256FD2A0,\r
511 0x5268E236,\r
512 0xCC0C7795,\r
513 0xBB0B4703,\r
514 0x220216B9,\r
515 0x5505262F,\r
516 0xC5BA3BBE,\r
517 0xB2BD0B28,\r
518 0x2BB45A92,\r
519 0x5CB36A04,\r
520 0xC2D7FFA7,\r
521 0xB5D0CF31,\r
522 0x2CD99E8B,\r
523 0x5BDEAE1D,\r
524 0x9B64C2B0,\r
525 0xEC63F226,\r
526 0x756AA39C,\r
527 0x026D930A,\r
528 0x9C0906A9,\r
529 0xEB0E363F,\r
530 0x72076785,\r
531 0x05005713,\r
532 0x95BF4A82,\r
533 0xE2B87A14,\r
534 0x7BB12BAE,\r
535 0x0CB61B38,\r
536 0x92D28E9B,\r
537 0xE5D5BE0D,\r
538 0x7CDCEFB7,\r
539 0x0BDBDF21,\r
540 0x86D3D2D4,\r
541 0xF1D4E242,\r
542 0x68DDB3F8,\r
543 0x1FDA836E,\r
544 0x81BE16CD,\r
545 0xF6B9265B,\r
546 0x6FB077E1,\r
547 0x18B74777,\r
548 0x88085AE6,\r
549 0xFF0F6A70,\r
550 0x66063BCA,\r
551 0x11010B5C,\r
552 0x8F659EFF,\r
553 0xF862AE69,\r
554 0x616BFFD3,\r
555 0x166CCF45,\r
556 0xA00AE278,\r
557 0xD70DD2EE,\r
558 0x4E048354,\r
559 0x3903B3C2,\r
560 0xA7672661,\r
561 0xD06016F7,\r
562 0x4969474D,\r
563 0x3E6E77DB,\r
564 0xAED16A4A,\r
565 0xD9D65ADC,\r
566 0x40DF0B66,\r
567 0x37D83BF0,\r
568 0xA9BCAE53,\r
569 0xDEBB9EC5,\r
570 0x47B2CF7F,\r
571 0x30B5FFE9,\r
572 0xBDBDF21C,\r
573 0xCABAC28A,\r
574 0x53B39330,\r
575 0x24B4A3A6,\r
576 0xBAD03605,\r
577 0xCDD70693,\r
578 0x54DE5729,\r
579 0x23D967BF,\r
580 0xB3667A2E,\r
581 0xC4614AB8,\r
582 0x5D681B02,\r
583 0x2A6F2B94,\r
584 0xB40BBE37,\r
585 0xC30C8EA1,\r
586 0x5A05DF1B,\r
587 0x2D02EF8D\r
588};\r
e1f414b6 589\r
0a8e6f79
LG
590/**\r
591 Computes and returns a 32-bit CRC for a data buffer.\r
592 CRC32 value bases on ITU-T V.42.\r
593\r
594 If Buffer is NULL, then ASSERT().\r
595 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
596\r
597 @param[in] Buffer A pointer to the buffer on which the 32-bit CRC is to be computed.\r
598 @param[in] Length The number of bytes in the buffer Data.\r
599\r
600 @retval Crc32 The 32-bit CRC was computed for the data buffer.\r
601\r
602**/\r
603UINT32\r
604EFIAPI\r
605CalculateCrc32(\r
606 IN VOID *Buffer,\r
607 IN UINTN Length\r
608 )\r
609{\r
610 UINTN Index;\r
611 UINT32 Crc;\r
612 UINT8 *Ptr;\r
613\r
614 ASSERT (Buffer != NULL);\r
615 ASSERT (Length <= (MAX_ADDRESS - ((UINTN) Buffer) + 1));\r
616\r
617 //\r
618 // Compute CRC\r
619 //\r
620 Crc = 0xffffffff;\r
621 for (Index = 0, Ptr = Buffer; Index < Length; Index++, Ptr++) {\r
622 Crc = (Crc >> 8) ^ mCrcTable[(UINT8) Crc ^ *Ptr];\r
623 }\r
624\r
625 return Crc ^ 0xffffffff;\r
626}\r