feature: SHA-1 Hashing

- Add SHA-1 hashing implementation with Init/Update/Final API and inline test in kernel,
  following the same interface as MD5 & the fpc rtl.
This commit is contained in:
t3hn3rd committed 2026-03-07 10:31:56 +00:00
1 parent 262d064b6d
commit ffa06c982f
2 files changed
+234 -1

No files matched your search

File diff suppressed because it is too large. Load diff
+24 -1
View File
@@ -69,7 +69,8 @@ uses
video, vesa, doublebuffer, color, lvgl, desktop, uidebug, windows,
vterminal,
graphicsrefresh, usbhotplug,
fifo, cfifo, cfifols, lifo, circ, minh, maxh, prio;
fifo, cfifo, cfifols, lifo, circ, minh, maxh, prio,
sha1;
procedure kmain(mbinfo: Pmultiboot_info_t; mbmagic: uint32); stdcall;
@@ -104,6 +105,9 @@ var
dds : uint32;
keyboard_layout : array [0..1] of TKeyInfo;
i : uint32;
sha1ctx : TSHA1Context;
sha1dig : TSHA1Digest;
sha1msg : array[0..9] of uint8;
begin
{ Init the base system unit }
@@ -264,6 +268,25 @@ begin
maxh.UnitTest;
prio.UnitTest;
{ SHA1 test: hash 'Helloworld' }
sha1msg[0] := $48; { H }
sha1msg[1] := $65; { e }
sha1msg[2] := $6C; { l }
sha1msg[3] := $6C; { l }
sha1msg[4] := $6F; { o }
sha1msg[5] := $77; { w }
sha1msg[6] := $6F; { o }
sha1msg[7] := $72; { r }
sha1msg[8] := $6C; { l }
sha1msg[9] := $64; { d }
SHA1Init(@sha1ctx);
SHA1Update(@sha1ctx, @sha1msg[0], 10);
SHA1Final(@sha1ctx, @sha1dig);
syslog.log('SHA1', 'Helloworld = ');
for i := 0 to 19 do
syslog.writehexpair(sha1dig[i]);
syslog.writestringln('');
{ Register timer-driven tasks }
graphicsrefresh.init;
usbhotplug.init;