Read Encryption Key Function code=66 BGeneral descriptionb This calls supplies an encryption key to use in a *I AM or a *PASS command. BOn entry,b 0 +-------------------------+ | Transmit block | | (shown on summary page) | 7 +-------------------------+ BOn exit,b 0 +-------------------------+ | Receive block | | (shown on summary page) | 4 +-------------------------+ | Encryption Key | 7 +-------------------------+ The encryption key allows a use to use *I AM or *PASS without their password being transmitted across the network in plain text. The passwords must be encrypted with code such as the following: \ txt must be a 32-byte area of memory \ XY points to the source string in another 32-byte area of memory \ The source strings must be space padded to 11 characters, eg \ "password " or "oldpass newpass " \ blk must be a 7-byte FSOp control block \ On entry, A=number of strings to encrpypt 1 or 2 \ XY=>string to be encyprted \ On exit, A=0 for ok or A=error number from server \ XY=>encrypted string or error string PHA:STX zp:STY zp+1:LDY #0 :\ Point zp to input string .Lp0 LDA (zp),Y:STA txt,Y:INY :\ Copy input string to text buffer CMP #13:BNE Lp0 : LDA #0:LDX #6 .Lp1 STA blk,X:DEX:BPL Lp1 :\ Clear FSOp control block LDA #7:STA blk+1 :\ Length=7 LDA #&42:STA blk+3 :\ FSOp=&42 - Get Encryption Key LDX #blk AND255:LDY #blk DIV256:\ Point to FSOp control block LDA #&14:JSR &FFF1 :\ Fetch key to blk!4 LDX #(blk+4)AND255:LDY #(blk+4)DIV 256 :\ Point to any error LDA blk+3:BEQ noerror:RTS :\ Exit if error returned : .noerror LDY #0 :\ Point to start of text buffer .Lp2 LDA txt,Y :\ Get character from text buffer LDX #0 .Lp3 ROR A:PHA:ROR A:EOR blk+6 :\ Encrypt this character into ROL A:ROL A:ROL A:ROL A :\ encryption key EOR blk+6:ROR A:ROR A:ROR A ROL blk+4:ROL blk+5:ROL blk+6 PLA:INX:CPX #5:BCC Lp3 ROR A:CPX #5:BEQ Lp3 INY:CPY #10:BNE Lp2 :\ Loop for ten characters : LDY #0:LDX #0 LDA #ASC"$":STA (zp),Y:INY :\ Put '$' prefix into output buffer .Lp5 LDA blk+4,X:PHA:AND #&F CLC:ADC #&41:STA (zp),Y:INY :\ Store low nybble as 'A'-'P' PLA:LSR A:LSR A:LSR A:LSR A CLC:ADC #&41:STA (zp),Y:INY :\ Store high nybble as 'A'-'P' INX:CPX #3:BNE Lp5 :\ Loop for three bytes of key PLA:LSR A:BCS exit :\ Exit if only one string to encrypt : LDA #ASC" ":STA (zp),Y:INY :\ Put ' ' seperator into output buffer LDA #ASC"$":STA (zp),Y:INY :\ Put another '$' prefix into buffer LDX #0 .Lp6 LDA txt,X:CMP #ASC"a":BCC Up :\ Get character from CMP #ASC"{":BCS Up:AND #&5F :\ Force to upper case .Up EOR txt+11,X:EOR #&A5 :\ Encrypt with character from PHA:AND #&F CLC:ADC #&41:STA (zp),Y:INY :\ Store low nybble as 'A'-'P' PLA:LSR A:LSR A:LSR A:LSR A CLC:ADC #&41:STA (zp),Y:INY :\ Store high nybble as 'A'-'P' INX:CPX #10:BNE Lp6 :\ Loop for ten characters of : .exit LDA #13:STA (zp),Y:LDX #20 :\ Put terminating at end of output .Lp7 STA txt,X:DEX:BPL Lp7 :\ Overwrite plaintext input string LDX zp:LDY zp+1:LDA #0:RTS :\ Return A=0, XY=string Issue 01 Jul 1997 10-76