raw
eucrypt_ch14_crc32      1 ------------------------------------------------------------------------------
eucrypt_ch14_crc32 2 ------------------------------------------------------------------------------
eucrypt_ch14_crc32 3 -- This file is part of 'CRC32' --
eucrypt_ch14_crc32 4 -- --
eucrypt_ch14_crc32 5 -- You do not have, nor can you ever acquire the right to use, copy or --
eucrypt_ch14_crc32 6 -- distribute this software ; Should you use this software for any purpose, --
eucrypt_ch14_crc32 7 -- or copy and distribute it to anyone or in any manner, you are breaking --
eucrypt_ch14_crc32 8 -- the laws of whatever soi-disant jurisdiction, and you promise to --
eucrypt_ch14_crc32 9 -- continue doing so for the indefinite future. In any case, please --
eucrypt_ch14_crc32 10 -- always : read and understand any software ; verify any PGP signatures --
eucrypt_ch14_crc32 11 -- that you use - for any purpose. --
eucrypt_ch14_crc32 12 -- --
eucrypt_ch14_crc32 13 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
eucrypt_ch14_crc32 14 ------------------------------------------------------------------------------
eucrypt_ch14_crc32 15 ------------------------------------------------------------------------------
eucrypt_ch14_crc32 16
eucrypt_ch14_crc32 17 -- CRC32 implementation
eucrypt_ch14_crc32 18 -- S.MG, 2018
eucrypt_ch14_crc32 19
eucrypt_ch14_crc32 20 package body CRC32 is
eucrypt_ch14_crc32 21 function CRC( S: in String ) return CRC32 is
eucrypt_ch14_crc32 22 Result : CRC32 := Init_Value;
eucrypt_ch14_crc32 23 Value : CRC32;
eucrypt_ch14_crc32 24 begin
eucrypt_ch14_crc32 25 -- process input character by character
eucrypt_ch14_crc32 26 for C of S loop
eucrypt_ch14_crc32 27 Value := CRC32( Character'Pos( C ) );
eucrypt_ch14_crc32 28 Result := Shift_Right(Result, 8) xor
eucrypt_ch14_crc32 29 Lookup( Value xor (Result and LSB_MASK));
eucrypt_ch14_crc32 30 end loop;
eucrypt_ch14_crc32 31 -- reflect result
eucrypt_ch14_crc32 32 Result := Result xor Xor_Out;
eucrypt_ch14_crc32 33
eucrypt_ch14_crc32 34 return Result;
eucrypt_ch14_crc32 35 end CRC;
eucrypt_ch14_crc32 36
eucrypt_ch14_crc32 37 function CRC( Data: in Octet_Array ) return CRC32 is
eucrypt_ch14_crc32 38 Result : CRC32 := Init_Value;
eucrypt_ch14_crc32 39 begin
eucrypt_ch14_crc32 40 -- process input octet by octet
eucrypt_ch14_crc32 41 for C of Data loop
eucrypt_ch14_crc32 42 Result := Shift_Right(Result, 8) xor
eucrypt_ch14_crc32 43 Lookup( CRC32(C) xor (Result and LSB_MASK));
eucrypt_ch14_crc32 44 end loop;
eucrypt_ch14_crc32 45 -- reflect result
eucrypt_ch14_crc32 46 Result := Result xor Xor_Out;
eucrypt_ch14_crc32 47
eucrypt_ch14_crc32 48 return Result;
eucrypt_ch14_crc32 49 end CRC;
eucrypt_ch14_crc32 50
eucrypt_ch14_crc32 51 end CRC32;
eucrypt_ch14_crc32 52