Trailing-Edge
-
PDP-10 Archives
-
BB-M080M-SM
-
monitor-sources/crypt.mac
There are 24 other files named crypt.mac in the archive. Click here to see a list.
;------------------------- Autopatch Tape # 13 -------------------------
;------------------------- Autopatch Tape # 12 -------------------------
; UPD ID= 2058, SNARK:<6.1.MONITOR>CRYPT.MAC.9, 3-Jun-85 14:22:56 by MCCOLLUM
;TCO 6.1.1406 - Update copyright notice.
; UPD ID= 1391, SNARK:<6.1.MONITOR>CRYPT.MAC.8, 22-Jan-85 14:59:05 by LEACHE
;TCO 6.1.1149 Simplify CHKPEV
; UPD ID= 4515, SNARK:<6.MONITOR>CRYPT.MAC.7, 13-Jul-84 19:29:14 by PURRETTA
;Update copyright notice
; UPD ID= 2221, SNARK:<6.MONITOR>CRYPT.MAC.6, 8-Apr-83 14:49:14 by LEACHE
;Suppress MN%DPV and MX%DPV
; UPD ID= 2128, SNARK:<6.MONITOR>CRYPT.MAC.5, 2-Apr-83 22:46:23 by LEACHE
;Move customer dispatch tables to STG
;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED
;OR COPIED ONLY IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE.
;
;COPYRIGHT (C) DIGITAL EQUIPMENT CORPORATION 1976, 1985.
;ALL RIGHTS RESERVED.
SEARCH PROLOG,MONSYM
TTITLE CRYPT
SWAPCD
;Encryption routines
; Routine to encrypt a password
; Accepts in T1/ Password encryption version number to use
; T2/ Lookup pointer to JSB block containing password
; Returns:
; +1 Invalid password encryption version number
; +2 with T1 containing lookup pointer to encrypted block
; -(LEN-1),,TEXT-1
; Suitable for use by SETMSK and CPYDIR
;
; Called and returns NOINT because of the JSB block
;Dispatch table for DEC password encryption version
DECDIS: [RETSKP] ;Version 0 (Unencrypted)
MN%DPV==:.-DECDIS-1 ;Current Minimum DEC password encryption version
HSHPWD ;Version 1
MX%DPV==:.-DECDIS-1 ;Current Maximum DEC password encryption version
[RET] ;Version 2
[RET] ;Version 3
[RET] ;Version 4
[RET] ;Version 5
[RET] ;Version 6
[RET] ;Version 7
[RET] ;Version 10
;Customer encryption routines, customer dispatch table, customer
;version interval, and current encryption version for this monitor
;are defined in STG. See label PSENVR:
ENCPAS::CALL CHKPEV ;Check validity of password encryption
; version number
RET ;Bad version
TRZN T1,1B18 ;Customer version number?
SKIPA T3,DECDIS(T1) ;No, get DEC dispatch address
MOVE T3,CUSDIS(T1) ;Yes, get customer dispatch address
JRST (T3) ;Go to it
;Routine to range-check password encryption version number
;T1/ DEC/customer version number
;RETURNS: +1 Bad version number
; +2 Good version number
CHKPEV::CAIL T1,MN%DPV ;Within DEC interval?
CAILE T1,MX%DPV ;...
SKIPA ;No
RETSKP ;Yes, return success
CAML T1,MINCPV ;Within customer interval?
CAMLE T1,MAXCPV ;...
RET ;Neither DEC nor customer, return failure
RETSKP ;Yes, return success
;Routine for polynomial password encryption
;This computes P^(2^30+36) +A1*P^(2^30) +A2*P^3 +A3*P^2 +A4*P +A5
HSHPWD: SAVEP ;Make use of all P's
STKVAR <HSHVER,HSHPTR> ;Two locals
MOVEM T1,HSHVER ;Save version number
MOVEM T2,HSHPTR ;Save lookup pointer
SKIPN 1(T2) ;Is there anything?
RETSKP ;No, leave it like that
SKIPN HSHVER ;Version 0 password?
RETSKP ;Yes, leave it unencrypted
MOVE T1,T2 ;Copy block address
MOVEI P5,4 ;Number of double word groups to encode
; SETZB P3,P4 ;Start with real first word
dmove p3,3(a) ;push different hash to up to 20 chars
HSHPW1: TDC P3,1(A) ;First half
TDC P4,2(A) ;Second half
DMOVE P1,P3 ;Double word to encode
LSHC P1,-1 ;Put significant bits where they belong
DDIV P1,HSHMOD ;Take mod
DMOVE C,P3 ;Save original number
MOVEI B,5 ;Loop count
HSHPW2: DMOVE P1,P3 ;Copy number for square
DMUL P1,P3 ;Square it
DDIV P1,HSHMOD ;Take mod
SOJG B,HSHPW2 ;Loop to raise it to the 32 power
DMOVEM P3,1(A) ;Save Pwd^32
DMOVE P1,P3 ;Move for multiply
DMUL P1,C ;Make Pwd^33
DDIV P1,HSHMOD ;Take mod
DADD P3,HSHA1 ;Add in first coefficient
SETZB P1,P2 ;Make quad-word
DDIV P1,HSHMOD ;Take mod
DMOVE P1,1(A) ;Get Pwd^32 back
DMOVEM P3,1(A) ;Save A1+Pwd^33
DMOVE P3,P1 ;Copy for square
MOVEI B,^D25 ;Loop count
HSHPW3: DMUL P1,P3 ;Square it
DDIV P1,HSHMOD ;Take mod
DMOVE P1,P3 ;Copy for square
SOJG B,HSHPW3 ;Loop to produce (Pwd^(2^30))
DMUL P1,1(A) ;Multiply by A1+Pwd^33
DDIV P1,HSHMOD ;Take mod
SKIPE HSHVER ;Add second coefficient?
DADD P3,HSHA2 ;Yes
SETZB P1,P2 ;Make a quad-word
DDIV P1,HSHMOD ;Take mod
SETZ B, ;Offset for coefficients
HSHPW4: DMOVE P1,P3 ;Move for multiply
DMUL P1,C ;Multiply by Pwd
DDIV P1,HSHMOD ;Take mod
DMOVE P1,P3 ;Move for multiply
SKIPN HSHVER ;Multiply by next coefficient?
DMUL P1,HSHA3(B) ;Yes
SKIPE HSHVER ;Add next coefficient?
DADD P1,HSHA3(B) ;Yes
DDIV P1,HSHMOD ;Take mod
ADDI B,2 ;Next coefficient
CAIGE B,6 ;Only 3 more coefficients
JRST HSHPW4 ;Keep going
LSHC P3,1 ;Make it Ascii again
MOVE P1,[BYTE(7) 040,040,040,040,040]
MOVE P2,P1
TDZ P3,[BYTE(7) 100,100,100,100,100(1)1]
TDZ P4,[BYTE(7) 100,100,100,100,100(1)1]
ANDCM P1,P3 ;Do necessary
ANDCM P2,P4 ; work to
LSHC P1,1 ; make
TDO P3,P1 ; printable
TDO P4,P2 ; Ascii
DMOVEM P3,1(A) ;Store encoded Ascii password doubleword
ADDI A,2 ;Point to next doubleword
SOJG P5,HSHPW1 ;Do all 4 doublewords
SETZ B, ;Append a zero
SUBI A,8
DPB B,[POINT 8,8(A),35] ;To make string Asciz
MOVE A,HSHPTR ;Restore block pointer
RETSKP ;Return Noint
HSHMOD: OCT 377777777777,377777777735 ;(2^70-35) prime modulus
HSHA1: OCT 305301317120,157221260120 ;The randomly chosen coefficients
HSHA2: OCT 147300565442,275156661305
HSHA3: OCT 276504256001,246721554756
OCT 226461502774,377222042231
OCT 040267005300,343010077117
TNXEND
END