home *** CD-ROM | disk | FTP | other *** search
- /********************************************************************/
- /* */
- /* SignPGP.ced - ARexx macro for use with Cygnus Editor and PGP */
- /* */
- /* Mark a block of text you want to be signed using PGP, then run */
- /* this macro. If no block was marked, you may choose to use whole */
- /* file instead. This macro was tested to work with CED 3.5, but */
- /* should work also with lower versions. It also takes advantage */
- /* of some PGP non-standard options avaliable in official Amiga */
- /* port by Peter Simons, but should work also with other versions, */
- /* like the PGP 2.6ui, or plain 2.3a. */
- /* */
- /* This code is in Public Domain under GNU General Public License */
- /* */
- /* author: Janusz A. Urbanowicz <alex@vm.cc.uni.torun.pl> */
- /* */
- /* See CEDPGP.guide for more info */
- /* */
- /********************************************************************/
-
- /*
- * $VER: SignPGP.ced 1.7 (30.10.1994)
- */
-
- Trace Off
-
- Options Results
-
- lf = '0A'X
- tempfile = 'T:ced$pgp.tmp'
- scrname = 'CygnusEdScreen'
- scrnum = 1
- portname = 'rexx_ced'
- portnum = 0
-
- pgpt = 0 /* pgp 'type' 0 = 2.3a, 1 = 2.3a.?, 2 = 2.6<ui> */
-
- cmdn = '-sat ' /* command for NORMAL PGP */
- cmdf = '<'||tempfile||' -fast -o '||tempfile||'.asc' /* command for Peter's patchlevel 3,4 and 5 versions */
- scratch = 0
-
- /* main () */
-
- status portnumber
- portnum = result
- if (portnum ~= 0)&(portnum ~== 'RESULT') Then
- Do
- scrnum = scrnum + portnum
- portname = portname||portnum
- End
-
- scrname = scrname||scrnum
-
-
- Call Close 'STDOUT' /* Thanx for that goes to Rick Younie*/
- Call Close 'STDIN'
- Call Open 'STDOUT','CON:16/24/620/130/PGPAmiga Output/CLOSE/WAIT/SCREEN'||scrname
- Call Pragma '*','STDOUT'
- Call Open 'STDIN','*'
-
- Call checkf
- pgpt = result
- If pgpt > 0 Then
- Do
- cmd = cmdf
- cmdline = ''
- End
- Else
- Do
- Call ask
- cmd = cmdn
- cmdline = tempfile||' +batchmode=on'
- End
-
-
- Address Command
- 'GetEnv >PIPE:PGPUSER PGPUSER'
- If rc == 0 Then
- Do
- If Open('user','PIPE:PGPUSER','R') Then
- Do
- userid = ReadLN('user')
- If ~Close('user') Then Nop
- cmdline = cmdline||' -u '||'"'||userid||'"'
- End
- Else
- Do
- Address porname
- Okay1 "Problem while opening PGPUSER environmental variable"||lf||,
- "Fatal error, macro execution aborted."
- Call quit
- End
- End
-
- address value portname
- cmdline = cmd||cmdline
- okay2 "Do you want the text you sign to be readable"||lf,
- ||"after signing ( +clearsig=on ) ?"
- If result = 1 Then cmdline = cmdline||' +clearsig=on'
- If pgpt = 1 Then /* is PGP26_IMPERSONATE option avaliable ? */
- Do
- okay2 "Do you want the encrypted packet to be"||lf,
- "in PGP 2.6 format ?"
- If result = 1 Then
- Do
- okay1 "WARNING: Packet created with this"||lf,
- ||"option set cannot be processed"||lf,
- ||"using 'standard' PGP 2.3a."||lf||lf,
- ||"You SHOULD NOT use this option"
- okay2 "Are you sure you want to use"||lf,
- ||"this option ?"
- If result = 1 Then cmdline = cmdline||' +PGP26_IMPERSONATE=on'
- End
- End
- cut block
- If result = 1 Then Call sign
- Else
- Do
- okay2 "No area selected."||lf||"Sign whole file ?"
- If result = 1 Then
- Do
- 'beg of file'
- 'mark block'
- 'end of file'
- 'cut block'
- Call sign
- End
- End
- Call quit
-
- sign:
- menu 0 6 0 tempfile /* save block to file */
- Address Command
- 'PGP '||cmdline
- If rc == 0 Then
- Do
- If Exists(tempfile||'.asc') Then
- Do
- If Open('outf',tempfile||'.asc','R') Then
- Do /* we check if the file has length 0 what happens if PGP in -f mode encountered wrong password */
- If Seek('outf',100,'Begin') = 0 Then Call wrongpass
- Else
- Do
- address value portname
- include file tempfile||'.asc'
- status 21
- End
- End
- End
- Else Call wrongpass
- End
- Else Call wrongpass
- Return
-
- wrongpass:
- address value portname
- undo
- okay1 "Wrong passphrase !"
-
- quit:
- Address Command
- If Exists(tempfile||'.info') Then 'Delete '||tempfile||'.info QUIET'
- If Exists(tempfile||'.asc') Then 'Delete '||tempfile||'.asc QUIET'
- If Exists(tempfile) Then 'Delete '||tempfile||' QUIET'
- If scratch == 1 Then 'Delete env:PGPPASS QUIET'
- If Close('STDOUT') Then Nop
- Exit 0
-
- ask: Procedure Expose scratch lf portname
- Address Command
- 'GetEnv >NIL: PGPPASS'
- If rc ~= 0 Then
- Do
- address value portname
- 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,'T')
- Address Command
- 'SetEnv PGPPASS '||'"'||pgppass||'"'
- End
- Return
-
- checkf: Procedure
- Address Command
- Call getpath
- path = result
- If path = "" Then Return 0
- Else
- Do
- 'Version >PIPE:PGPVERSION '||path
- If Open('pvers','PIPE:PGPVERSION','R') Then
- Do
- verstring = ReadLN('pvers')
- If Close('pvers') Then Nop
- End
- Parse Var verstring . version
- Select
- When version = '2.6ui' Then Return 2
- When version = '2.3a.5' Then Return 1
- When version = '2.3a.4' Then Return 1
- When version = '2.3a.3' Then Return 1
- Otherwise Return 0
- End
- End
-
- getpath: procedure
- 'Which >PIPE:PGPPATH PGP'
- If rc = 0 Then
- Do
- If Open('ppath','PIPE:PGPPATH','R') Then
- Do
- path = ReadLN('ppath')
- If ~Close('ppath') Then Nop
- Return path
- End
- End
- Else
- Do
- 'GetEnv >PIPE:PGPPATH PGPPATH'
- If rc = 0 Then
- Do
- If Open('ppath','PIPE:PGPPATH','R') Then
- Do
- path = ReadLN('ppath')
- If ~Close('ppath') Then Nop
- path = path||'/PGP'
- Return path
- End
- Else Return ""
- End
- End
-