From: “Deranged Mutant” <WlkngOwl@unix.asb.com>
To: coderpunks@toad.com
Message Hash: ab0da4d1bf27de7b30b2dcf8dd1648ab255b32d514517d3244ec5332492f8f2a
Message ID: <199603210649.BAA27694@unix.asb.com>
Reply To: N/A
UTC Datetime: 1996-03-21 10:50:17 UTC
Raw Date: Thu, 21 Mar 1996 18:50:17 +0800
From: "Deranged Mutant" <WlkngOwl@unix.asb.com>
Date: Thu, 21 Mar 1996 18:50:17 +0800
To: coderpunks@toad.com
Subject: PC: Using BIOS Wait function as a source of entropy?
Message-ID: <199603210649.BAA27694@unix.asb.com>
MIME-Version: 1.0
Content-Type: text/plain
In some older versions of the NOISE.SYS random driver I experimented
with calling the BIOS Wait function which uses the CMOS timer to
pause, using the "drift" between timing differences. There appears
to be some variation here, but I don't have enough documentation (and
have yet to hack with the BIOS myself) to figure out what goes on
exactly when one calls Int 15h/AH=86h, so I don't know if this is
"real" clock drift of if the variation is caused by somehting else
unsuitable for an RNG.
Still, it seems interesting.
Does anyone have decently detailed tech specs for this function?
Source is enclosed below for reference. No copyrights on it.
---Rob <WlkngOwl@unix.asb.com>
----- Attachment begins here -----
{$F-}
const
timer0 = $40;
timercntl = $43;
WaitInterval = 977;
function SampleTimerWord: Word; assembler;
asm
mov al, 0c2h
out timercntl, al { Latch status and count for timer 0 }
in al, timer0 { Get status word }
test al, 2 { Remember mode 2 v. mode 3 for later }
mov ch, al
in al, timer0 { Get count low byte }
mov ah, al
in al, timer0 { Get count high byte }
xchg ah, al
jz @GotSample { If mode 2, skip this last bit...}
add ch, ch { Top bit of status byte into CF}
rcr ax, 1 { Shift data down and accumulate}
@GotSample:
end;
function Sample: Integer; assembler;
asm
{ From Ralph Brown's Interrupt List:
--------B-1586-------------------------------
INT 15 - BIOS - WAIT (AT,PS)
AH = 86h
CX:DX = interval in microseconds
Return: CF clear if successful (wait interval elapsed)
CF set on error or AH=83h wait already in progress
AH = status (see #0390)
Note: the resolution of the wait period is 977 microseconds on most
systems
because most BIOSes use the 1/1024 second fast interrupt from the
AT real-time clock chip which is available on INT 70
SeeAlso: AH=41h,AH=83h,INT 1A/AX=FF01h,INT 70
}
call SampleTimerWord
push ax
xor cx, cx
mov dx, WaitInterval
mov ah, 86h
int 15h
jnc @NoError { does this affect timings much? }
xor ax, ax
jmp @Abort
@NoError:
call SampleTimerWord
pop bx
sub ax, bx
@Abort:
end;
begin
{ Note: repeated/rapid calls to Sample() crashes the system or causes
BOUND
interrupts (which triggers the Print Screen function on PCs). }
WriteLn(Sample:6);
end.
Rob.
---
Send a blank message with the subject "send pgp-key" (not in
quotes) to <WlkngOwl@unix.asb.com> for a copy of my PGP key.
Return to March 1996
Return to ““Deranged Mutant” <WlkngOwl@unix.asb.com>”
1996-03-21 (Thu, 21 Mar 1996 18:50:17 +0800) - PC: Using BIOS Wait function as a source of entropy? - “Deranged Mutant” <WlkngOwl@unix.asb.com>