Skip to content

Commit 8e0fed1

Browse files
committed
- Criação de uma classe intermediária para facilitar exportação de criptografia do pacote, RALHashes.pas #78
* Ajuste em todas as classes para trocar RALHashes -> RALHashBase - Correção de IntegerOverflow nas hashes SHA * Ajuste de mensagem de erro referente às classes de criptografia e hash + Tratamento de entrada para evitar Invalid Pointer e Rangecheck Error - Ajuste de versionamento
1 parent a3abc6a commit 8e0fed1

20 files changed

Lines changed: 634 additions & 423 deletions

pkg/Delphi/PascalRAL.dpk

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ contains
5252
RALCripto in '..\..\src\utils\RALCripto.pas',
5353
RALCriptoAES in '..\..\src\utils\RALCriptoAES.pas',
5454
RALCustomObjects in '..\..\src\utils\RALCustomObjects.pas',
55-
RALHashes in '..\..\src\utils\RALHashes.pas',
55+
RALHashBase in '..\..\src\utils\RALHashBase.pas',
5656
RALJson in '..\..\src\utils\RALJson.pas',
5757
RALMD5 in '..\..\src\utils\RALMD5.pas',
5858
RALMIMETypes in '..\..\src\utils\RALMIMETypes.pas',
@@ -72,6 +72,7 @@ contains
7272
RALStorageCSV in '..\..\src\utils\RALStorageCSV.pas',
7373
RALStorageJSON in '..\..\src\utils\RALStorageJSON.pas',
7474
RALStorageBIN in '..\..\src\utils\RALStorageBIN.pas',
75-
RALDBTypes in '..\..\src\base\RALDBTypes.pas';
75+
RALDBTypes in '..\..\src\base\RALDBTypes.pas',
76+
RALHashes in '..\..\src\utils\RALHashes.pas';
7677

7778
end.

pkg/Delphi/PascalRAL.dproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@
191191
<DCCReference Include="..\..\src\utils\RALCripto.pas"/>
192192
<DCCReference Include="..\..\src\utils\RALCriptoAES.pas"/>
193193
<DCCReference Include="..\..\src\utils\RALCustomObjects.pas"/>
194-
<DCCReference Include="..\..\src\utils\RALHashes.pas"/>
194+
<DCCReference Include="..\..\src\utils\RALHashBase.pas"/>
195195
<DCCReference Include="..\..\src\utils\RALJson.pas"/>
196196
<DCCReference Include="..\..\src\utils\RALMD5.pas"/>
197197
<DCCReference Include="..\..\src\utils\RALMIMETypes.pas"/>
@@ -212,6 +212,7 @@
212212
<DCCReference Include="..\..\src\utils\RALStorageJSON.pas"/>
213213
<DCCReference Include="..\..\src\utils\RALStorageBIN.pas"/>
214214
<DCCReference Include="..\..\src\base\RALDBTypes.pas"/>
215+
<DCCReference Include="..\..\src\utils\RALHashes.pas"/>
215216
<BuildConfiguration Include="Base">
216217
<Key>Base</Key>
217218
</BuildConfiguration>

src/base/RALConsts.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ interface
1313

1414
const
1515
// Versionamento
16-
RALVERSION = '0.11.0-13 alpha';
16+
RALVERSION = '0.11.0-16 alpha';
1717
RALVERSION_MAJOR = 0;
1818
RALVERSION_MINOR = 11;
1919
RALVERSION_PATCH = 0;

src/base/RALDBTypes.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ class procedure TRALDB.ParseSQLParams(ASQL: StringRAL; AParams: TParams);
378378

379379
for vInt := POSINISTR to RALHighStr(ASQL) do
380380
begin
381-
vSQLChar := ASQL[vInt];
381+
vSQLChar := CharRAL(ASQL[vInt]);
382382
if (vSQLChar = '''') and (not vEspaceDoubleQuote) and
383383
(not (vEscapeQuote and (vChar = '\'))) then
384384
begin

src/base/ralconsts_enus.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
emCompressLibFilesError = 'The library files of the following classes were not found: %s.';
1515
emContentCheckError = 'Content check error.';
1616
emCryptEmptyKey = 'Key must be provided.';
17+
emHMACEmptyText = 'Input text must be provided.';
1718
emDBConnectionUndefined = 'Connection not set.';
1819
emDBDriverMissing = 'Connection driver not found.';
1920
emDBEmptyBody = 'Body is empty.';

src/base/ralconsts_eses.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
emCompressLibFilesError = 'No se encontraron los archivos binarios de biblioteca de las clases: %s.';
1515
emContentCheckError = 'Error de comprobación de contenido.';
1616
emCryptEmptyKey = 'Se debe proporcionar la clave.';
17+
emHMACEmptyText = 'Se debe proporcionar lo texto.';
1718
emDBConnectionUndefined = 'Conexión no establecida.';
1819
emDBDriverMissing = 'No se encontró el controlador de conexión.';
1920
emDBEmptyBody = 'El cuerpo está vacío.';

src/base/ralconsts_ptbr.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
emCompressLibFilesError = 'Os arquivos binários das seguintes classes não foram encontrados: %s.';
1515
emContentCheckError = 'Erro de verificação de conteúdo.';
1616
emCryptEmptyKey = 'A chave deve ser fornecida.';
17+
emHMACEmptyText = 'Texto de entrada não pode ser vazio.';
1718
emDBConnectionUndefined = 'Conexão não definida.';
1819
emDBDriverMissing = 'Driver de conexão não encontrado.';
1920
emDBEmptyBody = 'O "body" está vazio.';

src/database/sqldb/RALDBSQLDB.pas

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ TRALDBSQLDB = class(TRALDBBase)
3131
var ALastInsertId : Int64RAL); override;
3232
function GetDriverType: TRALDBDriverType; override;
3333
function GetFieldTable(ADataset: TDataSet; AFieldIndex: IntegerRAL) : StringRAL; override;
34-
function OpenNative(ASQL : string; AParams : TParams) : TDataset; override;
34+
function OpenNative(ASQL : StringRAL; AParams : TParams) : TDataset; override;
3535
function OpenCompatible(ASQL : StringRAL; AParams : TParams) : TDataset; override;
3636

3737
procedure SaveToStream(ADataset: TDataSet; AStream: TStream;
@@ -127,7 +127,7 @@ destructor TRALDBSQLDB.Destroy;
127127
inherited Destroy;
128128
end;
129129

130-
function TRALDBSQLDB.OpenNative(ASQL : string; AParams : TParams) : TDataset;
130+
function TRALDBSQLDB.OpenNative(ASQL : StringRAL; AParams : TParams) : TDataset;
131131
var
132132
vQuery : TSQLQuery;
133133
vInt : integer;

src/utils/RALBase64.pas

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ TRALBase64 = class
3737
class function GetSizeDecode(ASize: Int64RAL): Int64RAL;
3838
end;
3939

40+
{$IF Defined(FPC) or Defined(DELPHIXE3UP)}
41+
TRALBase64StringHelper = record helper for StringRAL
42+
public
43+
function toBase64: StringRAL;
44+
function fromBase64: StringRAL;
45+
end;
46+
{$IFEND}
47+
4048
implementation
4149

4250
const
@@ -71,6 +79,9 @@ class function TRALBase64.Decode(const AValue: StringRAL): StringRAL;
7179
var
7280
vStream: TStream;
7381
begin
82+
if AValue = '' then
83+
Raise Exception.Create(emHMACEmptyText);
84+
7485
vStream := StringToStreamUTF8(AValue);
7586
try
7687
Result := Decode(vStream);
@@ -340,6 +351,9 @@ class function TRALBase64.Encode(const AValue: StringRAL): StringRAL;
340351
var
341352
vStream: TStream;
342353
begin
354+
if AValue = '' then
355+
Raise Exception.Create(emHMACEmptyText);
356+
343357
vStream := StringToStreamUTF8(AValue);
344358
try
345359
Result := Encode(vStream);
@@ -419,4 +433,18 @@ class function TRALBase64.EncodeAsStream(AValue: TStream): TStream;
419433
Result.Position := 0;
420434
end;
421435

436+
{ TRALBase64StringHelper }
437+
438+
{$IF Defined(FPC) or defined(DELPHIXE3UP)}
439+
function TRALBase64StringHelper.fromBase64: StringRAL;
440+
begin
441+
Result := TRALBase64.Decode(Self);
442+
end;
443+
444+
function TRALBase64StringHelper.toBase64: StringRAL;
445+
begin
446+
Result := TRALBase64.Encode(Self);
447+
end;
448+
{$IFEND}
449+
422450
end.

src/utils/RALCRC32.pas

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ interface
44

55
uses
66
Classes, SysUtils,
7-
RALHashes, RALTypes;
7+
RALHashBase, RALTypes;
88

99
type
10-
TRALCRC32 = class(TRALHashes)
10+
TRALCRC32 = class(TRALHashBase)
1111
private
1212
FCRC32 : LongWord;
1313
FBuffer: array[0..63] of Byte;

0 commit comments

Comments
 (0)