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