|
|
1.1 ! root 1: Newsgroups: alt.security.pgp ! 2: From: [email protected] (Michael P. Frank) ! 3: Subject: Here's a simple Emacs interface to PGP 2.1. (w. bug fix) ! 4: Organization: MIT Laboratory for Computer Science ! 5: Distribution: alt ! 6: Date: Tue, 2 Mar 1993 23:14:16 GMT ! 7: ! 8: (This supersedes an earlier posting that had inconsistent function names ! 9: due to some last-minute changes.) ! 10: ! 11: Hi, PGP fans. ! 12: ! 13: Below are some new emacs commands I wrote, for using PGP 2.1 to easily ! 14: encrypt/decrypt/sign/verify regions of text under GNU emacs. Perhaps ! 15: this has already been done, but I haven't seen it anywhere. ! 16: ! 17: To use a command, select a region of text to manipulate, then execute ! 18: the command. The region of text will be passed as input to pgp with ! 19: the appropriate options, and pgp's output will appear in its place. ! 20: (Unwanted parts of this output, such as PGP status information, can ! 21: usually be easily deleted by hand.) If you make a mistake you can ! 22: always undo the operation (with C-_, C-x u, or M-x undo). If you ! 23: precede a command with C-u, the output will go to a separate emacs ! 24: window instead of replacing the input text. ! 25: ! 26: A quick summary: ! 27: ! 28: Key Command name Notes ! 29: ------- ------------------ ---------------- ! 30: C-c p e pgp-encrypt-region Prompts for recipient's ID. ! 31: C-c p d pgp-decrypt-region The first time, prompts for your pass phrase. ! 32: C-c p s pgp-sign-region Ditto. Uses CLEARSIG. ! 33: C-c p S pgp-sign-and-encrypt-region Doesn't use CLEARSIG. Encrypts also. ! 34: C-c p v pgp-verify-region Checks signature (in a new window). ! 35: C-c p p pgp-set-passphrase Sets or changes PGP pass phrase. ! 36: C-c p c pgp-clear-passphrase Erases pass phrase. ! 37: ! 38: Thanks are due to Bob Anderson <[email protected]> for ! 39: writing a very helpful explanation of how to do the guts of these ! 40: commands. However, any bugs are my own. ! 41: ! 42: Enjoy! ! 43: ! 44: -Mike ! 45: ! 46: ---------------- program starts here --------------- ! 47: ;;; ! 48: ;;; Emacs Support for PGP ! 49: ;;; ! 50: ;;; People can see your PGP passphrase if: ! 51: ;;; * They watch over your shoulder as you type it. (It's not invisible.) ! 52: ;;; * They do "ps auxww" (SunOS) on your machine while you're ! 53: ;;; decrypting/signing. ! 54: ;;; * They type C-h v *pgp-passphrase* in your emacs after you've ! 55: ;;; entered your passphrase. ! 56: ;;; ! 57: ;;; Plus the system suffers from all the normal Unix and X-windows ! 58: ;;; security holes. ! 59: ;;; ! 60: ! 61: (defun pgp-set-passphrase (arg) ! 62: "Prompts for PGP pass phrase." ! 63: (interactive "sPGP pass phrase: ") ! 64: (setq *pgp-passphrase* arg)) ! 65: ! 66: (defun pgp-clear-passphrase () ! 67: "Clears the PGP pass phrase." ! 68: (interactive) ! 69: (makunbound *pgp-passphrase*)) ! 70: ! 71: (defun pgp-encrypt-region (start end pgp-user-id &optional flag) ! 72: "Encrypt the region using PGP. Prompts for a PGP user ID. ! 73: With prefix arg, puts result in serparate window. ! 74: Noninteractive args are START, END, PGP-USER-ID, and optional FLAG." ! 75: (interactive "r\nsUser ID to encrypt to: \nP") ! 76: (shell-command-on-region start end (concat "pgp -fea " pgp-user-id) ! 77: (not flag))) ! 78: ! 79: (defun pgp-decrypt-region (start end &optional flag) ! 80: "Decrypt the region using PGP. Prompts for the user's pass phrase, ! 81: if not already known. With prefix arg, puts result in separate window. ! 82: Noninteractive args are START and END and optional FLAG." ! 83: (interactive "r\nP") ! 84: (if (not (boundp '*pgp-passphrase*)) ! 85: (call-interactively 'pgp-set-passphrase)) ! 86: (shell-command-on-region start end ! 87: (concat "pgp -f -z \"" *pgp-passphrase* ! 88: "\"") ! 89: (not flag))) ! 90: ! 91: (defun pgp-sign-and-encrypt-region (start end pgp-user-id &optional flag) ! 92: "Sign and encrypt the region using PGP. Prompts for a user to ! 93: encrypt to and a pass phrase, if not already known. ! 94: With prefix arg puts result in separate window. ! 95: Noninteractive args are START, END, and PGP-USER-ID, and optional FLAG." ! 96: (interactive "r\nsUser ID to encrypt to: \nP") ! 97: (if (not (boundp '*pgp-passphrase*)) ! 98: (call-interactively 'pgp-set-passphrase)) ! 99: (shell-command-on-region start end (concat "pgp -safe " pgp-user-id ! 100: " -z \"" *pgp-passphrase* ! 101: "\"") (not flag))) ! 102: ! 103: (defun pgp-sign-region (start end &optional flag) ! 104: "Sign the region using PGP. Prompts for a pass phrase, if not already ! 105: Known. With prefix arg puts result in separate window. ! 106: Noninteractive args are START and END and optional FLAG." ! 107: (interactive "r\nP") ! 108: (if (not (boundp '*pgp-passphrase*)) ! 109: (call-interactively 'pgp-set-passphrase)) ! 110: (shell-command-on-region start end (concat "pgp -saft +clearsig=on" ! 111: " -z \"" *pgp-passphrase* "\"") ! 112: (not flag))) ! 113: ! 114: (defun pgp-verify-region (start end) ! 115: "Verify the signature on the text in the given region using PGP." ! 116: (interactive "r") ! 117: (shell-command-on-region start end "pgp -f")) ! 118: ! 119: (global-set-key "\C-cpp" 'pgp-set-passphrase) ! 120: (global-set-key "\C-cpc" 'pgp-clear-passphrase) ! 121: (global-set-key "\C-cpe" 'pgp-encrypt-region) ! 122: (global-set-key "\C-cpd" 'pgp-decrypt-region) ! 123: (global-set-key "\C-cps" 'pgp-sign-region) ! 124: (global-set-key "\C-cpS" 'pgp-sign-and-encrypt-region) ! 125: (global-set-key "\C-cpv" 'pgp-verify-region) ! 126: -- ! 127: , , __ MIT Lab for Computer Science ! 128: /|/| . _ |_ _ _ | |_ _ _ ,_ |, [email protected] ! 129: / | | | (_ | | (_| (-' | | | (_| | | |\ (Finger for PGP Public Key)
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.