🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.privacy.anon-server
Article #235682

Re: Question about esubs

#235682
From: StealthMonger
Date: Tue, 10 Nov 2009 10:04
245 lines
8959 bytes
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Fritz Wuehler <fritz@spamexpire-200911.rodent.frell.theremailer.net>
writes:

>   I'm lost!  I'm lost!

Appended below is the man page and C code for esubbf.  esub is the
same except that it uses (patented) IDEA instead of Blowfish.

 -- StealthMonger
	 <StealthMonger@nym.mixmin.net>

 --
   stealthmail: Scripts to hide whether you're doing email, or when,
   or with whom.
         mailto:stealthsuite@nym.mixmin.net

Finger for key.

ESUBBF(1)

NAME
 esubbf, esubbft, esubbft-arthdr <-> compute or test an encrypted subject

SYNOPSIS
 esubbf key subject
 esubbft key subject esub
 esubbft-arthdr key subject

DESCRIPTION
 Compute or test a so-called "encrypted subject" for use in a news arti-
 cle posted on USENET newsgroup alt.anonymous.messages. This is random-
 looking 48-digit hexadecimal number which is supposed to be efficiently
 recognizable, but only with knowledge of the subject and key.

 These programs are intended for use in shell scripts and would rarely
 be used interactively from the keyboard.

 For all three programs, subject and key are the subject to encrypt and
 the key with which to encrypt it.

 esubbf computes and writes to stdout an encrypted subject using the
 given subject and key plus a crytographically-strong random number.

 esubbft tests the given encrypted subject esub and returns success code
 0 if esub could have resulted from the given subject and key, else it
 returns failure code 1.

 esubbft-arthdr is a simple script which applies esubbft to the content
 of the first Subject: line found on stdin. It is useful as a test in a
 procmail(1) script.

 The algorithm for computing an encrypted subject is identical with that
 of the "classic" esub (see HISTORY below) except that it uses Blowfish
 encryption instead of IDEA (which is patented). The 48-digit encrypted
 subject encodes a 64-bit random IV followed by the 128-bit result of
 encrypt(subject,key,IV). The intention is that it not be feasible to
 determine subject or key from esub, or to determine if two esubs could
 have resulted from the same subject and key.

HISTORY
 "Encrypt Subject" was discussed by Andy Dustman in 1997 on the remailer
 operators mailing list. He wrote that "it allows you to encrypt a hash
 of the subject using a secret key, thus making the subject appear to be
 a random-looking string of 48 hex digits which is different each time
 (due to IDEA-CFB encryption). It's intended for nym reply blocks which
 point to alt.anonymous.messages." By 1999 it had been incorporated by
 RProcess into the widely-used Reliable remailer. See
 http://www.skuz.net/potatoware/esubplug.html. An error in an early
 implementation was worked out on the remailer operators mailing list in
 dialogue between RProcess and Ulf in 1999. A noteworthy remark by Ulf
 at this time was "The idea of esub is that each message has a different
 Subject header and only the person with the key can check which ones
 belong together."

 Working from these sources, the present author ported the algorithm
 back to its original Unix platform in 2003 for use in pseudonym reply
 blocks to alt.anonymous.messages. The recent introduction of stealth-
 mail(7), a new application having no need to be interoperable, was a
 fine opportunity to break with the original patented IDEA implementa-
 tion. blowfish(3) was chosen as the replacement because of the avail-
 ability of BF_cfb64_encrypt(3), which is the mode of the original IDEA
 implementation.

SEE ALSO
 blowfish(3), procmail(1).

AUTHOR
 StealthMonger <StealthMonger@nym.alias.net>
 2005 June 14

#if 0/*
exec gcc -g -o `basename $0 .c` $0 -lcrypto -lc;*/
#endif
/* Note:  Because of the foregoing, an executable can be built
   simply by issuing the command ``sh esubbf.c'' to the shell.

SYNOPSIS
        esubbf <key> <subject>

DESCRIPTION

        Write to stdout the 48 digit hexadecimal code of a number
        derived according to the esubbf algorithm from the given <key>
        and <subject>.  Functions like mixmaster.ren1.c.t1_esub except
        that it uses Blowfish instead of IDEA, avoiding patent issues.
        The fields of the number can be pictured as follows:

                ______________________________________________
                |               |                             |
                |   random iv   |   encrypt(subject,key,iv)   |
                |    64 bits    |          128 bits           |
                |_______________|_____________________________|


        where "subject" and "key" refer to the 128-bit MD5 hashes of
        the given <key> and <subject>, and encryption is computed by
        BF_cfb64_encrypt(3).

SEE ALSO
        esubbft

*/

#include <stdio.h>
#include <stdlib.h>
#include <openssl/md5.h>
#include <openssl/blowfish.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

void print8(unsigned char id[])
{
  printf
    ("%02x%02x%02x%02x%02x%02x%02x%02x",
     id[0], id[1], id[2], id[3], id[4], id[5], id[6], id[7]);
}

int main(int argc, char **argv)
{
  BF_KEY ks;
  int n=0, randfd;
  char keyd[16], subd[16], tsvd[16], iv[8];
  if ( argc != 3 ) return 1;
  MD5(argv[1],strlen(argv[1]),keyd);
  BF_set_key(&ks, 16, keyd);
  MD5(argv[2],strlen(argv[2]),subd);
#if defined(__linux__)
  randfd = open("/dev/urandom", O_RDONLY);
#elif defined (__OpenBSD__)
  randfd = open("/dev/srandom", O_RDONLY);
#else
  /* FIXME */
  equivalent_for_your_architecture;
#endif
  read(randfd, iv, 8);
  print8(iv);
  BF_cfb64_encrypt(subd, tsvd, 16, &ks, iv, &n, BF_ENCRYPT);
  print8(tsvd);
  print8(&tsvd[8]);
  return 0;
}

#if 0/*
exec gcc -g -o `basename $0 .c` $0 -lcrypto -lc;*/
#endif
/* Note:  Because of the foregoing, an executable can be built
   simply by issuing the command ``sh esubbft.c'' to the shell.

SYNOPSIS
        esubbft <key> <subject> <test>

DESCRIPTION
        Return 0 if <test> might have been the result of running
        "esubbf <key> <subject>", else 1.  A succinct statement of the
        functionality is that

          esubbft <key> <subject> $(esubbf <key> <subject>) ; echo $?

        gives 0.

SEE ALSO
        esubbf

*/

#include <stdio.h>
#include <stdlib.h>
#include <openssl/md5.h>
#include <openssl/blowfish.h>


int scanbytes(const char* buf, unsigned char* bytes, const int count)
{
  int i;
  char s[]="0xxx" , *eptr;

  for (i = 0; i < count; i++) {
    s[2] = *(buf + 2*i) ;
    s[3] = *(buf + 2*i + 1) ;
    eptr = &s[0];
    *(bytes + i) = (unsigned char) strtol(s, &eptr, 16);
    if ( eptr == &s[0] ) return 1;
  };
  return 0;
}

int main(int argc, char **argv)
{
  BF_KEY ks;
  int n=0;
  char keyd[16], subd[16], tsu[24], tsvd[16];
  if ( argc != 4 || strlen(argv[3]) != 48 ) return 1;
  if ( scanbytes(argv[3],tsu,24)) return 1;
  MD5(argv[1],strlen(argv[1]),keyd);
  BF_set_key(&ks, 16, keyd);
  BF_cfb64_encrypt(&tsu[8], tsvd, 16, &ks, tsu, &n, BF_DECRYPT);
  MD5(argv[2],strlen(argv[2]),subd);
  return (memcmp(subd, tsvd, 16) == 0 ? 0 : 1);
}

#!/bin/sh

# SYNOPSIS
#          esubbft-arthdr key sub

# DESCRIPTION
#          Returns the result of calling esubbft key sub test, where
#          test is a ^Subject: field found on standard input.  Useful
#          as a procmail test when fed the header of a candidate
#          article.
esubbft $1 $2 $(sed -n 's/^Subject: //Ip')

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8+ <http://mailcrypt.sourceforge.net/>

iD8DBQFK9Md5DkU5rhlDCl4RAv04AJ4t7SaMjCWzM2Vio2gBnWlG6NZdzgCfde+d
CD5Ma9XmBKpzoVJVNI8BiDY=
=SRVT
-----END PGP SIGNATURE-----
Technical Details
Message-ID: <20091110100401.DB1718147E@fleegle.mixmin.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-alt.privacy.anon-server.20141023.mbox.gz!num1.nntp.dca.giganews.com!number.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.84.MISMATCH!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!news.wiretrip.org!news.dizum.com!sewer-output!mail2news
References: <slrnhf6elo.69o.admin@fleegle.mixmin.net> <4b00ff910e596ca6b53d26a5a83fa8da@msgid.frell.theremailer.net>

Show Full Headers
Complete Article Headers
Message-ID: <20091110100401.DB1718147E@fleegle.mixmin.net>
Subject: Re: Question about esubs
Date: Tue, 10 Nov 2009 10:04:01 +0000
From: StealthMonger <Use-Author-Supplied-Address-Header@[127.1]>
References: <slrnhf6elo.69o.admin@fleegle.mixmin.net> <4b00ff910e596ca6b53d26a5a83fa8da@msgid.frell.theremailer.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-alt.privacy.anon-server.20141023.mbox.gz!num1.nntp.dca.giganews.com!number.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.84.MISMATCH!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!news.wiretrip.org!news.dizum.com!sewer-output!mail2news
Author-Supplied-Address: StealthMonger <AT> nym <DOT> mixmin <DOT> net
Newsgroups: alt.privacy.anon-server
Mail-To-News-Contact: abuse@dizum.com
Organization: mail2news@dizum.com
Lines: 245