1997-11-03 - the one Unbreakable crypto scheme.

Header Data

From: bureau42 Anonymous Remailer <nobody@bureau42.ml.org>
To: cypherpunks@cyberpass.net
Message Hash: d7117c68abc7d391b74bbc274f0b8bf6988c2bdf3f98c47e8dfc1989f30bc3da
Message ID: <II3U8FPHjnZhca9XSBZfUg==@bureau42.ml.org>
Reply To: N/A
UTC Datetime: 1997-11-03 07:53:03 UTC
Raw Date: Mon, 3 Nov 1997 15:53:03 +0800

Raw message

From: bureau42 Anonymous Remailer <nobody@bureau42.ml.org>
Date: Mon, 3 Nov 1997 15:53:03 +0800
To: cypherpunks@cyberpass.net
Subject: the one Unbreakable crypto scheme.
Message-ID: <II3U8FPHjnZhca9XSBZfUg==@bureau42.ml.org>
MIME-Version: 1.0
Content-Type: text/plain



/* Generic xor handler.

   With no args, xors stdin against 0xFF to stdout.  A single argument is a
   file to read xor-bytes out of.  Any zero in the xor-bytes array is treated
   as the end; if you need to xor against a string that *includes* zeros,
   you're on your own.

   *Hobbit*, 960208 */

#include <stdio.h>
#include <fcntl.h>

char buf[8192];
char bytes[256];
char * py;

/* do the xor, in place.  Uses global ptr "py" to maintain "bytes" state */
xorb (buf, len)
  char * buf;
  int len;
{
  register int x;
  register char * pb;

  pb = buf;
  x = len;
  while (x > 0) {
    *pb = (*pb ^ *py);
    pb++;
    py++;
    if (! *py)
      py = bytes;
    x--;
  }
} /* xorb */

/* blah */
main (argc, argv)
  int argc;
  char ** argv;
{
  register int x = 0;
  register int y;

/* manually preload; xor-with-0xFF is all too common */
  memset (bytes, 0, sizeof (bytes));
  bytes[0] = 0xff;

/* if file named in any arg, reload from that */
#ifdef O_BINARY				/* DOS shit... */
  x = setmode (0, O_BINARY);		/* make stdin raw */
  if (x < 0) {
    fprintf (stderr, "stdin binary setmode oops: %d\n", x);
    exit (1);
  }
  x = setmode (1, O_BINARY);		/* make stdout raw */
  if (x < 0) {
    fprintf (stderr, "stdout binary setmode oops: %d\n", x);
    exit (1);
  }
#endif /* O_BINARY */
  
  if (argv[1])
#ifdef O_BINARY
    x = open (argv[1], O_RDONLY | O_BINARY);
#else
    x = open (argv[1], O_RDONLY);
#endif
  if (x > 0) {
    read (x, bytes, 250);		/* nothin' fancy here */
    close (x);
  }
  py = bytes;
  x = 1;
  while (x > 0) {
    x = read (0, buf, sizeof (buf));
    if (x <= 0)
      break;
    xorb (buf, x);
    y = write (1, buf, x);
    if (y <= 0)
      exit (1);
  }
  exit (0);
}







Thread