.title VALIDATE_PASSWORD Ask for and validate VMS pwd .library "MACROS" setup $JPIDEF $UAIDEF .psect pchk_data, long,noexe,noshr,wrt password_d: descriptor password, 32 password: .blkb 32 username_d: descriptor username, 12 username: .blkb 12 lf = 10 pprompt: .ascii "Password: " pprompt_l = .-pprompt jpi_itmlst: item JPI$_USERNAME, 12, username .long 0 uai_itmlst: item UAI$_PWD, 8, hpwd item UAI$_SALT, 2, salt item UAI$_ENCRYPT, 1, encrypt .long 0 hpwd: .blkq salt: .blkw encrypt: .blkw try_hpwd: .blkq chan: .blkw tty: .ascid "SYS$COMMAND" iosb: .blkw 4 symbol_name: .ascid "PASSWORD_VALID" yes: .ascid "YES" no: .ascid "NO" .psect pchk_code, long,exe,shr,nowrt .entry validate_password, ^M<> ; ; Get username and hashed password ; $GETJPI_S itmlst=jpi_itmlst, iosb=iosb status R0 status iosb $GETUAI_S usrnam=username_d, itmlst=uai_itmlst status R0 ; ; Get password from terminal, no echo ; $ASSIGN_S chan=chan, devnam=tty status R0 $QIOW_S chan=chan, iosb=iosb, - func=#IO$_READPROMPT!IO$M_CVTLOW!IO$M_NOECHO, - p1=password, p2=#32, p5=#pprompt, p6=#pprompt_l status R0 status iosb movw iosb+2, password_d $DASSGN_S chan=chan ; ; Get hashed password ; $HASH_PASSWORD_S pwd=password_d, alg=encrypt, salt=salt, - usrnam=username_d, hash=try_hpwd status R0 ; ; Compare hashed value with UAF ; cmpl hpwd, try_hpwd bneq 1$ cmpl hpwd+4, try_hpwd+4 bneq 1$ ; ; Password is valid -- set PASSWORD_VALID to "YES" ; pushaq yes pushaq symbol_name calls #2, g^LIB$SET_SYMBOL ret ; ; Password is invalid -- set PASSWORD_VALID to "NO" ; 1$: pushaq no pushaq symbol_name calls #2, g^LIB$SET_SYMBOL ret .end validate_password