ENCRYPT - FAST ENCRYPTION UTILITY 17-AUG-1990 16:20:01 VAX MACRO V5.0-8 Page 0 Table of contents (1) 3 HEADER AND DEFINITIONS (1) 72 READ ONLY DATA (1) 92 READ WRITE DATA (1) 136 MAIN LINE CODE (1) 227 RANDOM NUMBER GENERATOR (1) 241 ERROR AND EXIT POINTS ENCRYPT - FAST ENCRYPTION UTILITY 17-AUG-1990 16:20:01 VAX MACRO V5.0-8 Page 1 X01-02 17-AUG-1990 16:13:52 ENCRYPT.MAR;1 (1) 0000 1 .TITLE ENCRYPT - FAST ENCRYPTION UTILITY 0000 2 .IDENT /X01-02/ 0000 3 .SBTTL HEADER AND DEFINITIONS ENCRYPT - FAST ENCRYPTION UTILITY 17-AUG-1990 16:20:01 VAX MACRO V5.0-8 Page 2 X01-02 HEADER AND DEFINITIONS 17-AUG-1990 16:13:52 ENCRYPT.MAR;1 (1) 0000 5 ;++ 0000 6 ; 0000 7 ; Copyright (c) 1988 James F. Duff 0000 8 ; General permission to copy or modify is hereby granted under the 0000 9 ; conditions that copy is not used for the purposes of profit and that 0000 10 ; the above copyright notice is included and reference made to the fact 0000 11 ; that reproduction privileges were granted by James F. Duff. 0000 12 ; The author makes no warranties, express or implied, as to the 0000 13 ; usefulness or correctness of this software. 0000 14 ; No publication is made or suggested by use of this copyright notice. 0000 15 ; 0000 16 ;-- 0000 17 0000 18 0000 19 ;++ 0000 20 ; FACILITY: SECURITY 0000 21 ; 0000 22 ; ABSTRACT: 0000 23 ; 0000 24 ; This program is a fast encryption utility. Unlike most encryption 0000 25 ; utilities available, there are no limits on types of file or line 0000 26 ; lengths that this program can handle. 0000 27 ; 0000 28 ; The program is written to be called from DCL by replacing the verb 0000 29 ; "ENCRYPT" in the DCL tables. The parameters it takes are exactly the 0000 30 ; same as DIGITAL's encryption facility, which is available only under 0000 31 ; licence. 0000 32 ; 0000 33 ; The program works by using exclusive OR on bytes in the input file. 0000 34 ; It XORs each byte with a byte from the supplied password and also 0000 35 ; a random number generated by a seed taken from the first 4 bytes of 0000 36 ; the password. Using XOR means that there is only one program for both 0000 37 ; encryption and decryption. 0000 38 ; 0000 39 ; Due to this program being a DCL routine, the password is not case 0000 40 ; sensitive, thus reducing the available security somewhat. Hopefully, 0000 41 ; this restriction will eventually be removed. 0000 42 ; 0000 43 ; ENVIRONMENT: User mode 0000 44 ; 0000 45 ; AUTHOR: JAMES F. DUFF 0000 46 ; 0000 47 ; CREATION DATE: 12-JAN-1988 0000 48 ; 0000 49 ; MODIFIED BY: 0000 50 ; 0000 51 ; Jim Duff 17-Aug-1990 X01-02 0000 52 ; Fixed a bug which caused the first byte of the password 0000 53 ; to never be used. Also performed some code standardization. 0000 54 ; 0000 55 ;-- 0000 56 $IODEF 0000 57 $SSDEF 0000 58 $FIBDEF 0000 59 $SECDEF 0000 60 $CLIDEF 0000 61 ENCRYPT - FAST ENCRYPTION UTILITY 17-AUG-1990 16:20:01 VAX MACRO V5.0-8 Page 3 X01-02 HEADER AND DEFINITIONS 17-AUG-1990 16:13:52 ENCRYPT.MAR;1 (1) 0000 62 .MACRO JMPERR ADDR=ERROR, ?B 0000 63 ; 0000 64 ; This macro tests the low order bit of R0 and jumps to a user 0000 65 ; supplied error routine if it is clear. 0000 66 ; 0000 67 BLBS R0,B 0000 68 JMP ADDR 0000 69 B: .ENDM JMPERR 0000 70 0000 71 0000 72 .SBTTL READ ONLY DATA ENCRYPT - FAST ENCRYPTION UTILITY 17-AUG-1990 16:20:01 VAX MACRO V5.0-8 Page 4 X01-02 READ ONLY DATA 17-AUG-1990 16:13:52 ENCRYPT.MAR;1 (1) 00000000 74 .PSECT ENC$RODATA PIC,USR,CON,REL,LCL,SHR,NOEXE,RD,NOWRT,NOVEC,LONG 0000 75 0000 76 EXP_STR_D: 000000FF 0000 77 .LONG 255 0004 78 .ADDRESS - 00000201' 0004 79 EXP_STR 0008 80 0008 81 FIB_BLK_D: 00000030 0008 82 .LONG 48 000C 83 .ADDRESS - 000000D0' 000C 84 FIB_BLK 0010 85 53 45 4C 49 46 00000018'010E0000' 0010 86 ENT1_D: .ASCID /FILES/ 001D 87 44 57 53 50 00000025'010E0000' 001D 88 ENT2_D: .ASCID /PSWD/ 0029 89 0029 90 0029 91 0029 92 .SBTTL READ WRITE DATA ENCRYPT - FAST ENCRYPTION UTILITY 17-AUG-1990 16:20:01 VAX MACRO V5.0-8 Page 5 X01-02 READ WRITE DATA 17-AUG-1990 16:13:52 ENCRYPT.MAR;1 (1) 00000000 94 .PSECT ENC$RWDATA PIC,USR,CON,REL,LCL,NOSHR,NOEXE,RD,WRT,NOVEC,LONG 0000 95 0000 96 OUT_ARRAY: 00000008 0000 97 .BLKQ 1 0008 98 0008 99 IO_STATUS: 00000010 0008 100 .BLKQ 1 0010 101 000000FF 0010 102 PSWD_D: .LONG 255 0014 103 .ADDRESS - 00000102' 0014 104 PSWD 0018 105 0018 106 INP_STR_D: 000000FF 0018 107 .LONG 255 001C 108 .ADDRESS - 000003FF' 001C 109 INP_STR 0020 110 0020 111 .ALIGN LONG ; Align for RMS data blocks 0020 112 NAM_BLK:$NAM RSA=RES_STR, - ; NAM block 0020 113 RSS=255, - 0020 114 ESA=EXP_STR, - 0020 115 ESS=255 0080 116 0080 117 FAB_BLK:$FAB FOP=NAM, - ; Use NAM block 0080 118 NAM=NAM_BLK, - ; Address of NAM block 0080 119 FNA=INP_STR ; File name 00D0 120 00000100 00D0 121 FIB_BLK:.BLKL 12 0100 122 00000102 0100 123 CHANNEL:.BLKW 1 0102 124 00000201 0102 125 PSWD: .BLKB 255 0201 126 00000300 0201 127 EXP_STR:.BLKB 255 ; Expanded file name from $PARSE 0300 128 000003FF 0300 129 RES_STR:.BLKB 255 ; Resultant name from $PARSE 03FF 130 000004FE 03FF 131 INP_STR:.BLKB 255 04FE 132 04FE 133 04FE 134 04FE 135 04FE 136 .SBTTL MAIN LINE CODE ENCRYPT - FAST ENCRYPTION UTILITY 17-AUG-1990 16:20:01 VAX MACRO V5.0-8 Page 6 X01-02 MAIN LINE CODE 17-AUG-1990 16:13:52 ENCRYPT.MAR;1 (1) 00000000 138 .PSECT ENC$CODE PIC,USR,CON,REL,LCL,SHR,EXE,RD,NOWRT,NOVEC,BYTE 0000 0000 139 .ENTRY ENCRYPT,^M<> 00000010'EF 3F 0002 140 PUSHAW PSWD_D ; Return length 00000010'EF 7F 0008 141 PUSHAQ PSWD_D ; Buffer descriptor to store str 0000001D'EF 7F 000E 142 PUSHAQ ENT2_D ; Entity desc 2 "PSWD" 00000000'GF 03 FB 0014 143 CALLS #3,G^CLI$GET_VALUE ; Get value of entity 001B 144 JMPERR ; Error ? 0024 145 00000018'EF 3F 0024 146 START: PUSHAW INP_STR_D ; Return length 00000018'EF 7F 002A 147 PUSHAQ INP_STR_D ; Buffer descriptor to store str 00000010'EF 7F 0030 148 PUSHAQ ENT1_D ; Entity desc 1 "FILES" 00000000'GF 03 FB 0036 149 CALLS #3,G^CLI$GET_VALUE ; Get value of entity 50 00000000'8F D1 003D 150 CMPL #CLI$_ABSENT,R0 ; Value absent ? 06 12 0044 151 BNEQ 5$ ; No, branch 00000211'EF 17 0046 152 JMP EXIT ; Yes, so we have finished 004C 153 5$: JMPERR ; Other error ? 0055 154 000000B4'EF 00000018'EF D0 0055 155 MOVL INP_STR_D,FAB_BLK+FAB$B_FNS ; Indicate len of file to RMS 0060 156 $PARSE FAB=FAB_BLK ; Call RMS to parse the file 006D 157 JMPERR F_ERR ; Error ? 0076 158 0076 159 $SEARCH FAB=FAB_BLK ; Call RMS to locate the file 0083 160 JMPERR F_ERR ; Error ? 008C 161 55 000000D0'EF DE 008C 162 MOVAL FIB_BLK,R5 ; Address of FIB to R5 50 00000044'EF DE 0093 163 MOVAL NAM_BLK+NAM$W_FID,R0 ; Address of FID to R0 04 A5 80 D0 009A 164 MOVL (R0)+,FIB$W_FID(R5) ; Move 1st longword of FID ... 009E 165 ; ... to FIB 08 A5 60 B0 009E 166 MOVW (R0),FIB$W_FID+4(R5) ; Move 3rd word 65 00000100 8F D0 00A2 167 MOVL #FIB$M_WRITE,FIB$L_ACCTL(R5) ; Specify write access to file 00A9 168 00A9 169 $ASSIGN_S - ; Assign a channel 00A9 170 CHAN=CHANNEL, - 00A9 171 DEVNAM=EXP_STR_D 00BE 172 JMPERR ; Error ? 00C7 173 00C7 174 $QIOW_S FUNC = #IO$_ACCESS!IO$M_ACCESS, - ; Access the file... 00C7 175 CHAN = CHANNEL, - ; ... on the channel 00C7 176 IOSB = IO_STATUS, - 00C7 177 P1 = FIB_BLK_D ; Use FIB 00F0 178 JMPERR ; Error ? 50 00000008'EF D0 00F9 179 MOVL IO_STATUS,R0 ; IO STATUS to R0 0100 180 JMPERR ; IO Error ? 0109 181 0109 182 $CRMPSC_S - ; Map a section 0109 183 INADR=OUT_ARRAY, - 0109 184 RETADR=OUT_ARRAY, - 0109 185 FLAGS=#SEC$M_EXPREG!SEC$M_WRT, - 0109 186 CHAN=CHANNEL ; on the file 0135 187 JMPERR ; Error ? 013E 188 59 00000102'EF D0 013E 189 MOVL PSWD,R9 ; Construct an F float number- 59 59 F9 8F 9C 0145 190 ROTL #-7,R9,R9 ; Get the magnitude to a ... 59 28 90 014A 191 MOVB #40,R9 ; ...reasonable size... 59 59 07 9C 014D 192 ROTL #7,R9,R9 ; and rotate it back 56 00000000'EF 7D 0151 193 MOVQ OUT_ARRAY,R6 ; Start/End addr of section to 0158 194 ; R6/R7 ENCRYPT - FAST ENCRYPTION UTILITY 17-AUG-1990 16:20:01 VAX MACRO V5.0-8 Page 7 X01-02 MAIN LINE CODE 17-AUG-1990 16:13:52 ENCRYPT.MAR;1 (1) 58 D4 0158 195 CLRL R8 ; Clear password pointer 015A 196 57 56 D1 015A 197 LOOP: CMPL R6,R7 ; Begin loop. Finished ? 21 14 015D 198 BGTR LOOP_EXIT ; Yes, branch 58 D5 015F 199 TSTL R8 ; Are we pointing to a byte in 0161 200 ; the password ? 07 18 0161 201 BGEQ 5$ ; Yes, branch 58 00000010'EF 3C 0163 202 MOVZWL PSWD_D,R8 ; No, point to the last byte 66 00000102'EF48 66 8D 016A 203 5$: XORB3 (R6),PSWD[R8],(R6) ; XOR the value in the section 0173 204 ; with the byte of the password 005F 30 0173 205 BSBW RAND ; Get the next random number 66 50 66 8D 0176 206 XORB3 (R6),R0,(R6) ; XOR it in 56 D6 017A 207 INCL R6 ; Next byte of the section 58 D7 017C 208 DECL R8 ; Next byte of the password DA 11 017E 209 BRB LOOP ; Loop til done 0180 210 0180 211 LOOP_EXIT: ; Finished 0180 212 $UPDSEC_S - ; Write the section back to file 0180 213 INADR = OUT_ARRAY 0197 214 JMPERR ; Error ? 01A0 215 01A0 216 $DELTVA_S - ; Delete the section 01A0 217 INADR = OUT_ARRAY 01B1 218 JMPERR ; Error ? 01BA 219 01BA 220 $DASSGN_S - ; Deassign the file 01BA 221 CHAN = CHANNEL 01C8 222 JMPERR ; Error ? 01D1 223 FE4F CF 17 01D1 224 JMP START ; Go see if the file parameter 01D5 225 ; has any more specs in the list 01D5 226 01D5 227 .SBTTL RANDOM NUMBER GENERATOR ENCRYPT - FAST ENCRYPTION UTILITY 17-AUG-1990 16:20:01 VAX MACRO V5.0-8 Page 8 X01-02 RANDOM NUMBER GENERATOR 17-AUG-1990 16:13:52 ENCRYPT.MAR;1 (1) 01D5 229 RAND: 50 01 00010DCD 8F 59 7A 01D5 230 EMUL R9,#69069,#1,R0 ; Extended mult so no overflow 59 50 D0 01DE 231 MOVL R0,R9 ; Next seed to R9 50 59 18 08 EF 01E1 232 EXTZV #8,#24,R9,R0 ; Normalize... 50 50 4E 01E6 233 CVTLF R0,R0 05 13 01E9 234 BEQL 10$ 50 0C00 8F A2 01EB 235 SUBW #24@7,R0 50 F0004632 8F 44 01F0 236 10$: MULF2 #2863,R0 ; Multiply by arbitary number 50 50 4A 01F7 237 CVTFL R0,R0 ; Get integer part 50 01 C0 01FA 238 ADDL #1,R0 ; Add one 05 01FD 239 RSB ; Return with value in R0 01FE 240 01FE 241 .SBTTL ERROR AND EXIT POINTS ENCRYPT - FAST ENCRYPTION UTILITY 17-AUG-1990 16:20:01 VAX MACRO V5.0-8 Page 9 X01-02 ERROR AND EXIT POINTS 17-AUG-1990 16:13:52 ENCRYPT.MAR;1 (1) 0000008C'EF DD 01FE 243 F_ERR: PUSHL FAB_BLK+FAB$L_STV ; RMS error 00000088'EF DD 0204 244 PUSHL FAB_BLK+FAB$L_STS 00000000'GF 02 FB 020A 245 CALLS #2,G^LIB$SIGNAL 50 01 D0 0211 246 EXIT: MOVL #SS$_NORMAL,R0 ; Indicate normal completion 0214 247 ERROR: $EXIT_S R0 ; Exit with status 021D 248 021D 249 .END ENCRYPT ENCRYPT - FAST ENCRYPTION UTILITY 17-AUG-1990 16:20:01 VAX MACRO V5.0-8 Page 10 Symbol table 17-AUG-1990 16:13:52 ENCRYPT.MAR;1 (1) $$.TAB = 00000080 R 03 RAND 000001D5 R 04 $$.TABEND = 000000D0 R 03 RES_STR 00000300 R 03 $$.TMP = 00000000 SEC$M_EXPREG = 00020000 $$.TMP1 = 00000001 SEC$M_WRT = 00000008 $$.TMP2 = 000000AF SS$_NORMAL = 00000001 $$T1 = 00000001 START 00000024 R 04 CHANNEL 00000100 R 03 SYS$ASSIGN ******** GX 04 CLI$GET_VALUE ******** X 04 SYS$CRMPSC ******** GX 04 CLI$_ABSENT ******** X 04 SYS$DASSGN ******** GX 04 ENCRYPT 00000000 RG 04 SYS$DELTVA ******** GX 04 ENT1_D 00000010 R 02 SYS$EXIT ******** GX 04 ENT2_D 0000001D R 02 SYS$PARSE ******** GX 04 ERROR 00000214 R 04 SYS$QIOW ******** GX 04 EXIT 00000211 R 04 SYS$SEARCH ******** GX 04 EXP_STR 00000201 R 03 SYS$UPDSEC ******** GX 04 EXP_STR_D 00000000 R 02 FAB$B_FNS = 00000034 FAB$C_BID = 00000003 FAB$C_BLN = 00000050 FAB$C_SEQ = 00000000 FAB$C_VAR = 00000002 FAB$L_ALQ = 00000010 FAB$L_FOP = 00000004 FAB$L_STS = 00000008 FAB$L_STV = 0000000C FAB$V_CHAN_MODE = 00000002 FAB$V_FILE_MODE = 00000004 FAB$V_LNM_MODE = 00000000 FAB$V_NAM = 00000018 FAB$W_GBC = 00000048 FAB_BLK 00000080 R 03 FIB$L_ACCTL = 00000000 FIB$M_WRITE = 00000100 FIB$W_FID = 00000004 FIB_BLK 000000D0 R 03 FIB_BLK_D 00000008 R 02 F_ERR 000001FE R 04 INP_STR 000003FF R 03 INP_STR_D 00000018 R 03 IO$M_ACCESS = 00000040 IO$_ACCESS = 00000032 IO_STATUS 00000008 R 03 LIB$SIGNAL ******** X 04 LOOP 0000015A R 04 LOOP_EXIT 00000180 R 04 NAM$B_ESS = 0000000A NAM$B_NOP = 00000008 NAM$B_RSS = 00000002 NAM$C_BID = 00000002 NAM$C_BLN = 00000060 NAM$L_ESA = 0000000C NAM$L_RSA = 00000004 NAM$W_FID = 00000024 NAM_BLK 00000020 R 03 OUT_ARRAY 00000000 R 03 PSWD 00000102 R 03 PSWD_D 00000010 R 03 ENCRYPT - FAST ENCRYPTION UTILITY 17-AUG-1990 16:20:01 VAX MACRO V5.0-8 Page 11 Psect synopsis 17-AUG-1990 16:13:52 ENCRYPT.MAR;1 (1) +----------------+ ! Psect synopsis ! +----------------+ PSECT name Allocation PSECT No. Attributes ---------- ---------- --------- ---------- . ABS . 00000000 ( 0.) 00 ( 0.) NOPIC USR CON ABS LCL NOSHR NOEXE NORD NOWRT NOVEC BYTE $ABS$ 00000000 ( 0.) 01 ( 1.) NOPIC USR CON ABS LCL NOSHR EXE RD WRT NOVEC BYTE ENC$RODATA 00000029 ( 41.) 02 ( 2.) PIC USR CON REL LCL SHR NOEXE RD NOWRT NOVEC LONG ENC$RWDATA 000004FE ( 1278.) 03 ( 3.) PIC USR CON REL LCL NOSHR NOEXE RD WRT NOVEC LONG ENC$CODE 0000021D ( 541.) 04 ( 4.) PIC USR CON REL LCL SHR EXE RD NOWRT NOVEC BYTE +------------------------+ ! Performance indicators ! +------------------------+ Phase Page faults CPU Time Elapsed Time ----- ----------- -------- ------------ Initialization 106 00:00:00.27 00:00:01.64 Command processing 839 00:00:00.71 00:00:04.22 Pass 1 401 00:00:16.68 00:01:14.78 Symbol table sort 0 00:00:02.15 00:00:09.34 Pass 2 14 00:00:02.51 00:00:17.48 Symbol table output 0 00:00:00.09 00:00:00.11 Psect synopsis output 0 00:00:00.02 00:00:00.03 Cross-reference output 0 00:00:00.00 00:00:00.00 Assembler run totals 1362 00:00:22.45 00:01:47.75 The working set limit was 2506 pages. 81855 bytes (160 pages) of virtual memory were used to buffer the intermediate code. There were 100 pages of symbol table space allocated to hold 1626 non-local and 14 local symbols. 249 source lines were read in Pass 1, producing 22 object records in Pass 2. 38 pages of virtual memory were used to define 32 macros. +--------------------------+ ! Macro library statistics ! +--------------------------+ Macro library name Macros defined ------------------ -------------- SYS$COMMON:[SYSLIB]STARLET.MLB;1 28 1946 GETS were required to define 28 macros. There were no errors, warnings or information messages. MACRO/LIST ENCRYPT.MAR