home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / pgpmsq.zip / PGPMSQ.TXT
Text File  |  1994-08-10  |  9KB  |  183 lines

  1.  * Crossposted to areas PUBLIC_KEYS, MUFFIN, TUB
  2.  
  3.  
  4.  For anybody who is interested, I've just recently developed some macros/batch files to get PGP and msgedsq to operate together quite nicely...
  5.  
  6.  These are the macros:  One to decrypt, and one to encrypt:
  7.  
  8. This one is to decrypt a message.
  9.  
  10. _ _ _ O / _ _ C_U_T_ H_E_R_E_ _ _ _
  11.       O \
  12. function 31 
  13. \0x11^xH:\\TMP\\MSGED.TXT^m!DECRYPT^m^m\0x2e^m^m^m^my^m^m^m^m\0x77\0x1e\0x75\0x 2e\0x17^xH:\\TMP\\PGPOUT.TMP^m\0x20\0x20^m\0x75\0x48\0x20\0x17^xH:\\TMP\\MSGED^ m\0x77\0x1f
  14. _ _ _ O / _ _ C_U_T_ H_E_R_E_ _ _ _
  15.       O \
  16.  
  17. This one is to encrypt/sign a message (the batch file ENCRYPT presents the options of signing, encrypting, or both):
  18.  
  19. _ _ _ O / _ _ C_U_T_ H_E_R_E_ _ _ _
  20.       O \
  21. function 32 \0x11^xH:\\TMP\\MSGED.TXT^m!ENCRYPT^m^m\0x2e^m^m^m^my^m^m^m^m\0 x77\0x1e\0x75\0x2e\0x17^xH:\\TMP\\MSGED.ASC^m\0x1f
  22. _ _ _ O / _ _ C_U_T_ H_E_R_E_ _ _ _
  23.       O \
  24.  
  25. Now for an explanation of exactly what these macros do, step by step:
  26.  
  27. \0x11 - ALT-W:  Invokes the write command to export the message
  28. ^xH:\\TMP\\MSGED.TXT^m: Selects the file to write the message to.  The ^x
  29.                         clears to the beginning of the line so that a new
  30.                         filename can be entered.  Note that the double-slashes
  31.                         are also necessary, since a single slash is interpreted
  32.                         as a key-code prefix.
  33. !DECRYPT / !ENCRYPT     Invokes a DOS batch file to perform the PGP work.  The
  34.                         two CR's (^M^M) are necessary in order to enter the
  35.                         command, and return to msged afterwards.
  36. \0x2e^m^m^m^my^m^m^m^m: Invokes the Change-message routine (ALT-C).  The reason
  37.                         for all the carriage returns is to bypass the header.
  38.                         These are repeated twice in case msged prompts you to
  39.                         confirm editing an already-sent message.  Extraneous
  40.                         lines that end up in the message text because of this
  41.                         are cleared out next.
  42. \0x77\0x1e\0x75\0x2e:   This sequence is CTRL-HOME, ALT-A, CTRL-END, and ALT-C.
  43.                         This will cut the existing text, from beginning to end
  44.                         from the message.
  45. \0x17^xH:\\TMP\\MSGED^m This invokes the ALT-I function to import a file
  46.                         into the editor.  The file that is imported is either
  47.                         the plaintext (MSGED), or the armored ASCII text after
  48.                         signing/encrypting (MSGED.ASC).
  49. \0x1f                   This is the ALT-S (Save Message) function.
  50.  
  51.  Note also that in the decryption routine, another file, PGPOUT.TMP, is imported before the decrypted message, and some editing functions are performed on it in order to just leave a block at the top of the message that indicates that the sender's signature has been verified.  \0x20 is ALT-D (Delete line), \0x75 is CTRL-END (end of message), and \0x48 is the UP arrow.  The resulting content of PGPOUT.TMP that is left in the message looks as follows:
  52.  
  53. _ _ _ O / _ _ C_U_T_ H_E_R_E_ _ _ _
  54.       O \
  55. Good signature from user "Jesse David Hollington <1:225/1.1@fidonet.org>".
  56. Signature made 1992/11/07 23:46 GMT
  57.  
  58. ------------ P L A I N   T E X T   F O L L O W S ------------
  59. _ _ _ O / _ _ C_U_T_ H_E_R_E_ _ _ _
  60.       O \
  61.  
  62.  Note also that the separator line is a function of the batch file, and may be easily changed.
  63.  
  64.  Now for the batch files:
  65.  
  66.  Here is DECRYPT.BTM (note that commands are 4DOS/NDOS specific, with some
  67.  editing, they can probably be made to work with normal MS-DOS). 
  68.  
  69. _ _ _ O / _ _ C_U_T_ H_E_R_E_ _ _ _
  70.       O \
  71. CLS
  72.  
  73. REM This is a 4DOS/NDOS Command that saves the current directory.
  74. PUSHD
  75.  
  76. REM This is a 4DOS/NDOS command that changes both current drive and directory
  77. CDD H:\TMP
  78.  
  79. REM These two commands clean up any files left over in the work directory
  80. IF EXIST MSGED ZAP MSGED /Q >NUL
  81. IF EXIST MSGED.PGP ZAP MSGED.PGP /Q >NUL
  82.  
  83. REM This line decrypts the message (if it's encrypted) but leaves the
  84. REM signature block intact.  This is necessary so that the signature
  85. REM certification message can be added to the plaintext.  If the message
  86. REM is not encrypted, but only signed, the MSGED.PGP file will still be
  87. REM created.  Note that MSGED.PGP is created as a binary (non-armored) file.
  88. REM Obviously if the message is neither signed nor encrypted, nothing will
  89. REM occur.
  90. PGP -d MSGED.TXT MSGED.PGP
  91.  
  92. REM This line will then validate the signature on the message.  It takes
  93. REM MSGED.PGP as input (which is produced by the last command), and output
  94. REM is redirected to PGPOUT.TMP, to later be included with the plaintext.
  95. REM The final product of this command is a file called MSGED (no extension).
  96. REM If the file MSGED.PGP contains no signature, MSGED will not be produced.
  97. PGP MSGED.PGP >PGPOUT.TMP
  98.  
  99. REM This will delete the PGPOUT.TMP file if no signature was present on the
  100. REM message, since the only purpose of PGPOUT.TMP is to add the text validation
  101. REM block to the plaintext output.
  102. IF NOT EXIST MSGED ZAP PGPOUT.TMP /Q >NUL
  103.  
  104. REM This nested IFF statement will copy either the decrypted plaintext, or the
  105. REM original text, in the event that either no signature is present, or the
  106. REM message wasn't encrypted to begin with.  This is necessary since there is
  107. REM no way to check within msged as to what kind of operation PGP has performed REM (therefore msged will run the change-message routine and try to import the
  108. REM file MSGED regardless of outcome of PGP's operation).
  109. IFF NOT EXIST MSGED THEN 
  110.     IF EXIST MSGED.PGP COPY MSGED.PGP MSGED >NUL
  111.     IF NOT EXIST MSGED.PGP COPY MSGED.TXT MSGED >NUL
  112. ENDIFF
  113.  
  114. REM This line adds a tear line between the validation text and the plain text. IF EXIST PGPOUT.TMP ECHO ------------ P L A I N   T E X T   F O L L O W S ------------ >>PGPOUT.TMP
  115.  
  116. REM This is a 4DOS/NDOS command to restore the current directory. POPD 
  117. _ _ _ O / _ _ C_U_T_ H_E_R_E_ _ _ _
  118.       O \
  119.  
  120.  Here is ENCRYPT.BTM (again note the 4DOS/NDOS specific commands.  This one
  121.  would be a little more difficult to run with MS-DOS because of the menu it
  122.  uses).
  123.  
  124. _ _ _ O / _ _ C_U_T_ H_E_R_E_ _ _ _
  125.       O \
  126.  
  127. CLS
  128.  
  129. REM TEXT and ENDTEXT define the menu to be displayed.
  130. TEXT
  131.  
  132.   S) Sign Message
  133.   E) Encrypt Message
  134.   B) Sign & Encrypt
  135.   Q) Quit back to msged
  136.         
  137. ENDTEXT
  138.  
  139. REM This is actually a Norton BE command that prompts the user for a choice
  140. REM and returns an errorlevel based upon the user's choice.
  141. BE ASK "Choice:",SEBQ
  142.  
  143. REM These errorlevels set the command-line switches for PGP based upon the
  144. REM user's choice.
  145. IF ERRORLEVEL 1 SET SW=-SW
  146. IF ERRORLEVEL 2 SET SW=-EW
  147. IF ERRORLEVEL 3 SET SW=-SEW
  148. IF ERRORLEVEL 4 GOTO END
  149.  
  150. CLS
  151. PUSHD
  152. CDD H:\TMP
  153. REM This line erases the old MSGED.ASC output file, if it exists.
  154. IF EXIST MSGED.ASC ZAP MSGED.ASC /Q >NUL
  155. REM This runs PGP with the options defined above in the SW environment var.
  156. PGP %SW MSGED.TXT
  157.  
  158. REM This end routing is used if the user selects the Q)uit option, or if 
  159. REM PGP didn't produce a MSGED.ASC file for whatever other reason.  It copies
  160. REM the original plaintext into the MSGED.ASC file so that the original message
  161. REM will be preserved.
  162. :END
  163. IF NOT EXIST MSGED.ASC COPY MSGED.TXT MSGED.ASC >NUL
  164. POPD
  165.  
  166. _ _ _ O / _ _ C_U_T_ H_E_R_E_ _ _ _
  167.       O \
  168.  
  169.  It should be noted that there are a couple other important things that must be done for this to work properly.  Obviously, PGP, DECRYPT.BTM, and ENCRYPT.BTM have to be available on the DOS path.  It is also recommended that a RAM drive be used for the intermediate files, as this will speed up operation a bit.  Most importantly, however, the kludge lines have to be turned off before the macro runs.  Since the kludge option is toggled with ALT-V (keycode \0x2f) in msgedsq, there is no way to definitely determine whether they are on or off before the macro is executed.  I run mine off by default using a startup macro in msgedsq, but if you want your kludge lines *on* by default, then the "\0x2f" sequence should be added at the beginning and end of the macro.  If the kludge lines are on, it doesn't really create any problem beyond a minor nuisance (they'll be encrypted with the rest of the plaintext).
  170.  
  171.  It is also important to note that only the PGP block from a message will be included in the output.  If there is any text before or after the PGP block, it will be lost.  Unfortunately, I haven't found a way to deal with this yet.  If anybody else finds a way, I'd appreciate hearing about it.
  172.  
  173.  Lastly, the DECRYPT sequence can also be used to import public keys or keyrings from the PKEY_DROP area (or wherever else) onto your keyring. 
  174.  
  175.  I hope this is useful to those of you who run PGP and msgedsq together.  Feel free to expand upon these and let me know how they work.  I'd also appreciate hearing any problems so I can clear them up.
  176.  
  177. Cheers,
  178.  Jesse.
  179.  
  180.  
  181. --- msgedsq 2.1
  182.  * Origin: Net 225 Command Post (1:225/1.1)
  183.