.title PASSCHK - Verify a Password ; ; Author: Dennis Merchant ; Oct. 1990 ; ; Function: Verify if a Password is correct ; .show expansions ; ; Symbols : ; $UAIDEF ; $STRDEF $STR$ROUTINESDEF ; ; Data : ; ITEMLST: .word 8 .word UAI$_PWD ; Encrypted Password .address PWD .address PWDLEN .word 1 .word UAI$_ENCRYPT ; Encryption Algorithm .address ECRPT .address ECRPTLEN .word 2 .word UAI$_SALT ; Salt .address SALT ; .address SALTLEN .long 0 PWD: .quad 0 PWDLEN: .long 0 ECRPT: .byte 0 ECRPTLEN: .long 0 SALT: .word 0 SALTLEN: .long 0 HASHPWD: .quad 0 NAME: .ascid / / PASSWORD: .ascid / / BLNK: .ascii / / PWD_LEN: .word 0 SUB_IDX: .long 0 SUCCESS: .long 1 FAILURE: .long 2 ; ; Code : ; .entry PASSCHK, ^M ; MOVC3 #40,@4(AP),PASSWORD+8 ; Get supplied password MOVC3 #12,@8(AP),NAME+8 ; Get supplied userid ; MOVAL PASSWORD+8,R4 ; Start of password field AGAIN: CMPW #41,PWD_LEN ; Are we at the end? BEQL GET_UAI ; No blanks, assume length=40 CMPB BLNK,(R4) ; Is it a Blank? BEQL FOUNDIT ; Yes, were done INCL R4 ; No, increment pointer INCW PWD_LEN ; Increment length JMP AGAIN FOUNDIT: MOVW PWD_LEN,PASSWORD ; Move length into descriptor GET_UAI: ; $GETUAI_S USRNAM=NAME, - ; Get the UAI info that ITMLST=ITEMLST ; we need. ; $HASH_PASSWORD_S USRNAM=NAME, - ; Encode the password PWD=PASSWORD, - ; we were given. ALG=ECRPT, - SALT=SALT, - HASH=HASHPWD ; CMPL PWD,HASHPWD ; Does the first longword ; ; match? BNEQU NOMATCH ; No, then indicate it. CMPL PWD+4,HASHPWD+4 ; Does the second longword ; ; match? BNEQU NOMATCH ; No, then indicate it. MOVL SUCCESS,R0 ; Indicate Success BRW RETURN ; and return. ; NOMATCH: MOVL FAILURE,R0 ; Indicate Failure RETURN: RET ; Return to Calling Program ; .end