meditationatae

Just another WordPress.com site

C source code to select list significant bit in *.wav file of white noise , at 2 channels and 16 bits/channel ; name = decrypt45.c

/****************************

the working directory was:  /home/david2/RANDOM

and the input white noise *wav file, at 2 channels audio and

16 bits of depth per pulse position modulated sample per audio channel,

for a total of 32 bits per sample; the idea is to take the least significant bit

from say Channel 1 and throw away channel 2 ; The LSB should be the

“most random” …

The input file , /home/david2/RANDOM/output.wav is a

895,123,758-byte *.wav file produced by Windows Magnetophone

recording in *.wav format from the two microphones (stereo input),

an analog TV set tuned to a non-broadcast (empty) TV channel, so

it’s white noise, both analog audio and analog video.

Windows used stereo at 16 bits depth, and 44100 samples per second:

this is contained in the 44 or 46 first bytes of the *.wav file.

The Windows *.wav was zipped with Winzip, burnt to disc (a CD), then

sent to a Linux Box, and unzipped, resulting in

/home/david2/RANDOM/output.wav . The program

decrypt45.c skipped approximately the first 90,000 bytes, as there were

many zero bytes there.

The output, redirected to: decrypt45.txt

is 28,224,000 bytes long, in 14,112,000 lines of characters ‘0’ or ‘1’ :

$ wc decrypt45.txt
14112000 14112000 28224000 decrypt45.txt

This is done to get an unambiguous, easily processed file of 0’s and 1’s .

This unambiguous file of 0s and 1s was used as input bu the next program,

makebin02a.c (next post) to pack the 14,112,000 random bits

at 8 per byte into a binary file of 1,764,000 byes.

This packed file, /home/david2/RANDOM/LSBwave.bin of 1,764,000 bytes

is appropriate for use with base64 encoding in the manner:

$ base64 LSBwave.bin  [ENTER ]

gives “truly random” base64 characters for assistance in picking

passwords, etc.

The most strong compression, ” xz -9 ” could not compress

LSBwave.bin to less than 1,764,000 bytes. Nevertheless, many

cryptography experts suggest XOR’ing random bits from noise/physical devices

with bits from pseudo-random number generators.

I’m assuming that the audio signal from the TV, its copy to Windows, the

CD engraved with the zipped *.wav file, and the files in the Linux Box

are safe from any intruders, except for the very very persistent.

The precautions to take go with the threat model…

LSBwave.bin can be pre-pended using makebin06a.c with an appropriate 44 or 46-byte

*.wav file Header to produce a “synthetic” 10-second audio file:

the 1,764,046-byte WAVE audio file: lsbwave.wav ;

this in turn can be played in VLC on Linux.

I consider this mini-project a succes because, while the *.wav file from

TV speakers whitenoise, the 895,123,758-byte output.wav file

WAS significantly biased (compressible), the output from taking the

least significant bit from 1 channel of every 32-bit 2-channel sample,

and packing at 8 bits per byte, the  1,764,000-byte file  LSBwave.bin ,

has resisted any compression tried so far .

David Bernier ( @doubledeckerpot ) ,

Quebec City,

Canada,

Sat Jul 4 04:38:11 EDT 2015

follows:  decrypt45.c from:

/home/david2/RANDOM/decrypt45.c

***********************************************************************/

#include <stdio.h>

int main(void)
{
int j;
unsigned char car;
unsigned char uc1;
unsigned char uc0;
unsigned char bitwiseand;
FILE *in;

in = fopen(“/home/david2/RANDOM/output.wav”, “r”);

uc1 = (unsigned char) 1;
uc0 = (unsigned char) 0;

for(j=0; j<56547736; j++)
{
fscanf(in, “%c”, &car);

if(j> 99737)
{
if((j%4) == 2)
{
// printf(“%3d: “, j+1);
// printf(“%3d “, car);
bitwiseand = uc1&car;
if(bitwiseand == uc1)
{
printf(“%d\n”, uc1);
}
else
{
printf(“%d\n”, uc0);
}
}
}
}

fclose(in);

return 0;

}

#include <stdio.h>

int main(void)
{
int j;
unsigned char car;
unsigned char uc1;
unsigned char uc0;
unsigned char bitwiseand;
FILE *in;

in = fopen(“/home/david2/RANDOM/output.wav”, “r”);

uc1 = (unsigned char) 1;
uc0 = (unsigned char) 0;

for(j=0; j<56547736; j++)
{
fscanf(in, “%c”, &car);

if(j> 99737)
{
if((j%4) == 2)
{
// printf(“%3d: “, j+1);
// printf(“%3d “, car);
bitwiseand = uc1&car;
if(bitwiseand == uc1)
{
printf(“%d\n”, uc1);
}
else
{
printf(“%d\n”, uc0);
}
}
}
}

fclose(in);

return 0;

}

Advertisements

Written by meditationatae

July 4, 2015 at 8:41 am

Posted in History

%d bloggers like this: