home *** CD-ROM | disk | FTP | other *** search
- /**********************************************************************/
- /* */
- /* DecryptPGP.ced - ARexx program that integrates Cygnus Editor and */
- /* the Pretty Good Privacy package, version 1.0 */
- /* */
- /* This program was tested to work with Cygnus Editor 3.5 and PGP */
- /* version 2.3a patchlevel 3 by Peter Simons, but should work also */
- /* with earlier versions of both PGP and CED. */
- /* If you want to decrypt a PGP message, you have to load it into */
- /* CED, then run this macro, and sit comfortably enjoying the show */
- /* until it finishes. */
- /* */
- /* This software is in Public Domain under GNU General Public License */
- /* */
- /* Author: Janusz A. Urbanowicz <alex@vm.cc.uni.torun.pl> */
- /* */
- /* History */
- /* Version 1.0 - first public release */
- /* */
- /**********************************************************************/
-
- /*
- * $VER: DecryptPGP.ced 1.0 (4.07.1994)
- */
-
-
- Trace Off
-
- Options Results
-
- packetstart = "'-----BEGIN PGP MESSAGE-----'"
- packetend = "'-----END PGP MESSAGE-----'"
- signedstart = "'-----BEGIN PGP SIGNED MESSAGE-----'"
- signedend = "'-----END PGP SIGNATURE-----'"
-
- cmdline = '+batchmode=on T:ced$pgp.tmp -o T:ced$plain.asc'
- lf = '0A'X
-
- packets = 0
- lpackets = 0
- scratch = 0
-
- /* main() */
- Address Command
- 'GetEnv >NIL: PGPPASS'
- If rc ~= 0 Then
- Do
- Address 'rexx_ced'
- okay2 "Your passphrase is not set in PGPPASS variable."||lf||,
- "It must be set temporarily for running PGP".||lf||,
- "Should it be deleted (for higher security) after use ??"
- If result = 1 then scratch = 1
- else scratch = 0
- okay1 'WARNING: Your passphrase will be visible when you type it in.'
- getstring "' ' 'Please enter passphrase.'"
- pgppass = result
- pgppass = Strip(pgppass,'B')
- Address Command
- 'SetEnv PGPPASS '||'"'||pgppass||'"'
- End
-
- Address 'rexx_ced'
- okay2 "Do you want to mark decrypted blocks"||lf||,
- "within the text ?"
- mark = result
-
- Do until lpackets == packets
- lpackets = packets
- scan(mark)
- End
- If packets = 0 Then okay1 "No PGP ASCII packet found."
- Else okay1 "Found "||packets||" packet(s)."
- Exit
-
- /* End of main() */
-
- scan: procedure expose lf cmdline scratch packets packetstart signedstart packetend signedend
- Arg mark
- Address 'rexx_ced'
- If FindStart(packetstart) Then
- Do
- If FindEnd(packetend) Then
- Do
- cut block
- menu 0 6 0 'T:ced$pgp.tmp' /* save block to file */
- decrypt_pkt(mark)
- Return 1
- End
- End
-
- If FindStart(signedstart) Then
- Do
- If FindEnd(signedend) Then
- Do
- cut block
- menu 0 6 0 'T:ced$pgp.tmp' /* save block to file */
- decrypt_pkt(mark)
- Return 1
- End
- End
- Return 0
-
- FindStart: procedure expose packets
- Arg string
- Address 'rexx_ced'
- beg of file
-
- Do FOREVER
- search for string
- If result = 1 Then
- Do
- status 59
- If result = (Length(string)-2) Then
- Do
- packets = packets +1
- mark block
- Return 1
- End
- End
- Else Return 0
- End
-
- FindEnd: procedure expose lf scratch
- Arg string
- Address = 'rexx_ced'
- Do FOREVER
- search for string
- If result = 0 Then
- Do
- okay1 "Cannot find end of packet."||lf,
- "File is corrupted"
- Call quit
- End
- Else
- Do
- status 59
- If result = (Length(string)-2) Then
- Do
- down
- Return 1
- End
- End
- End
-
- decrypt_pkt: procedure expose cmdline lf scratch
- arg mark
-
- plainstart = "======== BEGIN OF PGP BLOCK ========"
- plainend = "======== END OF PGP BLOCK ========"
-
- Address Command
- 'PGP '||cmdline
- If ~Exists('T:ced$plain.asc') Then
- Do
- Address 'rexx_ced'
- include file 'T:ced$pgp.tmp'
- okay1 "Wrong passphrase !"
- Address Command
- Call quit
- End
- Else
- Do
- Address 'rexx_ced'
- If mark == 1 Then
- Do
- text plainstart
- text lf
- up
- center line
- text plainend
- text lf
- up
- center line
- up
- beg of line
- End
- include file 'T:ced$plain.asc'
- status 21
- Call clean
- Return 1
- End
-
- clean: procedure
- Address Command
- If Exists('T:ced$pgp.tmp') Then 'Delete T:ced$pgp.tmp quiet'
- If Exists('T:ced$plain.asc') Then 'Delete T:ced$plain.asc quiet'
- If Exists('T:ced$pgp.tmp.bak') Then 'Delete T:ced$pgp.tmp.bak quiet'
- If Exists('T:ced$pgp.tmp.info') Then 'Delete T:ced$pgp.tmp.info quiet'
- Return 1
-
- quit: procedure expose scratch
- Call clean
- If scratch == 1 Then 'Delete env:PGPPASS'
- Exit 0
-