From 6c7c9d3c5ba3e83604687bc09b3d1a1264ce2827 Mon Sep 17 00:00:00 2001 From: Markus Humm Date: Tue, 1 Feb 2022 18:53:36 +0100 Subject: [PATCH] Start of the SM3 hash development --- Source/DECHash.pas | 87 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/Source/DECHash.pas b/Source/DECHash.pas index 01b28c25..424e389d 100644 --- a/Source/DECHash.pas +++ b/Source/DECHash.pas @@ -75,6 +75,7 @@ THash_Square = class; THash_Snefru128 = class; // derived from the Xerox Secure Hash Function THash_Snefru256 = class; // " - " THash_Sapphire = class; + THash_SM3 = class; /// /// Implementation of the MD2 hash algorithm. Considered to be broken, @@ -1036,6 +1037,51 @@ THash_Sapphire = class(TDECHashExtended) write SetDigestSize; end; + THash_SM3 = class(TDECHashExtended) + private +// FDigestSize: UInt8; + +// /// +// /// Set the length of the output hash value in byte. +// /// +// /// +// /// Minimum value is 1 byte, maximum value is 64 byte = 512 bit. +// /// Sets the size to the default size returned by DigestSize otherwise. +// /// is specified. +// /// +// procedure SetDigestSize(Value: UInt8); + protected + procedure DoInit; override; + procedure DoDone; override; + procedure DoTransform(Buffer: PUInt32Array); override; + public + function Digest: PByteArray; override; + function DigestAsBytes: TBytes; override; + /// + /// Returns the default digest/hash size in bit. If RequestedDigestSize is + /// not set, the defauilt size returned here is being used. + /// + class function DigestSize: UInt32; override; + /// + /// Returns on which block size this algorithm operates. Since the Sapphire + /// hash originates from a Sapphire stream cipher algorithm this is always 1. + /// + class function BlockSize: UInt32; override; +// procedure Calc(const Data; DataSize: Integer); override; + +// /// +// /// This property defines the length of the output from the hash calculation +// /// in byte. The maximum value is 64 byte = 512 bit. Values bigger 64 byte +// /// and a value of 0 lead to the default size returned by DigestSize otherwise. +// /// This setting is only respected by the DigestAsBytes method and all other +// /// convenience methods using that one like CalcStream, CalcString, +// /// DigestAsString or DigestAsRawString. +// /// +// property RequestedDigestSize: UInt8 +// read FDigestSize +// write SetDigestSize; + end; + /// /// Implementation of the bcrypt password hash algorithm. Maximum password /// length is 72 byte. When encoding typed in passwords in UTF8 that can mean @@ -5211,6 +5257,46 @@ procedure THash_BCrypt.SetCost(const Value: UInt32); {$IFDEF RESTORE_RANGECHECKS}{$R+}{$ENDIF} {$IFDEF RESTORE_OVERFLOWCHECKS}{$Q+}{$ENDIF} +{ THash_SM3 } + +class function THash_SM3.BlockSize: UInt32; +begin + +end; + +function THash_SM3.Digest: PByteArray; +begin + +end; + +function THash_SM3.DigestAsBytes: TBytes; +begin + +end; + +class function THash_SM3.DigestSize: UInt32; +begin + +end; + +procedure THash_SM3.DoDone; +begin + inherited; + +end; + +procedure THash_SM3.DoInit; +begin + inherited; + +end; + +procedure THash_SM3.DoTransform(Buffer: PUInt32Array); +begin + inherited; + +end; + initialization // Define the has returned by ValidHash if passing nil as parameter SetDefaultHashClass(THash_SHA256); @@ -5258,6 +5344,7 @@ initialization THash_Snefru128.RegisterClass(TDECHash.ClassList); THash_Snefru256.RegisterClass(TDECHash.ClassList); THash_Sapphire.RegisterClass(TDECHash.ClassList); + THash_SM3.RegisterClass(TDECHash.ClassList); THash_BCrypt.RegisterClass(TDECHash.ClassList); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy