GithubHelp home page GithubHelp logo

fundamentals5's People

Contributors

bi0t1n avatar butlerdj avatar casteng avatar fundamentalslib avatar zoomuae avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fundamentals5's Issues

Backwards compatibility issue when migrating from v5.0.4 -> v5.0.5 using Delphi 7

I have a Delphi 7 project (an RSA encrypt/decrypt demo) using fundamentals release v5.0.4 source code. It compiles and works OK.

Then I see new release v5.0.5 became public, so I try the same project using release v5.0.5 source code but It does not compile anymore.

Here the messages log from Delphi 7 compiler:

[Error] flcHash.pas(1089): Undeclared identifier: 'UnicodeString'
[Error] flcHash.pas(1334): Overloaded procedure 'CalcXOR8' must be marked with the 'overload' directive
[Error] flcHash.pas(1347): Overloaded procedure 'CalcXOR16' must be marked with the 'overload' directive
[Error] flcHash.pas(1357): Overloaded procedure 'CalcXOR32' must be marked with the 'overload' directive
[Error] flcHash.pas(1431): Overloaded procedure 'CalcCRC16' must be marked with the 'overload' directive
[Error] flcHash.pas(1525): Overloaded procedure 'CalcCRC32' must be marked with the 'overload' directive
[Error] flcHash.pas(1584): Overloaded procedure 'CalcAdler32' must be marked with the 'overload' directive
[Error] flcHash.pas(1622): Overloaded procedure 'CalcELF' must be marked with the 'overload' directive
[Error] flcHash.pas(2386): Overloaded procedure 'CalcMD5' must be marked with the 'overload' directive
[Error] flcHash.pas(2559): Overloaded procedure 'CalcSHA1' must be marked with the 'overload' directive
[Error] flcHash.pas(2638): Overloaded procedure 'CalcSHA224' must be marked with the 'overload' directive
[Error] flcHash.pas(2807): Overloaded procedure 'CalcSHA256' must be marked with the 'overload' directive
[Error] flcHash.pas(2888): Overloaded procedure 'CalcSHA384' must be marked with the 'overload' directive
[Error] flcHash.pas(3163): Overloaded procedure 'CalcSHA512' must be marked with the 'overload' directive
[Error] flcHash.pas(3490): Overloaded procedure 'CalcRipeMD160' must be marked with the 'overload' directive
[Error] flcHash.pas(3635): Overloaded procedure 'CalcHMAC_MD5' must be marked with the 'overload' directive
[Error] flcHash.pas(3640): Overloaded procedure 'CalcHMAC_MD5' must be marked with the 'overload' directive
[Error] flcHash.pas(3710): Overloaded procedure 'CalcHMAC_SHA1' must be marked with the 'overload' directive
[Error] flcHash.pas(3715): Overloaded procedure 'CalcHMAC_SHA1' must be marked with the 'overload' directive
[Error] flcHash.pas(3785): Overloaded procedure 'CalcHMAC_SHA256' must be marked with the 'overload' directive
[Error] flcHash.pas(3790): Overloaded procedure 'CalcHMAC_SHA256' must be marked with the 'overload' directive
[Error] flcHash.pas(3860): Overloaded procedure 'CalcHMAC_SHA512' must be marked with the 'overload' directive
[Error] flcHash.pas(3865): Overloaded procedure 'CalcHMAC_SHA512' must be marked with the 'overload' directive
[Error] flcHash.pas(207): Unsatisfied forward or external declaration: 'DigestToHexBufA'
[Error] flcHash.pas(212): Unsatisfied forward or external declaration: 'DigestToHexA'
[Fatal Error] flcCipherRSA.pas(63): Could not compile used unit 'Utils\flcHash.pas'

Did you test this new release using Delphi 7 ?
Am I missing any extra step in order to get fundamentals release v5.0.5 working using Delphi 7 ?

Function is only defined on windows "SOCKETLIB_WIN"

This fails on Linux because this function result -

{$IFDEF StringIsUnicode}
Result := IsIP6AddressU(Address, NetAddress);
{$ELSE}
Result := IsIP6AddressA(Address, NetAddress);
{$ENDIF}

Is only defined for Windows -

{$IFDEF SOCKETLIB_WIN}
function IsIP6AddressU(const Address: UnicodeString; out NetAddress: TIP6Addr): Boolean;
{$ENDIF}

Compile error - Duplicate identifier

fpc 3.3 r40721 does not like it when function arguments have the same name as a property

flcDataStructs.pas(343,48) Error: Duplicate identifier "Count"
flcDataStructs.pas(344,48) Error: Duplicate identifier "Count"
flcDataStructs.pas(378,48) Error: Duplicate identifier "Count"
flcDataStructs.pas(379,48) Error: Duplicate identifier "Count"
flcDataStructs.pas(384,31) Error: Duplicate identifier "Count"
flcDataStructs.pas(420,48) Error: Duplicate identifier "Count"
flcDataStructs.pas(421,48) Error: Duplicate identifier "Count"
flcDataStructs.pas(426,31) Error: Duplicate identifier "Count"
flcDataStructs.pas(471,48) Error: Duplicate identifier "Count"
flcDataStructs.pas(472,48) Error: Duplicate identifier "Count"
flcDataStructs.pas(477,31) Error: Duplicate identifier "Count"
flcDataStructs.pas(513,48) Error: Duplicate identifier "Count"
flcDataStructs.pas(514,48) Error: Duplicate identifier "Count"
flcDataStructs.pas(519,31) Error: Duplicate identifier "Count"
flcDataStructs.pas(564,48) Error: Duplicate identifier "Count"
flcDataStructs.pas(565,48) Error: Duplicate identifier "Count"
flcDataStructs.pas(570,31) Error: Duplicate identifier "Count"
flcDataStructs.pas(606,48) Error: Duplicate identifier "Count"
flcDataStructs.pas(607,48) Error: Duplicate identifier "Count"
flcDataStructs.pas(612,31) Error: Duplicate identifier "Count"
flcDataStructs.pas(648,48) Error: Duplicate identifier "Count"
flcDataStructs.pas(649,48) Error: Duplicate identifier "Count"
flcDataStructs.pas(654,31) Error: Duplicate identifier "Count"
flcDataStructs.pas(690,48) Error: Duplicate identifier "Count"
flcDataStructs.pas(691,48) Error: Duplicate identifier "Count"
flcDataStructs.pas(696,31) Error: Duplicate identifier "Count"
flcDataStructs.pas(733,48) Error: Duplicate identifier "Count"
flcDataStructs.pas(734,48) Error: Duplicate identifier "Count"
flcDataStructs.pas(739,31) Error: Duplicate identifier "Count"
flcDataStructs.pas(776,48) Error: Duplicate identifier "Count"
flcDataStructs.pas(777,48) Error: Duplicate identifier "Count"
flcDataStructs.pas(782,31) Error: Duplicate identifier "Count"
flcDataStructs.pas(824,48) Error: Duplicate identifier "Count"
flcDataStructs.pas(825,48) Error: Duplicate identifier "Count"
flcDataStructs.pas(830,31) Error: Duplicate identifier "Count"
flcDataStructs.pas(863,48) Error: Duplicate identifier "Count"
flcDataStructs.pas(864,48) Error: Duplicate identifier "Count"
flcDataStructs.pas(869,31) Error: Duplicate identifier "Count"
flcDataStructs.pas(905,48) Error: Duplicate identifier "Count"
flcDataStructs.pas(906,48) Error: Duplicate identifier "Count"
flcDataStructs.pas(911,31) Error: Duplicate identifier "Count"
flcDataStructs.pas(944,48) Error: Duplicate identifier "Count"
flcDataStructs.pas(945,48) Error: Duplicate identifier "Count"
flcDataStructs.pas(950,31) Error: Duplicate identifier "Count"
flcDataStructs.pas(987,48) Error: Duplicate identifier "Count"
flcDataStructs.pas(996,27) Error: Duplicate identifier "Item"
flcDataStructs.pas(996,48) Error: Duplicate identifier "ClassType"
flcDataStructs.pas(997,27) Error: Duplicate identifier "Item"
flcDataStructs.pas(997,48) Error: Duplicate identifier "ClassName"
flcDataStructs.pas(998,26) Error: Duplicate identifier "ClassType"
flcDataStructs.pas(998,26) Verbose: There were 50 errors compiling module, stopping

Do the utils work on OSX?

Is this library cross platform and can it be used in FMX apps? I am interested in using it on OSX.

I can see there are defines for UNIX but not sure whether they work on OSX

How to use TDoublyLinkedList

Hi,
Can you provide an example about how to use TDoublyLinkedList?

This is what I have so far:

  var list: TDoublyLinkedList:=TDoublyLinkedList.Create;
  list.Append(TDoublyLinkedString.Create('1'));
  var ni:TDoublyLinkedString:=TDoublyLinkedString.Create('2');
  ni.Append('2.1');
  ni.Append('2.2');
  list.Append(ni);
  list.free;

How do I iterate through the elements?
I'd like to produce the following output:
1
2 - 2.1 - 2.2

Bug in calling CompareMemNoAsciiCase() in flcHTMLElements.pas

in flcHTMLElements.pas

in function htmlGetTagIDPtrA();

this portion
CompareMemNoAsciiCase(Name^, Pointer(P^.Name)^, NameLen)
should be
CompareMemNoAsciiCase(Name^, Pointer(AnsiString(P^.Name))^, NameLen)

and similarly, in function htmlGetAttrIDPtrA()
this portion
CompareMemNoAsciiCase(Name^, Pointer(htmlAttributeTable[Result])^, NameLen)
should be
CompareMemNoAsciiCase(Name^, Pointer(AnsiString(htmlAttributeTable[Result]))^, NameLen)

Otherwise, CompareMemNoAsciiCase() fails.

Could you please add those typecasts.

wrong certificate digital signature

Hi,

I have generated my root ca, imported it as trusted ca.
I then have generated a server cert (signed by my root ca) : so far so good, my windows is happy with my cert (cert path, etc).

Now, I set up a https server with fundamentals5 and use http_srv.TCPServer.TLSServer.PEMFileName :='full.pem'; //contains cert and private key

When connecting to my https server (with different browsers), it fails.

Client hello, server hello, cert exchange and key exchange take place but client sends back an alert.

My issue is the following : I can observe that the key exchange is tagged as malformed packet in wireshark (key len = 0).
Screenshot here [https://i.imgur.com/CGO7mHD.png] .

I tried to generate my ca & cert with sha1 and sha2 : no success.
I tried ssl3 to tls1.2 : no success.
I tried setting PrivateKeyRSAPEM and TLSCertificateListAppend (rather than using a cert file) : no success.

Anything I am doing wrong / missing or is there a bug in the code?

I can share my root ca and cert if needed (all local with openssl).
The same cert works fine with a similar code with Indy 10

Regards,
Erwan

my code

begin
http_srv:=TF5HTTPServer.Create(nil);
http_srv.OnPrepareResponse := onSrvPrepareResponse;
http_srv.OnResponseComplete:=onSrvResponseComplete;
http_srv.AddressFamily := safIP4;
http_srv.ServerPort :=4443;
http_srv.OnLog :=onSrvLogEvent;
//http_srv.TCPServer.OnLog := onTCPServerLogEvent;
//define tls in flcTCP.inc and define http_tls in flcHTTP.inc
if chktls.Checked then
begin
//http_srv.HTTPSOptions:=[ssoDontUseTLS12,ssoDontUseTLS11,ssoDontUseTLS10 ];
http_srv.TCPServer.TLSServer.PEMFileName :='full.pem';
http_srv.TCPServer.TLSServer.OnLog :=onTLSServerLogEvent;
http_srv.HTTPSEnabled :=true;
end;
http_srv.Active :=true;
Assert(http_srv.Active);
end;

HugeWordAssignBufStrB / HugeWordAssignBufStr works wrong with short buffers

Hello!

Thank you for a great library!

I found a bug in the functions HugeWordAssignBufStrB and HugeWordAssignBufStr
it adds 0x013F00 to the short buffers

How to repeat:
pass a single byte buffer to the function, e.g., #1

A "patch" that fixes the problem (just add zeros)
raw := StringOfChar(#0,3) + raw;
HugeWordAssignBufStrB(BN, raw, True);

TF5HTTPClient HTTPS using

Hello, i didn't find any information about http client component.
So the question is: how to set HTTPS connection as example for "google.com"?
I tried to change "usehttps" property, but this no helps.

Documentation?

Is there any documentation beyond staring at source code?

CompareMemNoAsciiCase not present

Unit flcStreams

AReaderEx.Match contains a call to CompareMemNoAsciiCase
This is listed in the documentation but doesn't exist.
CompareMemNoAsciiCaseB and CompareMemNoAsciiCaseW do exist.

My project won't compile and I don't want to guess which to use and start changing code I don't understand :)

Have you got a function to convert time/date from free form

Hi,
I was looking at the datetime util but couldn't find any methods to do what I need.

Is there a method to convert natural language date/time to TDateTime?
For example, for the input "3hrs and 5mins" to produce the relevant TDateTime?
Thanks

Invalid NUMBER representation in flcJSON.pas

Hello!
In advance, sorry for my poor english.

In accordance with the specifications of JSON (see http://www.json.org/), about Number type.
Number is:
It is a double precision floating-point format in JavaScript (Octal and hexadecimal formats are not used).
...
In accordance with the definition, the DOT (".") must be used as the decimal separator. In your implementation of JSON (in flcJson.pas), you use FloatToStr and StrToFloat function, which as a decimal value used Delphi DecimalSeparator global constant, which contradicts the requirements of the JSON specification. For example, in Russia as DecjmalSeparator used COMMA, therefore your flcJson module in Russia can not be used.

In accordance with the foregoing, I propose:

  1. Into flcJson.pas module add two functions:
function FloatToStrDot (aValue: extended): string;
var
 fFormatSettings : TFormatSettings;
begin
  GetLocaleFormatSettings (GetThreadLocale, fFormatSettings);
  fFormatSettings.DecimalSeparator := '.';
  Result := FloatToStr (aValue, fFormatSettings);
end;

function StrToFloatDot (aValue : string) : Extended;
var
  fDummy : Integer;
begin
  Val(aValue, Result, fDummy);
  if fDummy <> 0 then
    raise Exception.CreateFmt('Invalid float value: "%s"', [aValue]);
end;
  1. Using the above-mentioned functions in all flcJson.pas module instead
    FloatToStr and StrToFloat.
Regards, 
Malinovsky Vladimir.

Hashing the text instead of dictionary keys

Hi,

I used some of your code to make some very good dictionaries in one of my apps.
Thank you very much.

Now I have a different situation: dictionaries for multiple (automated/confirmation) find&replace.
They can be strings of any kind: Any (upcase/lowcase) letter, number 0..9 or even chars not found in words.

Usualy there are a large number of searches on large rtfs - and only a few replacements.
So it seems a text hashing (instead of dictionary key hashing) would be a lot faster.

Do you have some advices/hints on how to do that?

Thank you.

Kind regards,
Cosmin

Compiler error - flcUtils.pas(2279): E2003 Undeclared identifier: 'UTF8Char'

Wanted to compile and newly introduced html parser and run flcHTMLTest.pas, but got error as the following:
[dcc32 Error] flcUtils.pas(2279): E2003 Undeclared identifier: 'UTF8Char'

It's XE4 and it does support utf-8 and I can see the following in flcInclude.inc, so not sure why this compilation error happens. I did try manually adding SupportUTF8Char to the newly-created, almost-empty project's Conditional Defines, still getting the same error.
Any hints? Thanks.

{$IFDEF DELPHIXE4_UP}
  {$DEFINE SupportUTF8Char}

BTW, does the parser supports full html5 spec?
does the parsed info contain position info?

File flcASN1.pas

flcCipherDH references flcASN1, than isn't in the package. I look everywhere but didn't find it.

Pseudo-abstrct metods of class TStringDictionary are not fully defined

Error detection:

uses
  flcDataStructs;
var
  fD : TStringDictionary;
  fStr: string;
begin
   fD := TStringDictionary.Create;
   fD['1234'] := '567';
   fStr := fD.AsString; // raised exception "Method TStringDictionary.GetItemStrByIndex not implemented"

Solution:

Solution:
It should be in the protected section of class AStringDictionary add overridden method:

type
  AStringDictionary = class(ADictionary)
  protected
...
    function  GetItemStrByIndex(const Idx: Integer): String; override; // Added 

with the implementation:

function AStringDictionary.GetItemStrByIndex(const Idx: Integer): String;
begin
  Result := GetItemByIndex(Idx);
end;
Regards, Malinovsky Vladimir.

Get modulus , public exponent , private exponent from RSA KEY PEM file

Hi, I am using flcCipherRSA (fundamentals5 v5.0.4).

Here, I manage PublicKeys and PrivateKeys in terms of KeySize Modulus & Exponent.

However, when somebody provides me a key , they give me a PEM File.

I know I can use openssl command line tool this way:

Get key size, modulus, public exponent & private exponent, (private.pem contains a RSA PRIVATE KEY)
openssl rsa -in private.pem -text

Get key size, modulus, public exponent, (public.pem contains a RSA PUBLIC KEY)
openssl rsa -pubin -inform PEM -text -noout < public.pem

So, here my question:

Is there an easy way to get key size, modulus, public exponent, private exponent from a PEM file using fundamental5 library ?

FYI: I'm using fundamentals v5.0.4 and Delphi 7. (I see some functions related to PEM management in TLS unit (v5.0.5) but I don't really know they cover my needs and eventually I can not use because v5.0.5 is not actually been testes with Delphi 7)

HugeWordAssignBuf() memory corruption bug

I think, there is a bug in HugeWordAssignBuf() at the end of the procedure. Here is a modified version with some explanations:

procedure HugeWordAssignBuf(var A: HugeWord; const Buf; const BufSize{Bytes}: Integer; const ReverseByteOrder: Boolean);
//* The for cycle high value when filling the end of A.Data buffer with zeroes. -1 means no fill, 0 means 1 byte fill.
const FillCount: array[0..HugeWordElementSize-1] of Integer = (-1, 2, 1, 0); 
var {L}ElemCount, I : Integer;
    P, Q : PByte;
begin
  if BufSize <= 0 then
    HugeWordAssignZero(A)
  else
    begin
      {L}ElemCount := (BufSize{Bytes} + HugeWordElementSize{Bytes} - 1) div HugeWordElementSize{Bytes};
      HugeWordSetSize_NoZeroMem(A, {L}ElemCount);
      //* Copy number of BufSize bytes from Buf to A.Data
      P := @Buf;
      Q := A.Data;
      if ReverseByteOrder then
        Inc(P, BufSize{Bytes} - 1);
      //* For example BufSize = 3, ElemCount = 1, this is a 4 byte buffer. 
      //* It copies bytes at position 0, 1, 2 
      for I := 0 to BufSize{Bytes} - 1 do
        begin
          Q^ := P^;
          Inc(Q);
          if ReverseByteOrder then
            Dec(P)
          else
            Inc(P);
        end;
      //* Fill the remaining bytes with zeroes in A.Data
(* Original code
      //* In the above example, Q points to position 3, and the cycle should run once.
      //* But 3 mod 4 - 1 = 2, and the cycle will run 3 times, causing memory corruption above the allocated buffer.
      for I := 0 to BufSize{Bytes} mod 4{HugeWordElementSize} - 1 do
        begin
          Q^ := 0; 
          Inc(Q);
        end;
*)
      //*  Modified code
      for I := 0 to FillCount[BufSize{Bytes} mod HugeWordElementSize] do
        begin
          Q^ := 0; 
          Inc(Q);
        end;
    end;
end;

No "HugeWordAddWord64" in flcHugeInt

flcHugeInt contains no addition function for directly passed 64-bit integers (signed or unsigned).

By contrast, flcInteger contains operations like WordXXAddWord64 for all integer word types and is able to operate even on typecasted 64-bit variables. Could such functionality be implemented in flcHugeInt too?

HugeInt performance degradation

flcHugeInt has serious performance degradation in comparison with version 4. RSA 4096-bit keys generation take about 30 sec. using cHugeInt (version 4) and more than 3 minutes with flcHugeInt (current version). Generation 8192-bit keys take about 3 minutes using cHugeInt (version 4) and more then 3 hours with flcHugeInt (current version). In my test i used equal entropy source for both versions.

CodeGen fails to generate code for complex .proto

Trying to generate code for VoxPbMonitoringProtocol.proto from http://developer.voxtron.com/?page_id=262 I get the following error:

Error: VoxPbMonitoringProtocol.proto(8): VoxPbCommonProtocol.proto(256): Identifier expected

VoxPbCommonProtocol.proto is an import and is also present in the directory.
I tried it with the google supplied protoc for C++ and it generated code, so I assume the .proto file itself is valid.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.