Cryptography-Digest Digest #553, Volume #11 Sat, 15 Apr 00 15:13:01 EDT
Contents:
Re: ? Backdoor in Microsoft web server ? (Jim Gillogly)
Re: PGP for Linux as secure as Windows? ([EMAIL PROTECTED])
Re: CLOSE Encryption (Tom St Denis)
Re: The use of Three DES (zapzing)
Re: General principles of design (zapzing)
Classical Crypto Books (CryptoBook)
Why is this algorithm insecure? (Newbie flamefodder) (Richard Heathfield)
Re: new Echelon article (JimD)
----------------------------------------------------------------------------
From: Jim Gillogly <[EMAIL PROTECTED]>
Subject: Re: ? Backdoor in Microsoft web server ?
Date: Sat, 15 Apr 2000 17:26:24 +0000
David A Molnar wrote:
>
> Mok-Kong Shen <[EMAIL PROTECTED]> wrote:
> > in the original UNIX code (cf. ACM award lecture) without being
> > detected, it shouldn't surprise that software not written by
> > oneself may have backdoors.
>
> He never actually admitted to placing the backdoor in login...he simply
> described in great detail how one would go about doing it.
You're both mistaken. Thompson's paper described placing the back door
to login in a separate version of the Unix C compiler, not in the original
code nor in any shipping version of it. Thompson confirmed later that he
did indeed perform this experiment, and it spread to another in-house lab
before he blew the gaffe -- it was not merely theoretical. His exposition
has been posted here before.
--
Jim Gillogly
Trewesday, 25 Astron S.R. 2000, 17:14
12.19.7.2.5, 10 Chicchan 8 Pop, Ninth Lord of Night
------------------------------
From: [EMAIL PROTECTED]
Subject: Re: PGP for Linux as secure as Windows?
Crossposted-To: alt.security.pgp,comp.security.pgp.discuss
Date: Sat, 15 Apr 2000 17:38:54 GMT
In sci.crypt none <[EMAIL PROTECTED]> wrote:
> Do the memory protection features work under linux?
> Clearly, the secure viewer does not have the fonts needed to attempt to
> emulate the Windows Secure viewer option, but is there any protection
> against the data going into a Swap file?
GNUPG will lock pages in memory if it's installed suid, so that's an
option for you if PGP doesn't.
--
Matt Gauthier <[EMAIL PROTECTED]>
------------------------------
From: Tom St Denis <[EMAIL PROTECTED]>
Subject: Re: CLOSE Encryption
Date: Sat, 15 Apr 2000 17:44:36 GMT
[EMAIL PROTECTED] wrote:
>
> In article <ABNJ4.80$rv6.5063@news1-hme0>,
> "MeneLaus" <[EMAIL PROTECTED]> wrote:
> > CLOSE is a new algorithm written by Chaos Legion,
> > Thanks, i'll return the favour some day if you ever need something
> testing.
> >
> > MeneLaus
>
> Sir,
>
> The CLOSE algorithm is not secure. Essentially, the alogorithm XOR each
> byte of the plain text with multiple key bytes. No non-linear steps are
> involved and no diffision among bytes is accomplished. It appears that
> one know plain text will reveal a decryption key, by plain XOR cipher =
> encryption key.
>
> A few suggestions, first if you want real security use a well known
> algorithm. If you are just having fun then ...
>
> Add a non linear step like an s-box substistution or a modular mult, see
> the IDEA cipher for mod mult.
>
> Instead of rotating by eight bits each round rotate by 11. After
> several (6?) rounds, each bit will influence each output byte.
Or rotate by any odd constant.
> Add a post whitening step similiar to your pre whitening.
>
> By steps as in your diagram
>
> 1 Split the 64 bit into 8 seperate blocks
>
> 2 XOR a key byte with each block
>
> 3 Substitute each block with the Rijndael s-box byte
Or any non-linear/high avalanche sbox, such as the one from SAFER, which
is essentially 45^x mod 257...
> 4 Rotate the 8 blocks by 11 (13,17,etc) bits in a circular left manor
You cannot rotate a octet 'byte' by 11 bits, that's the same as rotating
it by 3 bits. I think you meant to say rotate the entire block by 11
bits. Or better yet rotate by 2r + 1, where 'r' = round number, so each
round is slightly diff.
> 5 XOR a key byte with each block
>
> 6 loop to step 3
This is very similar to Safer, but I doubt it shares the avalanche
properties. As a result you will need many more rounds.
> This reminds me of the GOST algorithm. GOST has 32 rounds. GOST uses
> 4-bit s-boxes that are secret.
GOST does not seperate into 8 bytes, it does it into 2 32-bit words like
DES. And the sboxes need not be secret, as long as they are strong
[non-linear permutation of the input]. Of course GOST can be sped up to
if you turn the fixed sbox into a 4kb lut.
Tom
------------------------------
From: zapzing <[EMAIL PROTECTED]>
Subject: Re: The use of Three DES
Date: Sat, 15 Apr 2000 17:38:45 GMT
It sounds very similar to the VHS/Beta battle
of lo so many years ago. While Beta was
technically superior, it was defeated by
VHS because of more agressive advertizing,
and eventually noone would buy Beta because
it was "nonstandard". In fact, "beta" actually
was used as a transitive term to describe the
process. I think we could say that DES "betaed"
(sp?) RC5.
--
Do as thou thinkest best.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
From: zapzing <[EMAIL PROTECTED]>
Subject: Re: General principles of design
Date: Sat, 15 Apr 2000 17:49:43 GMT
In article <8d04ge$3u1$[EMAIL PROTECTED]>,
"almis" <[EMAIL PROTECTED]> wrote:
> Hmmmmm..... OK
>
> However; your concept seems to be in conflict with a cryptographic
> maxim that states (something like) '...That which cannot be hidden
deeply,
> should not be hidden at all...'
>
>
And that crypto maxim contradicts a
well known military maxim, "information
will be given out on a need to know basis"
--
Do as thou thinkest best.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
From: [EMAIL PROTECTED] (CryptoBook)
Subject: Classical Crypto Books
Date: 15 Apr 2000 18:05:32 GMT
Classical Crypto Books is pleased to announce the following recent additions
and updates to the CCB catalog.
RECENTLY PUBLISHED
CRYPTORUNES: Codes and Secret Writing
by Clifford A. Pickover
SB, Pomegranate, 104 pp.
Nonmember $13.95, Member $11.95
GENERAL SOLUTION OF THE ADFGVX CIPHER SYSTEM: Technical Paper of the Signal
Intelligence Section, War Plans and Training Division
by J. Rives Childs, Alan G. Konheim
SB, Aegean Park Press C-88, 250 pp.
Nonmember $36.80, Member $29.45
ICSA GUIDE TO CRYPTOGRAPHY
by Randall K. Nichols
Includes a CDROM. Published at $70.00.
SB, McGraw-Hill, 880 pp.
Nonmember $63.95, Member $56.95
DEFENDING YOUR DIGITAL ASSETS: Against Hackers, Crackers, Spies, and Thieves
by Randall K. Nichols, Daniel J. Ryan, Julie J.H.C. Ryan
Published at $49.99.
SB, RSA Press, 894 pp.
Nonmember $44.95, Member $39.95
HACKING EXPOSED: Network Security Secrets and Solutions
by Stuart McClure, Joel Scambray, George Kurtz
Published at $39.99.
SB, Osborne, 512 pp.
Nonmember $35.95, Member $31.95
THE MATHEMATICS OF CIPHERS: Number Theory and RSA Cryptography
by S. C. Coutinho
HB, MIT Press, 212 pp.
Nonmember $34.95, Member $29.95
ANCIENT SCRIPTS
EGYPTIAN HIEROGLYPHS FOR EVERYONE: An Introduction to the Writing of Ancient
Egypt
by Joseph Scott, Lenore Scott
HB, Barnes & Noble Books, 96 pp.
Nonmember $7.95, Member $6.95
CLASSICAL CRYPTO
CRYPTANALYSIS OF AN ENCIPHERED CODE PROBLEM: Where an "Additive" Method of
Encipherment Has Been Used
by Wayne G. Barker
SB, Aegean Park Press C-26, 182 pp.
Nonmember $26.80, Member $21.45
HISTORY OF THE USE OF CODES
by William F. Friedman
Called "superb" by David Kahn, this report was written in the 1920s when Mr.
Friedman was a Major in the Signal Corps Reserve. Defines terms; discusses
two-letter differential, five-letter groups, origin of codes, use with
telegraph, and dictionary codes.
SB, Aegean Park Press C-12, 84 pp.
Nonmember $20.80, Member $16.65
SIX LECTURES CONCERNING CRYPTOGRAPHY AND CRYPTANALYSIS
by William F. Friedman
SB, Aegean Park Press C-67, 253 pp.
Nonmember $34.80, Member $27.85
THE INDEX OF COINCIDENCE AND ITS APPLICATION IN CRYPTANALYSIS
by William F. Friedman
SB, Aegean Park Press C-49, 99 pp.
Nonmember $24.80, Member $19.85
CRYPTANALYSIS: A Study of Ciphers and Their Solution
by Helen Fouche Gaines
A BEST BUY! Originally published in 1939 by Piccola with the aid of, and for
the benefit of other ACA members. Has become know as the "bible" of the ACA. If
you want to learn how to solve the ciphers used
by the ACA, you must read this book.
SB, Dover Publications, 245 pp.
Nonmember $7.95, Member $6.95
COURSE IN CRYPTOGRAPHY: Translated from the Original "Cours de Cryptographie"
by General Marcel Givierge
SB, Aegean Park Press C-19, 172 pp.
Nonmember $26.80, Member $21.45
TREATISE ON CRYPTOGRAPHY: An English Translation of the Original
"Traite de Cryptographie"
by Andre Lange, E.-A. Soudart
SB, Aegean Park Press C-36, 184 pp.
Nonmember $26.80, Member $21.45
ELEMENTARY CRYPTOGRAPHY AND CRYPTANALYSIS
by Donald D. Millikin
SB, Aegean Park Press C-56, 142 pp.
Nonmember $22.80, Member $18.25
ELEMENTARY CRYPTANALYSIS: A Mathematical Approach
by Abraham Sinkov
SB, Mathematical Association of America, 232 pp.
Nonmember $23.95, Member $21.95
CLASSICAL CRYPTOGRAPHY COURSE
CLASSICAL CRYPTOGRAPHY COURSE, VOLUME I
by Randall K. Nichols
Written by a past president of the American Cryptogram Association; based on an
enormously successful Internet course taken by 390 students worldwide. Contains
updated and corrected versions of the first ten lectures.
SB, Aegean Park Press C-74, 313 pp.
Nonmember $36.80, Member $29.45
CLASSICAL CRYPTOGRAPHY COURSE, VOLUME II
by Randall K. Nichols
Continuation of the author's highly acclaimed course; contains updated and
corrected versions of lectures 11 through 22. Includes a glossary, a
comprehensive bibliography, and an annotated list of World Wide Web resources.
SB, Aegean Park Press C-76, 466 pp.
Nonmember $42.80, Member $34.25
COURSE IN CRYPTANALYSIS
A COURSE IN CRYPTANALYSIS, VOLUME I, EXPLANATORY TEXT AND SHORT EXERCISES: S.
I. Course, Revised and Enlarged, June, 1942
by Anonymous, British War Office
SB, Aegean Park Press C-33, 74 pp.
Nonmember $18.80, Member $15.05
A COURSE IN CRYPTANALYSIS, VOLUME II, FIGURES AND CIPHER TEXTS: S. I. Course,
Revised and Enlarged, June, 1942
by Anonymous, British War Office
SB, Aegean Park Press C-34, 73 pp.
Nonmember $18.80, Member $15.05
DEFECTION OF IGOR GOUZENKO
THE DEFECTION OF IGOR GOUZENKO, VOLUME 1
by Anonymous, Royal Commision (Canada)
SB, Aegean Park Press I-4, 98 pp.
Nonmember $16.80, Member $13.45
THE DEFECTION OF IGOR GOUZENKO, VOLUME 2
by Anonymous, Royal Commision (Canada)
SB, Aegean Park Press I-5, 197 pp.
Nonmember $16.80, Member $13.45
THE DEFECTION OF IGOR GOUZENKO, VOLUME 3
by Anonymous, Royal Commision (Canada)
SB, Aegean Park Press I-6, 98 pp.
Nonmember $16.80, Member $13.45
ESPIONAGE AND INTELLIGENCE
INTELLIGENCE AND CRYPTANALYTIC ACTIVITIES OF THE JAPANESE DURING WORLD WAR II:
SRH 254, The Japanese Intelligence System, MIS/WDGS
by J. W. Bennett, W. A. Hobert, J. B. Spitzer
SB, Aegean Park Press I-7, 145 pp.
Nonmember $28.80, Member $23.05
SECRET AND SANCTIONED: Covert Operations and the American Presidency
by Stephen Knott
Published at $30.00.
HB, Oxford University Press, 268 pp.
Nonmember $27.95, Member $23.95
THE TAO OF SPYCRAFT: Intelligence Theory and Practice in Traditional China
by Ralph D. Sawyer, Mei-chun Lee Sawyer
Published at $35.00.
HB, Westview Press, 635 pp.
Nonmember $31.95, Member $28.95
FOREIGN LANGUAGE
CRYPTOGRAMS IN SPANISH: Plus Spanish-Letter Frequency Data
by Wayne G. Barker
SB, Aegean Park Press M-9, 128 pp.
Nonmember $4.95, Member $3.95
CRYPTOGRAMS IN PORTUGUESE: Plus Portuguese-Letter Frequency Data
by Stewart Todd
SB, Aegean Park Press M-11, 128 pp.
Nonmember $4.95, Member $3.95
HISTORY
THE ORIGIN AND DEVELOPMENT OF THE ARMY SECURITY AGENCY: 1917-1947
by Anonymous, Army Security Agency
SB, Aegean Park Press C-16, 61 pp.
Nonmember $12.80, Member $10.25
THE ORIGIN AND DEVELOPMENT OF THE NATIONAL SECURITY AGENCY: Includes
General George C. Marshall's "Eyes-Only" Top Secret Letter to Thomas E. Dewey
during the 1944 Presidential Campaign
by George A. Brownell
SB, Aegean Park Press C-35, 108 pp.
Nonmember $20.80, Member $16.65
SECRET CIPHERS OF THE 1876 PRESIDENTIAL ELECTIONS
by D. Beaird Glover
SB, Aegean Park Press C-57, 150 pp.
Nonmember $26.80, Member $21.45
THE CONTRIBUTION OF THE CRYPTOGRAPHIC BUREAUS IN THE WORLD WAR: Translated
from the Original "Chifferbyraernas Insatser I Varldskriget Till Lands"
by Yves Gylden
SB, Aegean Park Press C-18, 95 pp.
Nonmember $20.80, Member $16.65
SEIZING THE ENIGMA: The Race to Break the German U-Boat Codes 1939-1943
by David Kahn
HB, Barnes & Noble Books, 350 pp.
Nonmember $11.95, Member $10.95
HISTORY OF CODES AND CIPHERS IN THE UNITED STATES
THE HISTORY OF CODES AND CIPHERS IN THE UNITED STATES DURING THE PERIOD
BETWEEN THE WORLD WARS, PART I. 1919-1929
by Wayne G. Barker (Editor)
SB, Aegean Park Press C-22, 192 pp.
Nonmember $26.80, Member $21.45
THE HISTORY OF CODES AND CIPHERS IN THE UNITED STATES DURING THE PERIOD
BETWEEN THE WORLD WARS, PART II. 1930-1939
by Wayne G. Barker (Editor)
SB, Aegean Park Press C-54, 107 pp.
Nonmember $26.80, Member $21.45
THE HISTORY OF CODES AND CIPHERS IN THE UNITED STATES DURING WORLD WAR I
by Wayne G. Barker (Editor)
SB, Aegean Park Press C-21, 269 pp.
Nonmember $26.80, Member $21.45
THE HISTORY OF CODES AND CIPHERS IN THE UNITED STATES PRIOR TO WORLD WAR I
by Wayne G. Barker (Editor)
SB, Aegean Park Press C-20, 169 pp.
Nonmember $26.80, Member $21.45
MILITARY CRYPTANALYSIS SET
MILITARY CRYPTANALYSIS PART I: With New Added Problems for the Student
by William F. Friedman
SB, Aegean Park Press C-30, 155 pp.
Nonmember $28.80, Member $23.05
MILITARY CRYPTANALYSIS PART II: With Added Problems and Computer Programs
by William F. Friedman
SB, Aegean Park Press C-40, 164 pp.
Nonmember $28.80, Member $23.05
MILITARY CRYPTANALYSIS PART III: Simpler Varieties of Aperiodic Substitution
Systems
by William F. Friedman
SB, Aegean Park Press C-60, 123 pp.
Nonmember $32.80, Member $26.25
MILITARY CRYPTANALYSIS PART IV: Transposition and Fractionating Systems
by William F. Friedman
SB, Aegean Park Press C-61, 195 pp.
Nonmember $44.80, Member $35.85
MILITARY CRYPTANALYTICS SET
MILITARY CRYPTANALYTICS, PART I - VOLUME 1
by William F. Friedman, Lambros D. Callimahos
SB, Aegean Park Press C-42, 235 pp.
Nonmember $34.80, Member $27.85
MILITARY CRYPTANALYTICS, PART I - VOLUME 2: Includes Problems and
Computer Programs
by William F. Friedman, Lambros D. Callimahos
SB, Aegean Park Press C-43, 239 pp.
Nonmember $34.80, Member $27.85
MODERN AND ADVANCED CRYPTO
INTRODUCTION TO THE ANALYSIS OF THE DATA ENCRYPTION STANDARD (DES): Includes
Computer Programs in Basic
by Wayne G. Barker
SB, Aegean Park Press C-55, 198 pp.
Nonmember $48.80, Member $39.05
ALGEBRAIC CODING THEORY: Revised 1984 Edition
by Elwyn R. Berlekamp
SB, Aegean Park Press M-6, 488 pp.
Nonmember $42.80, Member $34.25
SHIFT REGISTER SEQUENCES: Revised Edition
by Solomon W. Golomb, Lloyd R. Welch, Richard M. Goldstein, Alfred W. Hales
"The purpose of this book is to collect and present in a single volume a
thorough treatment of both the linear and nonlinear theory, with a guide to
the area of application, and a full bibliography of the related literature." --
from the preface.
SB, Aegean Park Press M-5, 263 pp.
Nonmember $36.80, Member $29.45
CRYPTOLOGY: System Identification and Key Clustering
by I. J. Kumar
The focus of this advanced book is the application of modern pattern
recognition techniques to the cryptanalysis of classical systems, stream
ciphers, rotor based systems, DES, and public key systems. Discusses the
cryptanalysis of speech systems.
SB, Aegean Park Press C-78, 499 pp.
Nonmember $52.80, Member $42.25
RIVERBANK PUBLICATIONS
THE RIVERBANK PUBLICATIONS, VOLUME 1
by William F. Friedman
SB, Aegean Park Press C-23, 144 pp.
Nonmember $26.80, Member $21.45
THE RIVERBANK PUBLICATIONS, VOLUME 2
by William F. Friedman
SB, Aegean Park Press C-24, 132 pp.
Nonmember $26.80, Member $21.45
THE RIVERBANK PUBLICATIONS, VOLUME 3
by William F. Friedman
SB, Aegean Park Press C-25, 91 pp.
Nonmember $26.80, Member $21.45
VOYNICH MANUSCRIPT
THE VOYNICH MANUSCRIPT: An Elegant Enigma
by M. E. D'Imperio
SB, Aegean Park Press C-27, 150 pp.
Nonmember $20.80, Member $16.65
==============
HB = Hardbound
SB = Softbound
==============
All items are in stock and available now. Member prices are available to
members of the American Cryptogram Association, the U.S. Naval Cryptologic
Veterans Association, and full-time students. Shipping and handling are extra.
For complete ordering information, a free catalog of crypto books by return
e-mail, or for information about membership in the American Cryptogram
Association, please send e-mail to: [EMAIL PROTECTED]
Best Wishes,
Gary
Gary Rasmussen
Classical Crypto Books
E-Mail: [EMAIL PROTECTED]
Fax: (603) 432-4898
------------------------------
Date: Sat, 15 Apr 2000 19:31:42 +0100
From: Richard Heathfield <[EMAIL PROTECTED]>
Subject: Why is this algorithm insecure? (Newbie flamefodder)
Please allow me a disclaimer. I'm not a cryptographer, and I'm certainly
not a cryptanalyst. I'm just a humble programmer, wending his weary way
through life's widespread wonders. Nevertheless, I've read Schneier
(didn't understand most of it) and Singh (understood almost all of it),
so I hope I get the jargon straight.
Having broken a couple of very simple "unbreakable" ciphers for friends,
I tried my hand - as we all do from time to time - at writing an
unbreakable cryptographic algorithm.
I've failed, naturally. But I don't know why, and I can't find anyone
else who does either, so I was hoping you guys could help out. Even if
it's just to say "yeh yeh yeh, congratulations, you just re-invented
Caveman Cryptography, even Noah thought it was old-fashioned" or
whatever.
I was going to submit this to your 'contest', but I can't, (a) because I
don't know if this counts as a block cipher and (b) I don't know spit
about analysis.
The algorithm is too simple to be secure, surely. It also suffers from
inefficiency, having a time complexity which I believe to be O(pk) where
p is the plaintext length and k is the key length, although - again - I
could be wrong about this. Having said that, it does lend itself to
stupendously long keys - http://users.powernet.co.uk/eton/crypto/cipher
contains a cipher (which I daren't reproduce here, since all 8 (or, if
you prefer, CHAR_BIT) bits of each byte are in the cipher 'space') which
was encrypted using a key over 20,000 bits long. (I never really
understood why people were hung up on 56 and 64 and 128 bits!)
Here's the algorithm, which I rather self-consciously call CDX-1:
Read the /whole/ plaintext into a buffer.
Read the whole of the key into another buffer.
For each byte of the key
Pick some number B with which that byte of the key is uniquely
identified (I used a bunch of primes)
Rotate the buffer left by B bits.
Perform a Vigenere-style XOR of the key all the way along the buffer.
Next
Write out the buffer to the ciphertext file.
Decryption is a simple reverse of the above process.
I'd love to analyse this but I really don't have the skill to do it. I
had a hard enough time breaking a Vigenere cipher.
Since I'm no expert, I have to assume this algorithm is weak. But it
looks horrendous. Yes, the key is scrawled all over the data but, on the
other hand, the bits are constantly being stirred by the rotations,
creating what I can only imagine to be a rather thick bit soup.
(Please assume that the key is generated randomly. I know this is
impossible within ordinary software in a digital computer, but please
assume it anyway!)
It would be most foolish of me to expect anyone to analyse this
algorithm without my producing source code, so here it is (and it's
posted at http://users.powernet.co.uk/eton/crypto/cdx.c too):
/*
* cdx.c
*
* Cryptographic algorithm copyright 1999-2000 Richard Heathfield
*
* Source code copyright 1999-2000 Richard Heathfield
*
* All rights reserved.
*
* You are hereby granted permission to copy this file onto
* one computer only, for the purposes of study and compilation
* and for no other purpose of any kind whatsoever. You are
* not granted permission to amend this source code in any way.
* You may not give copies of this file away, and you may not
* sell copies of this file.
*
* Description:
* This program implements the CDX-1 encryption algorithm.
* (CDX-0 was an internal algorithm which has been discarded
* for being insecure.)
*
* Usage:
* Encryption:
* enc plaintextfile ciphertextfile keyfile
* Decryption:
* enc ciphertextfile plaintextfile keyfile -d
*
* Assumptions:
* CHAR_BIT must be 8, 16, or 32.
* I'm not sure how this program would fare with sizeof(int) < 4
*
* Portability:
* Code tested on Microsoft Visual C++ 5.0 Pro, Borland C++ 5.02,
* and Delorie C (gcc), all under Windows 95 DOS box.
*
* I see no reason why it shouldn't work under Linux/Unix, or indeed
* under any platform or operating system. If you have problems,
* let me know the circumstances (which OS (name and version), which
* compiler (name and version)). Thanks.
*
* Credits:
* Mathew Watson (debugging!)
* Bob Stout's Snippets Collection (bit macros)
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#define MASK (CHAR_BIT-1)
#define SHIFT ((CHAR_BIT==8)?3:((CHAR_BIT==16)?4:5))
#define BitOff(a,x) ((void)((a)[(x)>>SHIFT] &= ~(1 << ((x)&MASK))))
#define BitOn(a,x) ((void)((a)[(x)>>SHIFT] |= (1 << ((x)&MASK))))
#define BitFlip(a,x) ((void)((a)[(x)>>SHIFT] ^= (1 << ((x)&MASK))))
#define IsBit(a,x) ((a)[(x)>>SHIFT] & (1 << ((x)&MASK)))
/* (a non-portable program would probably use something
* like _filelength(_fileno(fp)) instead of this function)
*/
int GetFileLength(FILE *fp)
{
int len = 0;
rewind(fp);
while(fgetc(fp) != EOF)
{
len++;
}
rewind(fp);
return len;
}
void XORBuffer(unsigned char *buffer, int DataLen, unsigned char *Key,
int KeyLen)
{
int i;
for(i = 0; i < DataLen; i++)
{
buffer[i] ^= Key[i % KeyLen];
}
}
void RotateBufferLeft(unsigned char *buffer, size_t size, int n)
{
int LeftBit, ThisBit, NewBit;
size_t i;
int iter;
size_t numbytes;
int numbits;
unsigned char byte;
n %= (size * CHAR_BIT);
numbytes = n / CHAR_BIT;
for(i = 0; i < numbytes; i++)
{
byte = buffer[0];
memmove(buffer, buffer + 1, size - 1);
buffer[size - 1] = byte;
}
numbits = n % CHAR_BIT;
for(iter = 0; iter < numbits; iter++)
{
LeftBit = IsBit(buffer, 0) ? 1 : 0;
ThisBit = LeftBit;
for(i = 0; i < (CHAR_BIT * size) - 1; i++)
{
NewBit = IsBit(buffer, (i + 1)) ? 1 : 0;
if(NewBit != ThisBit)
{
BitFlip(buffer, i);
}
ThisBit = NewBit;
}
if(NewBit != LeftBit)
BitFlip(buffer, i);
}
}
void RotateBufferRight(unsigned char *buffer, size_t size, int n)
{
int RightBit, ThisBit, NewBit;
size_t i;
int iter;
size_t numbytes;
int numbits;
unsigned char byte;
n %= (size * CHAR_BIT);
numbytes = n / CHAR_BIT;
for(i = 0; i < numbytes; i++)
{
byte = buffer[size - 1];
memmove(buffer + 1, buffer, size - 1);
buffer[0] = byte;
}
numbits = n % CHAR_BIT;
for(iter = 0; iter < numbits; iter++)
{
RightBit = IsBit(buffer, (CHAR_BIT * size) - 1) ? 1 : 0;
ThisBit = RightBit;
for(i = (CHAR_BIT * size) - 1; i > 0; i--)
{
NewBit = IsBit(buffer, (i - 1)) ? 1 : 0;
if(NewBit != ThisBit)
{
BitFlip(buffer, i);
}
ThisBit = NewBit;
}
if(NewBit != RightBit)
BitFlip(buffer, 0);
}
}
void Help(char *s)
{
if(!s || *s == 0)
s = "enc";
printf("Usage:\n");
printf("%s inputfile outputfile keyfile [-d]\n", s);
printf("-d specifies decryption\n");
}
unsigned char *GetPass(char *Filename, unsigned int *n)
{
unsigned char *buff = NULL;
FILE *fp;
fp = fopen(Filename, "rb");
if(fp != NULL)
{
*n = (unsigned int)GetFileLength(fp);
buff = malloc(*n);
if(buff != NULL)
{
if(!fread(buff, *n, 1, fp))
{
printf("Read error on key.\n");
exit(EXIT_FAILURE);
}
}
else
{
printf("Memory error - key too big.\n");
}
fclose(fp);
}
return buff;
}
int CheckArgs(int argc, char *argv[])
{
if(argc < 4)
{
Help(argv[0]);
return 0;
}
if(argc > 4 && strcmp(argv[4], "-d"))
{
printf("Syntax error.\n");
return 0;
}
return 1;
}
int encrypt(char *infile, char *outfile, char *keyfile, int decrypt)
{
static unsigned int PN_BLOCK[] =
{
2, 3, 5, 7, 11, 13, 17, 19,
23, 29, 31, 37, 41, 43, 47, 53,
59, 61, 67, 71, 73, 79, 83, 89,
97, 101, 103, 107, 109, 113, 127, 131,
137, 139, 149, 151, 157, 163, 167, 173,
179, 181, 191, 193, 197, 199, 211, 223,
227, 229, 233, 239, 241, 251, 257, 263,
269, 271, 277, 281, 283, 293, 307, 311,
313, 317, 331, 337, 347, 349, 353, 359,
367, 373, 379, 383, 389, 397, 401, 409,
419, 421, 431, 433, 439, 443, 449, 457,
461, 463, 467, 479, 487, 491, 499, 503,
509, 521, 523, 541, 547, 557, 563, 569,
571, 577, 587, 593, 599, 601, 607, 613,
617, 619, 631, 641, 643, 647, 653, 659,
661, 673, 677, 683, 691, 701, 709, 719,
727, 733, 739, 743, 751, 757, 761, 769,
773, 787, 797, 809, 811, 821, 823, 827,
829, 839, 853, 857, 859, 863, 877, 881,
883, 887, 907, 911, 919, 929, 937, 941,
947, 953, 967, 971, 977, 983, 991, 997,
1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049,
1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097,
1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163,
1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223,
1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283,
1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321,
1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423,
1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459,
1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511,
1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571,
1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619
};
unsigned char *Key;
unsigned int KeyLen;
FILE *fpIn, *fpOut;
int DataLen;
unsigned char *buffer;
int i;
fpIn = fopen(infile, "rb");
if(fpIn == NULL)
{
printf("Can't open input file.\n");
return EXIT_FAILURE;
}
fpOut = fopen(outfile, "wb");
if(fpOut == NULL)
{
fclose(fpIn);
printf("Can't open output file.\n");
return EXIT_FAILURE;
}
DataLen = GetFileLength(fpIn);
buffer = malloc(DataLen);
if(buffer == NULL)
{
fclose(fpIn), fclose(fpOut);
printf("Insufficient memory.\n");
return EXIT_FAILURE;
}
if(fread(buffer, DataLen, 1, fpIn) != 1)
{
fclose(fpIn), fclose(fpOut), free(buffer);
printf("Read error.\n");
return EXIT_FAILURE;
}
Key = GetPass(keyfile, &KeyLen);
if(Key == NULL)
{
fclose(fpIn), fclose(fpOut), free(buffer);
printf("Key error.\n");
return EXIT_FAILURE;
}
printf("\nProcessing");
fflush(stdout);
if(decrypt)
{
for(i = 0; i < (int)KeyLen; i++)
{
printf(".");
fflush(stdout);
XORBuffer(buffer, DataLen, Key, KeyLen);
RotateBufferRight(buffer, DataLen, PN_BLOCK[Key[KeyLen - (i +
1)]]);
}
}
else
{
for(i = 0; i < (int)KeyLen; i++)
{
printf(".");
fflush(stdout);
RotateBufferLeft(buffer, DataLen, PN_BLOCK[Key[i]]);
XORBuffer(buffer, DataLen, Key, KeyLen);
}
}
if(fwrite(buffer, DataLen, 1, fpOut) != 1)
{
printf("Write error.\n");
}
fclose(fpIn), fclose(fpOut), free(buffer);
return EXIT_SUCCESS;
}
int main(int argc, char *argv[])
{
int rc;
int decrypt = 0;
if(!CheckArgs(argc, argv))
{
rc = EXIT_FAILURE;
}
else
{
if(argc > 4 && strcmp(argv[4], "-d") == 0)
{
decrypt = 1;
}
rc = encrypt(argv[1], argv[2], argv[3], decrypt);
}
return rc;
}
Thank you for your time.
--
Richard Heathfield
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
29 K&R Answers: http://users.powernet.co.uk/eton/kandr2/index.html (68
to go)
------------------------------
From: [EMAIL PROTECTED] (JimD)
Crossposted-To:
alt.politics.org.cia,alt.politics.org.nsa,alt.journalism.print,alt.journalism.newspapers
Subject: Re: new Echelon article
Reply-To: JimD
Date: Sat, 15 Apr 2000 17:49:53 GMT
On Fri, 14 Apr 2000 21:07:15 -0700, "Stou Sandalski" <tangui
[EMAIL PROTECTED]> wrote:
>I read it in some mag, they had a thing on the discovery chanel about it...
>and they also had a movie about it which is pretty good. What was realy
>cool about this is that the cable was filled with compressed nitrogen (?) to
>detect breaches of it and they had to go through like airlocks and junk to
>get to it. East germany had pretty sick ass spy tech back in the day.. I
>heard rumors that they actualy taped every long distance telephone call.
>Interesting
Actually the nitrogen bit is usually to keep moisture out of the cable.
But a secondary advantage is that if the insulation is punctured
and the pressure drops, that is an indication that someone may
be tapping it. (Or some gardener or farmer has dug it up).
--
Jim Dunnett.
dynastic at cwcom.net
Londoner? Vote for Ken!!
------------------------------
** FOR YOUR REFERENCE **
The service address, to which questions about the list itself and requests
to be added to or deleted from it should be directed, is:
Internet: [EMAIL PROTECTED]
You can send mail to the entire list (and sci.crypt) via:
Internet: [EMAIL PROTECTED]
End of Cryptography-Digest Digest
******************************