/trunk/Decoder5/DecoderEncDec.pas |
---|
2,6 → 2,10 |
interface |
// TODO: DC 5.0 Format: |
// - Hinzufügen DEC C-MAC (optional) |
// - Hinzufügen GCM MAC (optional) |
uses |
Windows, Dialogs, SysUtils, Classes, DECFormatBase, DECTypes, |
System.UITypes, DECCiphers, DECCipherBase, DECHash, DECHashBase, |
67,6 → 71,21 |
'Bytes' |
); |
procedure DeCoder20_EncodeFile(const AFileName, AOutput: String; OnProgressProc: TDECProgressEvent=nil); |
procedure DeCoder20_DecodeFile(const AFileName, AOutput: String; OnProgressProc: TDECProgressEvent=nil); |
procedure DeCoder21_EncodeFile(const AFileName, AOutput: String; Key: integer; OnProgressProc: TDECProgressEvent=nil); |
procedure DeCoder21_DecodeFile(const AFileName, AOutput: String; Key: integer; OnProgressProc: TDECProgressEvent=nil); |
procedure DeCoder22_EncodeFile(const AFileName, AOutput: String; Key: integer; OnProgressProc: TDECProgressEvent=nil); |
procedure DeCoder22_DecodeFile(const AFileName, AOutput: String; Key: integer; OnProgressProc: TDECProgressEvent=nil); |
procedure DeCoder30_EncodeFile(const AFileName, AOutput: String; Key: AnsiString; OnProgressProc: TDECProgressEvent=nil); |
procedure DeCoder30_DecodeFile(const AFileName, AOutput: String; Key: AnsiString; OnProgressProc: TDECProgressEvent=nil); |
procedure DeCoder32_EncodeFile(const AFileName, AOutput: String; Key: AnsiString; OnProgressProc: TDECProgressEvent=nil); |
procedure DeCoder32_DecodeFile(const AFileName, AOutput: String; Key: AnsiString; OnProgressProc: TDECProgressEvent=nil); |
procedure DeCoder4X_EncodeFile_Ver4(const AFileName, AOutput: String; const APassword: RawByteString; OnProgressProc: TDECProgressEvent=nil); |
function DeCoder4X_DecodeFile(const AFileName, AOutput: String; const APassword: RawByteString; const OnlyReadFileInfo: boolean=false; OnProgressProc: TDECProgressEvent=nil): TDC4FileInfo; |
procedure DeCoder4X_PrintFileInfo(fi: TDC4FileInfo; sl: TStrings); |
73,6 → 92,9 |
implementation |
uses |
DecoderOldCiphers; |
type |
// https://github.com/MHumm/DelphiEncryptionCompendium/issues/62 |
TDECHashExtendedAuthentication = class helper for TDECHashAuthentication |
1020,6 → 1042,246 |
sl.Add('Message Authentication: ' + INTEGRITY_CHECK_INFO[fi.Dc4FormatVersion]); |
end; |
procedure DeCoder20_EncodeFile(const AFileName, AOutput: String; OnProgressProc: TDECProgressEvent=nil); |
var |
ssIn: TFileStream; |
ssOut: TFileStream; |
Cipher: TDECCipher; |
begin |
ssIn := TFileStream.Create(AFileName, fmOpenRead); |
try |
ssOut := TFileStream.Create(AOutput, fmCreate); |
try |
Cipher := TCipher_VtsDeCoder20.Create; |
Cipher.Init(AnsiString(''), AnsiString(''), $FF); |
Cipher.Mode := cmECBx; |
TDECFormattedCipher(Cipher).EncodeStream(ssIn, ssOut, ssIn.Size, OnProgressProc); |
Cipher.Done; |
Cipher.Free; |
finally |
ssOut.Free; |
end; |
finally |
ssIn.Free; |
end; |
end; |
procedure DeCoder20_DecodeFile(const AFileName, AOutput: String; OnProgressProc: TDECProgressEvent=nil); |
var |
ssIn: TFileStream; |
ssOut: TFileStream; |
Cipher: TDECCipher; |
begin |
ssIn := TFileStream.Create(AFileName, fmOpenRead); |
try |
ssOut := TFileStream.Create(AOutput, fmCreate); |
try |
Cipher := TCipher_VtsDeCoder20.Create; |
Cipher.Init(AnsiString(''), AnsiString(''), $FF); |
Cipher.Mode := cmECBx; |
TDECFormattedCipher(Cipher).DecodeStream(ssIn, ssOut, ssIn.Size, OnProgressProc); |
Cipher.Done; |
Cipher.Free; |
finally |
ssOut.Free; |
end; |
finally |
ssIn.Free; |
end; |
end; |
procedure DeCoder21_EncodeFile(const AFileName, AOutput: String; Key: integer; OnProgressProc: TDECProgressEvent=nil); |
var |
ssIn: TFileStream; |
ssOut: TFileStream; |
Cipher: TDECCipher; |
begin |
ssIn := TFileStream.Create(AFileName, fmOpenRead); |
try |
ssOut := TFileStream.Create(AOutput, fmCreate); |
try |
Cipher := TCipher_VtsDeCoder21.Create; |
Cipher.Init(AnsiString(IntToStr(Key)), AnsiString(''), $FF); |
Cipher.Mode := cmECBx; |
TDECFormattedCipher(Cipher).EncodeStream(ssIn, ssOut, ssIn.Size, OnProgressProc); |
Cipher.Done; |
Cipher.Free; |
finally |
ssOut.Free; |
end; |
finally |
ssIn.Free; |
end; |
end; |
procedure DeCoder21_DecodeFile(const AFileName, AOutput: String; Key: integer; OnProgressProc: TDECProgressEvent=nil); |
var |
ssIn: TFileStream; |
ssOut: TFileStream; |
Cipher: TDECCipher; |
begin |
ssIn := TFileStream.Create(AFileName, fmOpenRead); |
try |
ssOut := TFileStream.Create(AOutput, fmCreate); |
try |
Cipher := TCipher_VtsDeCoder21.Create; |
Cipher.Init(AnsiString(IntToStr(Key)), AnsiString(''), $FF); |
Cipher.Mode := cmECBx; |
TDECFormattedCipher(Cipher).DecodeStream(ssIn, ssOut, ssIn.Size, OnProgressProc); |
Cipher.Done; |
Cipher.Free; |
finally |
ssOut.Free; |
end; |
finally |
ssIn.Free; |
end; |
end; |
procedure DeCoder22_EncodeFile(const AFileName, AOutput: String; Key: integer; OnProgressProc: TDECProgressEvent=nil); |
var |
ssIn: TFileStream; |
ssOut: TFileStream; |
Cipher: TDECCipher; |
begin |
ssIn := TFileStream.Create(AFileName, fmOpenRead); |
try |
ssOut := TFileStream.Create(AOutput, fmCreate); |
try |
Cipher := TCipher_VtsDeCoder22.Create; |
Cipher.Init(AnsiString(IntToStr(Key)), AnsiString(''), $FF); |
Cipher.Mode := cmECBx; |
TDECFormattedCipher(Cipher).EncodeStream(ssIn, ssOut, ssIn.Size, OnProgressProc); |
Cipher.Done; |
Cipher.Free; |
finally |
ssOut.Free; |
end; |
finally |
ssIn.Free; |
end; |
end; |
procedure DeCoder22_DecodeFile(const AFileName, AOutput: String; Key: integer; OnProgressProc: TDECProgressEvent=nil); |
var |
ssIn: TFileStream; |
ssOut: TFileStream; |
Cipher: TDECCipher; |
begin |
ssIn := TFileStream.Create(AFileName, fmOpenRead); |
try |
ssOut := TFileStream.Create(AOutput, fmCreate); |
try |
Cipher := TCipher_VtsDeCoder22.Create; |
Cipher.Init(AnsiString(IntToStr(Key)), AnsiString(''), $FF); |
Cipher.Mode := cmECBx; |
TDECFormattedCipher(Cipher).DecodeStream(ssIn, ssOut, ssIn.Size, OnProgressProc); |
Cipher.Done; |
Cipher.Free; |
finally |
ssOut.Free; |
end; |
finally |
ssIn.Free; |
end; |
end; |
procedure DeCoder30_EncodeFile(const AFileName, AOutput: String; Key: AnsiString; OnProgressProc: TDECProgressEvent=nil); |
var |
ssIn: TFileStream; |
ssOut: TFileStream; |
Cipher: TDECCipher; |
begin |
ssIn := TFileStream.Create(AFileName, fmOpenRead); |
try |
ssOut := TFileStream.Create(AOutput, fmCreate); |
try |
Cipher := TCipher_VtsDeCoder30.Create; |
Cipher.Init(AnsiString(Key), AnsiString(''), $FF); |
Cipher.Mode := cmECBx; |
TDECFormattedCipher(Cipher).EncodeStream(ssIn, ssOut, ssIn.Size, OnProgressProc); |
Cipher.Done; |
Cipher.Free; |
finally |
ssOut.Free; |
end; |
finally |
ssIn.Free; |
end; |
end; |
procedure DeCoder30_DecodeFile(const AFileName, AOutput: String; Key: AnsiString; OnProgressProc: TDECProgressEvent=nil); |
var |
ssIn: TFileStream; |
ssOut: TFileStream; |
Cipher: TDECCipher; |
begin |
ssIn := TFileStream.Create(AFileName, fmOpenRead); |
try |
ssOut := TFileStream.Create(AOutput, fmCreate); |
try |
Cipher := TCipher_VtsDeCoder30.Create; |
Cipher.Init(AnsiString(Key), AnsiString(''), $FF); |
Cipher.Mode := cmECBx; |
TDECFormattedCipher(Cipher).DecodeStream(ssIn, ssOut, ssIn.Size, OnProgressProc); |
Cipher.Done; |
Cipher.Free; |
finally |
ssOut.Free; |
end; |
finally |
ssIn.Free; |
end; |
end; |
procedure DeCoder32_EncodeFile(const AFileName, AOutput: String; Key: AnsiString; OnProgressProc: TDECProgressEvent=nil); |
var |
ssIn: TFileStream; |
ssOut: TFileStream; |
Cipher: TDECCipher; |
begin |
ssIn := TFileStream.Create(AFileName, fmOpenRead); |
try |
ssOut := TFileStream.Create(AOutput, fmCreate); |
try |
Cipher := TCipher_VtsDeCoder32.Create; |
Cipher.Init(AnsiString(Key), AnsiString(''), $FF); |
Cipher.Mode := cmECBx; |
TDECFormattedCipher(Cipher).EncodeStream(ssIn, ssOut, ssIn.Size, OnProgressProc); |
Cipher.Done; |
Cipher.Free; |
finally |
ssOut.Free; |
end; |
finally |
ssIn.Free; |
end; |
end; |
procedure DeCoder32_DecodeFile(const AFileName, AOutput: String; Key: AnsiString; OnProgressProc: TDECProgressEvent=nil); |
var |
ssIn: TFileStream; |
ssOut: TFileStream; |
Cipher: TDECCipher; |
begin |
ssIn := TFileStream.Create(AFileName, fmOpenRead); |
try |
ssOut := TFileStream.Create(AOutput, fmCreate); |
try |
Cipher := TCipher_VtsDeCoder32.Create; |
Cipher.Init(AnsiString(Key), AnsiString(''), $FF); |
Cipher.Mode := cmECBx; |
TDECFormattedCipher(Cipher).DecodeStream(ssIn, ssOut, ssIn.Size, OnProgressProc); |
Cipher.Done; |
Cipher.Free; |
finally |
ssOut.Free; |
end; |
finally |
ssIn.Free; |
end; |
end; |
initialization |
RandomSeed; |
end. |
/trunk/Decoder5/DecoderMain.pas |
---|
120,7 → 120,7 |
Cipher: TDECCipher; |
s: RawByteString; |
begin |
Cipher := TCipher_Dc30.Create; |
Cipher := TCipher_VtsDeCoder30.Create; |
Cipher.Init('', '', $FF); |
Cipher.Mode := cmECBx; |
s := Cipher.EncodeRawByteString('Hello'); |
131,42 → 131,68 |
Cipher.Mode := cmECBx; |
memo1.Lines.Add(Cipher.DecodeRawByteString(s)); |
Cipher.Done; |
end; |
function Convert(const Bytes: TBytes): RawByteString; |
function Are2FilesEqual(const File1, File2: TFileName): Boolean; |
var |
ms1, ms2: TMemoryStream; |
begin |
SetLength(Result, Length(Bytes)); |
Move(Bytes[0], Result[1], Length(Bytes)) |
Result := False; |
ms1 := TMemoryStream.Create; |
try |
ms1.LoadFromFile(File1); |
ms2 := TMemoryStream.Create; |
try |
ms2.LoadFromFile(File2); |
if ms1.Size = ms2.Size then |
Result := CompareMem(ms1.Memory, ms2.memory, ms1.Size); |
finally |
ms2.Free; |
end; |
finally |
ms1.Free; |
end |
end; |
procedure TFormMain.Button3Click(Sender: TObject); |
var |
ssIn: TFileStream; |
ssOut: TFileStream; |
Cipher: TDECCipher; |
begin |
ssIn := TFileStream.Create('c:\SVN\Decoder\trunk\History\Decoder30\test_in.txt', fmOpenRead); |
ssOut := TFileStream.Create('c:\SVN\Decoder\trunk\History\Decoder30\test_out_foobar_2.txt', fmCreate); |
Cipher := TCipher_Dc30.Create; |
Cipher.Init(AnsiString('foobar'), AnsiString(''), $FF); |
Cipher.Mode := cmECBx; |
TDECFormattedCipher(Cipher).EncodeStream(ssIn, ssOut, ssIn.Size); |
Cipher.Done; |
ssIn.Free; |
ssOut.Free; |
DeCoder20_EncodeFile('TestData\dc20_256zero_in.txt', 'TestData\dc20_256zero_out.tmp', OnProgressProc); |
Assert(Are2FilesEqual('TestData\dc20_256zero_out.txt', 'TestData\dc20_256zero_out.tmp')); |
DeleteFile('TestData\dc20_256zero_out.tmp'); |
ssIn := TFileStream.Create('c:\SVN\Decoder\trunk\History\Decoder30\256zero_in.txt', fmOpenRead); |
ssOut := TFileStream.Create('c:\SVN\Decoder\trunk\History\Decoder30\256zero_out_foobar_2.txt', fmCreate); |
// Cipher := TCipher_Dc30.Create; |
// Cipher.Init(AnsiString('foobar'), AnsiString(''), $FF); |
Cipher.Mode := cmECBx; |
TDECFormattedCipher(Cipher).EncodeStream(ssIn, ssOut, ssIn.Size); |
Cipher.Done; |
ssIn.Free; |
ssOut.Free; |
DeCoder20_EncodeFile('TestData\dc20_test_in.txt', 'TestData\dc20_test_out.tmp', OnProgressProc); |
Assert(Are2FilesEqual('TestData\dc20_test_out.txt', 'TestData\dc20_test_out.tmp')); |
DeleteFile('TestData\dc20_test_out.tmp'); |
Cipher.Free; |
DeCoder22_EncodeFile('TestData\dc22_256zero_in.txt', 'TestData\dc22_256zero_out_61.tmp', 61, OnProgressProc); |
Assert(Are2FilesEqual('TestData\dc22_256zero_out_61.txt', 'TestData\dc22_256zero_out_61.tmp')); |
DeleteFile('TestData\dc22_256zero_out_61.tmp'); |
DeCoder22_EncodeFile('TestData\dc22_test_in.txt', 'TestData\dc22_test_out_61.tmp', 61, OnProgressProc); |
Assert(Are2FilesEqual('TestData\dc22_test_out_61.txt', 'TestData\dc22_test_out_61.tmp')); |
DeleteFile('TestData\dc22_test_out_61.tmp'); |
DeCoder30_EncodeFile('TestData\dc30_256zero_in.txt', 'TestData\dc30_256zero_out_foobar.tmp', 'foobar', OnProgressProc); |
Assert(Are2FilesEqual('TestData\dc30_256zero_out_foobar.txt', 'TestData\dc30_256zero_out_foobar.tmp')); |
DeleteFile('TestData\dc30_256zero_out_foobar.tmp'); |
DeCoder30_EncodeFile('TestData\dc30_test_in.txt', 'TestData\dc30_test_out_foobar.tmp', 'foobar', OnProgressProc); |
Assert(Are2FilesEqual('TestData\dc30_test_out_foobar.txt', 'TestData\dc30_test_out_foobar.tmp')); |
DeleteFile('TestData\dc30_test_out_foobar.tmp'); |
DeCoder32_EncodeFile('TestData\dc32_256zero_in.txt', 'TestData\dc32_256zero_out_foobar.tmp', 'foobar', OnProgressProc); |
Assert(Are2FilesEqual('TestData\dc32_256zero_out_foobar.txt', 'TestData\dc32_256zero_out_foobar.tmp')); |
DeleteFile('TestData\dc32_256zero_out_foobar.tmp'); |
DeCoder32_EncodeFile('TestData\dc32_test_in.txt', 'TestData\dc32_test_out_foobar.tmp', 'foobar', OnProgressProc); |
Assert(Are2FilesEqual('TestData\dc32_test_out_foobar.txt', 'TestData\dc32_test_out_foobar.tmp')); |
DeleteFile('TestData\dc32_test_out_foobar.tmp'); |
DeCoder32_EncodeFile('TestData\dc32_256zero_in.txt', 'TestData\dc32_256zero_out_abcdefg.tmp', 'abcdefg', OnProgressProc); |
Assert(Are2FilesEqual('TestData\dc32_256zero_out_abcdefg.txt', 'TestData\dc32_256zero_out_abcdefg.tmp')); |
DeleteFile('TestData\dc32_256zero_out_abcdefg.tmp'); |
ShowMessage('Alles OK'); |
end; |
end. |
/trunk/Decoder5/DecoderOldCiphers.pas |
---|
6,11 → 6,11 |
SysUtils, DECCipherBase, DECCipherFormats; |
type |
TCipher_Dc30 = class(TDECFormattedCipher) |
private |
TCipher_RepeatingXorSequence = class abstract (TDECFormattedCipher) |
strict private |
FKey: TBytes; |
FKeyPos: Integer; |
protected |
strict protected |
procedure DoInit(const Key; Size: Integer); override; |
procedure DoEncode(Source, Dest: Pointer; Size: Integer); override; |
procedure DoDecode(Source, Dest: Pointer; Size: Integer); override; |
19,14 → 19,62 |
class function Context: TCipherContext; override; |
end; |
// TCipher_VtsDeCoder10 does not exist as DEC Cipher, |
// because this is a cipher that changes the size of the blocks |
// XOR-Stream 00 01 02 03 ... FF 00 01 ... |
// No key provided |
TCipher_VtsDeCoder20 = class(TCipher_RepeatingXorSequence) |
strict protected |
procedure DoInit(const Key; Size: Integer); override; |
public |
class function Context: TCipherContext; override; |
end; |
// The exact implementation is not 100% sure because the binaries and |
// source of this version are lost. |
// It is porbably the same as Version 2.2, just with the key 0..255 instead 0..256 |
TCipher_VtsDeCoder21 = class(TCipher_RepeatingXorSequence) |
strict protected |
procedure DoInit(const Key; Size: Integer); override; |
end; |
// XOR-Stream 60 61 62 ... FF 00 01 ... if key is 60, etc. |
TCipher_VtsDeCoder22 = class(TCipher_RepeatingXorSequence) |
strict protected |
procedure DoInit(const Key; Size: Integer); override; |
end; |
// XOR-Stream repeated password, e.g. "foobarfoobarfoobar", etc. |
TCipher_VtsDeCoder30 = class(TCipher_RepeatingXorSequence) |
strict protected |
procedure DoInit(const Key; Size: Integer); override; |
end; |
// The exact implementation is not 100% sure because the binaries and |
// source of this version are lost. |
// Since Beta 3.3 has the same output as 3.0, it is very likely that |
// 3.1 was either like 3.0 or faulty like 3.2. One of these. |
(* |
TCipher_VtsDeCoder31 = class(TCipher_VtsDeCoder30); |
*) |
// (De)Coder 3.2 probably had a faulty implementation. |
// The XOR stream was "oobarr" instead of "foobar" |
// Version 3.0 and 3.3 beta were OK. Unsure if 3.1 was OK |
TCipher_VtsDeCoder32 = class(TCipher_RepeatingXorSequence) |
strict protected |
procedure DoInit(const Key; Size: Integer); override; |
end; |
implementation |
uses |
DECTypes, DECUtil; |
{ TCipher_Dc30 } |
{ TCipher_RepeatingXorSequence } |
class function TCipher_Dc30.Context: TCipherContext; |
class function TCipher_RepeatingXorSequence.Context: TCipherContext; |
begin |
Result.KeySize := High(Integer); |
Result.BlockSize := 1; |
38,15 → 86,15 |
Result.CipherType := [ctBlock, ctSymmetric]; |
end; |
procedure TCipher_Dc30.DoInit(const Key; Size: Integer); |
procedure TCipher_RepeatingXorSequence.DoInit(const Key; Size: Integer); |
begin |
inherited; |
SetLength(FKey, Size); |
Move(Key, FKey[0], Size); |
FKeyPos := Length(FKey)-1; // Use "-1", not 0, because there is one DoEncode round for IV in TDECCipher.Init, even if IV is empty |
FKeyPos := Length(FKey)-1; // Point to last character, not the first character, because there is one DoEncode round for IV in TDECCipher.Init, even if IV is empty |
end; |
procedure TCipher_Dc30.DoEncode(Source, Dest: Pointer; Size: Integer); |
procedure TCipher_RepeatingXorSequence.DoEncode(Source, Dest: Pointer; Size: Integer); |
var |
i: integer; |
begin |
53,12 → 101,20 |
if State = csDone then FKeyPos := 0; |
for i := 0 to Size-1 do |
begin |
if Length(FKey) = 0 then |
begin |
// Without key, this is a null cipher |
PByte(Dest)[i] := PByte(Source)[i]; |
end |
else |
begin |
PByte(Dest)[i] := PByte(Source)[i] xor FKey[FKeyPos]; |
FKeyPos := (FKeyPos+1) mod Length(FKey); |
end; |
end; |
end; |
procedure TCipher_Dc30.SecureErase; |
procedure TCipher_RepeatingXorSequence.SecureErase; |
begin |
ProtectBuffer(FKey, Length(FKey)); |
SetLength(FKey, 0); |
65,11 → 121,117 |
inherited; |
end; |
procedure TCipher_Dc30.DoDecode(Source, Dest: Pointer; Size: Integer); |
procedure TCipher_RepeatingXorSequence.DoDecode(Source, Dest: Pointer; Size: Integer); |
begin |
DoEncode(Source, Dest, Size); |
end; |
{ TCipher_VtsDeCoder20 } |
class function TCipher_VtsDeCoder20.Context: TCipherContext; |
begin |
result := inherited Context; |
result.KeySize := 0; |
end; |
procedure TCipher_VtsDeCoder20.DoInit(const Key; Size: Integer); |
var |
b: TBytes; |
i: integer; |
begin |
SetLength(b, 256); |
try |
for i := $00 to $FF do b[i] := i; |
inherited DoInit(b[0], 256); |
finally |
ProtectBuffer(b[0], 256); |
end; |
end; |
{ TCipher_VtsDeCoder21 } |
procedure TCipher_VtsDeCoder21.DoInit(const Key; Size: Integer); |
var |
b: TBytes; |
i: integer; |
KeyStr: AnsiString; |
iKey: integer; |
const |
GuiLimMin = 1; |
GuiLimMax = 255; |
resourcestring |
SInvalidDc21Key = 'Key must be a number between %d and %d'; |
begin |
SetLength(KeyStr, Size); |
Move(Key, KeyStr[Low(KeyStr)], Size); |
if not TryStrToInt(string(KeyStr), iKey) or (iKey<GuiLimMin) or (iKey>GuiLimMax) then |
raise EDECException.CreateFmt(SInvalidDc21Key, [GuiLimMin, GuiLimMax]); |
SetLength(b, 256); |
try |
for i := $00 to $FF do b[i] := (i + iKey) mod 256; |
inherited DoInit(b[0], 256); |
finally |
ProtectBuffer(b[0], 256); |
end; |
end; |
{ TCipher_VtsDeCoder22 } |
procedure TCipher_VtsDeCoder22.DoInit(const Key; Size: Integer); |
var |
b: TBytes; |
i: integer; |
KeyStr: AnsiString; |
iKey: integer; |
const |
GuiLimMin = 1; |
GuiLimMax = 256; |
resourcestring |
SInvalidDc22Key = 'Key must be a number between %d and %d'; |
begin |
SetLength(KeyStr, Size); |
Move(Key, KeyStr[Low(KeyStr)], Size); |
if not TryStrToInt(string(KeyStr), iKey) or (iKey<GuiLimMin) or (iKey>GuiLimMax) then |
raise EDECException.CreateFmt(SInvalidDc22Key, [GuiLimMin, GuiLimMax]); |
SetLength(b, 256); |
try |
for i := $00 to $FF do b[i] := (i + iKey) mod 256; |
inherited DoInit(b[0], 256); |
finally |
ProtectBuffer(b[0], 256); |
end; |
end; |
{ TCipher_VtsDeCoder30 } |
procedure TCipher_VtsDeCoder30.DoInit(const Key; Size: Integer); |
begin |
inherited DoInit(Key, Size); |
end; |
{ TCipher_VtsDeCoder32 } |
procedure TCipher_VtsDeCoder32.DoInit(const Key; Size: Integer); |
var |
b: TBytes; |
begin |
// Convert "foobar" to "oobarr" (faulty implementation) |
SetLength(b, Size+1); |
Move(Key, b[0], Size); |
try |
b[Size] := b[Size-1]; |
Delete(b, 0, 1); |
inherited DoInit(b[0], Size); |
finally |
ProtectBuffer(b[0], Size); |
end; |
end; |
initialization |
TCipher_Dc30.RegisterClass(TDECCipher.ClassList); |
TCipher_VtsDeCoder20.RegisterClass(TDECCipher.ClassList); |
TCipher_VtsDeCoder21.RegisterClass(TDECCipher.ClassList); |
TCipher_VtsDeCoder22.RegisterClass(TDECCipher.ClassList); |
TCipher_VtsDeCoder30.RegisterClass(TDECCipher.ClassList); |
//TCipher_VtsDeCoder31.RegisterClass(TDECCipher.ClassList); |
TCipher_VtsDeCoder32.RegisterClass(TDECCipher.ClassList); |
end. |
/trunk/Decoder5/TestData/dc10_example_in.txt |
---|
0,0 → 1,0 |
HELLO WORLD. THIS IS A TEST. |
/trunk/Decoder5/TestData/dc10_example_out.txt |
---|
0,0 → 1,0 |
COD$Ï$Í$Õ$Ö$Ú$Í $Ê$Ý$á$Ü$Õ$Ó.$Ô $Î$Ý$ß$Ð$Ù $È$Ó$Ü $Ý$Þ $Ø$Ê$Ù$Û$É. |
/trunk/Decoder5/TestData/dc20_256zero_in.txt |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/trunk/Decoder5/TestData/dc20_256zero_out.txt |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/trunk/Decoder5/TestData/dc20_test_in.txt |
---|
0,0 → 1,0 |
Hello World! This is a Test! |
/trunk/Decoder5/TestData/dc20_test_out.txt |
---|
0,0 → 1,0 |
Hdnok%Qhzen*,Yffc1{`4t6C}jn: |
/trunk/Decoder5/TestData/dc22_256zero_in.txt |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/trunk/Decoder5/TestData/dc22_256zero_out_61.txt |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/trunk/Decoder5/TestData/dc22_test_in.txt |
---|
0,0 → 1,0 |
Hello World! This is a Test! |
/trunk/Decoder5/TestData/dc22_test_out_61.txt |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/trunk/Decoder5/TestData/dc30_256zero_in.txt |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/trunk/Decoder5/TestData/dc30_256zero_out_foobar.txt |
---|
0,0 → 1,0 |
foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoob |
/trunk/Decoder5/TestData/dc30_test_in.txt |
---|
0,0 → 1,0 |
Hello World! This is a Test! |
/trunk/Decoder5/TestData/dc30_test_out_foobar.txt |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/trunk/Decoder5/TestData/dc32_256zero_in.txt |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/trunk/Decoder5/TestData/dc32_256zero_out_abcdefg.txt |
---|
0,0 → 1,0 |
bcdefggbcdefggbcdefggbcdefggbcdefggbcdefggbcdefggbcdefggbcdefggbcdefggbcdefggbcdefggbcdefggbcdefggbcdefggbcdefggbcdefggbcdefggbcdefggbcdefggbcdefggbcdefggbcdefggbcdefggbcdefggbcdefggbcdefggbcdefggbcdefggbcdefggbcdefggbcdefggbcdefggbcdefggbcdefggbcdefggbcde |
/trunk/Decoder5/TestData/dc32_256zero_out_foobar.txt |
---|
0,0 → 1,0 |
oobarroobarroobarroobarroobarroobarroobarroobarroobarroobarroobarroobarroobarroobarroobarroobarroobarroobarroobarroobarroobarroobarroobarroobarroobarroobarroobarroobarroobarroobarroobarroobarroobarroobarroobarroobarroobarroobarroobarroobarroobarroobarrooba |
/trunk/Decoder5/TestData/dc32_test_in.txt |
---|
0,0 → 1,0 |
Hello World! This is a Test! |
/trunk/Decoder5/TestData/dc32_test_out_foobar.txt |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/trunk/Decoder5/VCL_DEC/DECCipherBase.pas |
---|
998,7 → 998,7 |
begin |
// GCM allows empty key as the authentication still works |
if (Length(Key) = 0) and (not (ctNull in Context.CipherType)) and |
(not (FMode = cmGCM)) then |
(not (FMode = cmGCM)) and (Context.KeySize<>0) then |
raise EDECCipherException.CreateRes(@sNoKeyMaterialGiven); |
if Length(IVector) > 0 then |