Anonymous Encrypted Remailer Interface for Emacs

michael shiplett michael.shiplett at
Fri Mar 4 03:57:01 PST 1994


  I finally wrote some code. This interface automates the wrapping of
messages for use with the encrypted anonymous remailers--provided
you're willing to enter into Emacs for the wrapping.

  I've sent & received several messages using it. Please let me know
if you find any problems.


;;; anon-remail.el v1.0, anonymous remailer interface
;;; written by michael shiplett <walrus at>
;;; Any comments or suggestions welcomed.

;;; License

;;; No implied or expressed warranty nor any other guarantee.
;;; Do what you want with this.

;;; Anonymous Encrypted Remailer Interface

;;; Usage:

;;; You must set ar-remailer-list to a list of anonymous
;;; remailer addresses. These must be in a valid mail ``To:''
;;; format. The initial recipients address must also be in a valid
;;; ``To:'' format; addresses depending on alias files will not
;;; work because your mail program (MH, Elm, mail, etc.) will
;;; not get a chance to process them before the message is wrapped.

;;; After writing your message, invoke ar-wrap-message. If you
;;; wish to sign the message, you should only sign the first
;;; wrapping.

;;; After the message has been wrapped, a list will appear in
;;; the minibuffer--this is the route the message will take.

;;; This package requires that you have mailcrypt configured
;;; for use with pgp (unless you send to ripem remailers).

;;; To Do:

;;; Modify mc-encrypt to take a boolean argument for
;;; signing the message.

;;; Allow for different remailer lists based on whether
;;; the transit delay one wants, e.g., fast, normal, or slow.

(require 'mailcrypt)

;; User Variables

(defvar ar-remailer-list nil "*List of remailers from which to choose.")
(defvar ar-hops 3 "*Number of remailers among which to pass message.")

;; Hooks

(defvar ar-start-hook nil)

;; Functions

(defun ar-wrap-message (&optional hops)
  "*Wrap the current message for a person and then wrap it for
HOPS remailers. If HOPS is nil, use the value of `ar-hops'."
  (interactive "P")
  (run-hooks 'ar-start-hook)
  (let ((remailer-path (list (mail-fetch-field "to" nil t))))
    (if (not hops)
	(setq hops ar-hops))
    (while (< 0 hops)
      (let ((remailer (ar-choose-remailer)))
	;; `remailer-path' is to prevent us
	;; from sending to the same remailer twice
	;; in a row.
	;; It gives the path the message will take
	;; beginning with `(car remailer-path)'
	(while (string= remailer (car remailer-path))
	  (setq remailer (ar-choose-remailer)))
	(setq remailer-path (cons remailer remailer-path))
	(ar-wrap-for-remailer remailer)
	(setq hops (1- hops))))
    (message "%s" remailer-path)))

(defun ar-choose-remailer ()
  "*Select a random remailer from `ar-remailer-list'."
  (let (number-of-remailers remailer)
    ;; Choose a remailer
    (setq number-of-remailers (length ar-remailer-list))
    (or number-of-remailers
	(error "No remailers!"))
    (nth (random number-of-remailers) ar-remailer-list)))

(defun ar-wrap-for-remailer (remailer)
  "*Wrap the current mail buffer for mailing to a specified remailer."
  (let (recipient)
    ;; Keep track of whom should receive the resent message
    (setq recipient (mail-fetch-field "to" nil t))

    ;; Add the magic redirection words
    (goto-char (point-min))
    (search-forward (concat "\n" mail-header-separator "\n"))
    (setq start (point))
    (insert "::\nRequest-Remailing-To: " recipient "\n\n")

    ;; Wrap the message for the remailer
    (mc-encrypt-message remailer nil)

    ;; Add in the final magic remailer incantation
    (goto-char start)
    (insert "::\nEncrypted: PGP\n\n")

    ;; Set the message to be sent to the remailer
    (ar-set-recipient remailer)

(defun ar-wrap-message-for-individual ()
  "*Does the initial wrap for a message not intended for a remailer"
  ;; Figure out to whom the message is currently intended
  (let (recipient)
    (setq recipient (mail-fetch-field "to" nil t))
    (mc-encrypt-message recipient nil)

(defun ar-set-recipient (recipient)
  "*Set the ``To:'' field of a message. This will not work on
a multi-line ``To:''."
  (or recipient
   (error "No recipient!"))

  (goto-char (point-min))
  (search-forward "To:")
  (let ((beg (point)))
    (delete-region beg (point)))
  (insert " " recipient))

(provide 'anon-remail)

More information about the cypherpunks-legacy mailing list