You are not logged in.
Hello,
After upgrading to the latest stable version, I found that long enough data encrypted in 1.18 cannot be decrypted in 2.3.8854.
Lazarus 2.0.12; FPC: 3.2.0.
Is it a bug (somewhere in the padding)?
// Data to encrypt: "SOME TEST DATA SOME TEST DATA SOME TEST DATA SOME TEST DATA SOME TEST DATA SOME TEST DATA SOME TEST DATA SOME TEST DATA SOME TEST DATA SOME TEST DATA SOME TEST DATA SOME TEST DATA"
function EncryptAES256CTR(Data: Pointer; DataLength: Int64; const Key: THash256; out EncryptedData: RawByteString): Boolean;
var
AES: TAESCTR;
EncryptedDataSize: Int64;
begin
Result := True;
try
EncryptedData := '';
AES := TAESCTR.Create(Key);
try
EncryptedDataSize := AES.EncryptPKCS7Length(DataLength, True);
SetString(EncryptedData, nil, EncryptedDataSize);
Result := AES.EncryptPKCS7Buffer(Data, @EncryptedData[1], DataLength, EncryptedDataSize, True);
except
Result := False;
end;
AES.Free;
except
Result := False;
end;
end;
// ===
function DecryptAES256CTR(Data: Pointer; DataLength: Int64; const Key: THash256; out DecryptedData: RawByteString): Boolean;
var
AES: TAESCTR;
begin
Result := True;
try
AES := TAESCTR.Create(Key);
try
DecryptedData := AES.DecryptPKCS7Buffer(Data, DataLength, True);
except
Result := False;
end;
AES.Free;
except
Result := False;
end;
end;
Offline
Thank you!
You are right as always.
Offline