Hello, I got "Fatal: Internal error 200305103" while try to compile the attached file on my raspi.
The file is a class helper. I wonder if that is supported on FPC 2.6.0 or not? And whether this problem has anything to do with ARM?
unit cipher; {$mode objfpc}{$H+} interface uses sysutils, BlowFish; type TBlowFish = BlowFish.TBlowFish; TBlowFishModes = class helper for TBlowFish private procedure CryptCTR(IV: QWord; buf: Pointer; len: Integer); inline; public constructor Create(key: Pointer; KeySize: Integer); procedure EncryptCTR(IV: QWord; buf: Pointer; len: Integer); procedure DecryptCTR(IV: QWord; buf: Pointer; len: Integer); procedure EncryptCBC(IV: QWord; buf: Pointer; len: Integer); procedure DecryptCBC(IV: QWord; buf: Pointer; len: Integer); end; implementation constructor TBlowFishModes.Create(key: Pointer; KeySize: Integer); begin inherited Create(PBlowFishKey(key)^, KeySize); end; procedure TBlowFishModes.EncryptCTR(IV: QWord; buf: Pointer; len: Integer); begin CryptCTR(IV, Buf, len); end; procedure TBlowFishModes.DecryptCTR(IV: QWord; buf: Pointer; len: Integer); begin CryptCTR(IV, Buf, len); end; procedure TBlowFishModes.CryptCTR(IV: QWord; buf: Pointer; len: Integer); var i, cnt, res: Integer; ipt: QWord; iptb: array[0..7] of Byte absolute ipt; ptb: PQWord; ptr: PByte; begin cnt := len div 8; res := len mod 8; for i := 0 to cnt - 1 do begin ipt := IV xor i; Encrypt(TBFBlock(ipt)); ptb := PQWord(buf + i * 8); ptb^ := ptb^ xor ipt; end; if res > 0 then begin //process last block less than 8 byte ipt := IV xor cnt; for i := 0 to res - 1 do begin ptr := PByte(buf + cnt * 8 + i); ptr^ := ptr^ xor iptb[i]; end; end; end; procedure TBlowFishModes.EncryptCBC(IV: QWord; buf: Pointer; len: Integer); var i, cnt, res: Integer; ptb: PQWord; last, prelast: QWord; begin if len <= 8 then begin CryptCTR(IV, buf, len); Exit; end; cnt := len div 8; res := len mod 8; if res = 0 then begin prelast := PQWord(buf+(cnt-2)*8)^; last := PQWord(buf+(cnt-1)*8)^; res := 8; Dec(cnt, 2); end else begin prelast := PQWord(buf+(cnt-1)*8)^; last := PQWord(buf+cnt*8)^; Dec(cnt); end; for i := 0 to cnt - 1 do begin ptb := PQWord(buf + i * 8); ptb^ := ptb^ xor IV; Encrypt(TBFBlock(ptb^)); IV := ptb^; end; prelast := prelast xor IV; Encrypt(TBFBlock(prelast)); Move(prelast, PByte(buf+(cnt+1)*8)^, res); last := last xor prelast; Encrypt(TBFBlock(last)); PQWord(buf+cnt*8)^ := last; end; procedure TBlowFishModes.DecryptCBC(IV: QWord; buf: Pointer; len: Integer); type QWB = array[0..7] of Byte; var i, cnt, res: Integer; ptb: PQWord; ctx: QWord; last, prelast: QWord; begin if len <= 8 then begin CryptCTR(IV, buf, len); Exit; end; cnt := len div 8; res := len mod 8; if res = 0 then begin prelast := PQWord(buf+(cnt-2)*8)^; last := PQWord(buf+(cnt-1)*8)^; Dec(cnt, 2); end else begin prelast := PQWord(buf+(cnt-1)*8)^; last := PQWord(buf+cnt*8)^; Dec(cnt); end; for i := 0 to cnt - 1 do begin ptb := PQWord(buf + i * 8); ctx := ptb^; Decrypt(TBFBlock(ptb^)); ptb^ := ptb^ xor IV; IV := ctx; end; Decrypt(TBFBlock(prelast)); if res > 0 then begin for i := res to 7 do QWB(last)[i] := QWB(prelast)[i]; end else res := 8; prelast := prelast xor last; Move(prelast, PByte(buf+(cnt+1)*8)^, res); Decrypt(TBFBlock(last)); PQWord(buf+cnt*8)^ := last xor IV; end; end.
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal