This is all the help output from all the downloadable files that have help.
#----------------------------------------------------------------------------
# testecbs8
#----------------------------------------------------------------------------
testecbs8 is a Pseudo Random Number Generator, (PRNG).
By default, testecbs8 will simply print out pseudo random numbers
to stdout forever. It is meant for testing the algorithm and showing
that the algorithm can pass statistical tests even with some features
disabled.
Usage: testecbs8 -ffilename -d -dd -n[0-9.+BKMGTP] -r[0-9]+ -s[0-9]+ -c[1-4] -l -t -z|Z -E -D -C1n -C2n -T -ss "string" filename . . .
Command line arguments are optional. There are program control
arguments, and there are PRNG seed arguments. Anything that starts
with "-" is a control option. Control options are never used for
seed data. Anything that does NOT start with "-" is used as seed
data.
The program control options have two varieties that may or may not
require some numeric argument. The output CLI options are about
controling output, how many numbers to output, logfile or not,
dump the state and so on. The configuration options turn off parts
of the algorithm or set specific values for parts of the state.
-d
-dd dump the state to STDOUT. They first intialize with
any other CLI options or default, then print the state and exit.
The single -d omits the LFSR element values. The double -dd
includes the LFSR elements, and that can be saved to a file
and used for the -f option to set the state from a file.
-l saves the starting state like -dd, to a logfile named
testecbs8.log, and continues on, outputting pseudo random
numbers. -l creates a new file named testecbs8.log if it does
not exist, otherwise it appends to the existing file.
-E encrypts data read from STDIN and writes to STDOUT.
No Fiestel structure, just a couple of XORs and intermmediate
feedback into the LFSR state.
-D Decrypts data read from STDIN and writes to STDOUT.
-ss causes single step output of the state variables for every
pseudo random number generated. -ss also turns off stdout of the
binary pseudorandom numbers, only the single step output is seen.
-T turns off the tapa1 and tapa5 rotates.
These CLI options require a numeric argument consisting of ascii
digits specify the value of the parameter you are setting.
-n specifies how many numbers to output. The digit string can be
ended with an upper case units specifier, B = bytes, K = kilobytes,
and so on. These are base 2 units K = 1024, NOT 1000.
-s sets the LFSR length (size) and turns off resizing. -S allows
for later resizing but will start with the initially specified
size.
-r sets the ressize interval in powers of 2 where the setsize
function will be called pseudorandomly, approximately once in
every 2^resetpower output numbers. -R allows the resize function
to be used even if the -s option is used to set the initial size.
-e sets the entropyflag which cuases the resize function to add
entropy in the form of a call to gettime() using CLOCK_MONOTONIC.
Adding entropy will generate pseudo random numbers that cannot be
predicted forwards or backwards even given the complete state.
-f filename, requires a file name which may immediately follow
or follow whitespace as the next CLI argument, and reads state
configuration from that file if it's a valid dump file.
All the above options are used to configure the normal algorithm.
The ones below, disable some algorithm functions so it can be
tested with various incomplete implementations in a single program.
-c specifies the number of counters to REMOVE from the algorithm.
-c also requires a digit from 1 to 4. 4 disables all counters, 3
leaves one counter, and it starts from the last counter, so the
least used counters are removed first.
-t disables tap swapping. This is just a binary toggle.
-z sets all state values to 0. This also disables resizing and
sets the LFSR length to MINVAL+1 which is currently 9. -s can
be used to set the size to any other value. The upper case
switches can override the -z option and allow resizing.
-Z sets all LFSR element values to 0 but randomizes tap positions.
-S = Allow resizing after starting from specified LFSR length.
-C1n
-C2n sets constant1 and constant2 and uses ecbs8const function
instead of ecbs8. The ecbs8const function is identical to
ecbs8 except the two formula lines are replaces with constant
value updates.
All other CLI provided input is checked for being a readable
file and if so, opened and read for seed input. If the CLI
argument is not a valid control option and not a readable file,
then the ascii values are used as seed data.
Below is more detailed explanation
of each CLI option and arguments
-d = dump the config state (except LFSR elements), to STDOUT
and exit. Regardless of any other options, dump config
except the LFSR element values. Use this to see maximum
and minimum compiled LFSR sizes.
-dd = Dump the config state plus LFSR state to STDOUT and exit.
Like -d, this will dump and exit regardless of any other
CLI otptions. lower case -dd also prints out every element
of the LFSR in addition to adders and taps. Redirect this
output to a file and you can use that file with -f switch
to set the state to exactly those same values. You can edit
the file to set whatever numbers you want, just keep the
same format and make sure the values are in the proper
range. No negative numbers for example.
-l = Log initial state in a logfile. This option will log the
full state of the LFSR, exactly like -dd, but to a logfile
named testecbs8.log. Sections of the logfile can be used
as configuration file, but they must be split out into
separate, standalone files.
-E = Encrypt data from STDIN. All the algorithm controls will
still work, and its just toy encryption. But it can be
used for testing. -E and -D require a file piped through
the program to encrypt the data from. The user seed is
not hashed in any way and some of it may be skipped or
ignored. See the tesetecbs8.readme file for details.
Encrypt and Decrypt ignore single step and outputlimit.
-D = Decrypt data from STDIN. All the algorithm controls will
still work, and its just toy encryption. But it can be
used for testing.
-ss = single step output of the state variables for every pseudo
random number generated. -ss also turns off stdout of the
binary pseudorandom numbers, so only the single step output
is seen. Each number generated produces three lines of
output similar to these for LFSR of size 16 elements.
154 36 184 14 RETVAL 246 A
153 141 206 107 129 113 110 45 227 133 250 115 118 77 58 12 S
6 2 4 7 3 5 8 1 T
The position of the taps in the T line indicates the LFSR
element they currently point to. Single step cannot be used
with -E or -D
-T = disable rotates on tapa1 and tapa5. These taps are normally
rotated the amount specified by shift just before the formula
that updates them. The shift variable is normally decremented
and reset when reaching 0. The -T flag disables the shift
variable by skipping the rotate if shift == 0.
-f = Read state config from previously dumped data file. The
file must be exactly the same format as a file created
using the -dd option. It will include all LFSR values. If a
file is specified for state initialization, then the setsize
option "-s" can still be used, but will also reset all the
state data. Edit the file rather tha using CLI option.
-z = Zero out all LFSR state and set taps to 0-7. This initially
sets lfsralen to MINLEN+1 but it may be reset by the resize
function. The -z switch does not affect other program
control options, it just removes the seed step and starts
the lfsr with all zero's in the state, except the tap values
which have to be unique. The tap values are set to elements
0 - 7 of the LFSR. Since seeding is skipped, the lfsr
length is never set, so it defaults to MINLEN-1 unless
overridden by the -S option. The resize function turns off
resizing unless the special CLI option -S (upper case) is
used for the size, OR -R (upper case), is used to set the
resetpower value.
-Z = Zero out LFSR state and counters, but randomizes the taps.
Otherwise its the same as -z. The uppercase -Z option calls
the setsize function, but zero's out everything except
the tap positions.
-s = Set the lfsrlength. This sets the LFSR length if possible.
The -s option also turns of resizing completely because
it makes no sense to set a length and have it randomly
changed. If no seed bytes are provided, then the size can
be any value between MINLEN and MAXLEN. But if seed bytes
are provided, then the ecbs8seed function sets the LFSR
length to number of seed bytes recieved. The -s switch can
set the length greater than number of seed bytes recieved,
if some are also provided. If setsize is used with -f to
read from a dump file, then resetpower will be set to zero
if not zero and the resize function will be called. This
will change the LFSR taps and LFSR element values.
-S = Allow resizing after starting from specified LFSR length.
Normally the lower case -s option turns off reszing. The
upper case option allows for a specified initial LFSR length,
and resizing thereafter. The -z option also normally turns
off resizing and sets minimal length. Either -S or -R can
be used to allow the resize function when it would normally
be ignored with the lower case switches.
-r = Set the reset interval. The -r option requires a number
from 9 to 63 be provided. The number can be a separate
CLI argument or immediately follow the -r. By default the
LFSR resets it's size and taps pseudorandomly every 16
million calls or so. The reset interval is a power of 2,
from 9 to 63 which is used to set the reset frequency.
We set the reset value to (2^reset) -1 and if a certain
state value & reset == 0, then we call the resize function.
This means, we are calling based on the number of 1 bits
in a row on the small end of the state value. The reset
interval is stored as variable resetpower. If resetpower = 0,
then resetting and resizing the LFSR is completely turned
off. Otherwise, the value is used to set the AND value to
that many one bits in a row from small end. Values less than
17 can cause extra inefficient CPU usage, because ecbs8()
might try to call ecbs8setsize) while ecbs8setsize() is
calling ecbs8(). These calls are ignored. The default
value is 24. Any value < 9 is treated same as zero and
turns off resizing altogether.
-R = Set the resetpower when using -s or -z. The -z option
normally turns off resizing, even with the -s switch.
The -s switch normally turns off resizing. Upper case
R can be used to force the resize function. Either -S
or -R can be used to force the resize function when it
would normally be ignored with the lower case switches.
-e = Add entropy in the ecbs8setsize function. This causes setsize
to add current seconds and nanoseconds from
gettime(CLOCK_MONOTONIC, &curtime) system call. The values
returned are mixed and stored in variables seconds and ns,
and also the previous values are stored in lastseconds and
lastns. Those last values are used to update the LFSR elements
determined by the value of the shift variable. The use of the
last values introduces a delay, and adding to LFSR elements
will also introduce an amount of delay. This output cannot
be reproduced. The best you can do is start from the same
initial seed. The delay is intentional but you can simply
call ecbs8setsize() a second time before obtaining any numbers.
-t = Turn off tap swapping. This causes the taps to be fixed in
position, like most other LFSRs where the LFSR is defined
by the tap values. By default, (without the -t switch), one
tap is randomly selected to be swpped with its neighbor to
the right on each call to ecbs8.
-c = Cripple the adders by removing the last n adders. The
number n may follow the -c without a space or may be given
as the following CLI argument. The value ranges from 1 to 4
inclusive. 0 does not make sense, that would do nothing.
Adders are removed in order, adder4, adder3, adder2 and adder1.
They are simply not used anymore.
1 is the leaset extreme, 4 removes ALL adders.
1 = dont use adder4
2 = dont use adder4 adder3
3 = dont use adder4 adder3 adder2
4 = dont use adder4 adder3 adder2 adder1
-n = Output exactly n 8 bit numbers. Output bytes will be same
as n. The -n option requires a number and optionally, a
Units tag consisting of one of the following letters:
B = Bytes
K = Kilobytes
M = Megabytes
G = Gigabytes
T = Terabytes
P = Petabytes
The optional Units specifier, must be appended to the last
digit of the number given. It cannot be a seprate CLI
argument. This will output exactly that many numbers unless
overriden by a dump switch, (-d or -dd. Source of seed data
makes no difference, if numbers will be output, then it will
be this many, if specified. The outputlimit is ignored when
using -D and -E.
-C1n
-C2n sets constant1 and constant2 repectively where n may
follow immediately or separated by a space. Defaults
are constant1 = 170, constant2 = 85. They are always
used together so if only one is set the other will use
its default value. When either of these are set from CLI,
a flag is set that uses a modified ecbs8 PRNG algorithm
which is identical to the real ecbs8, EXCEPT, instead of
using the two formula lines, ecbs8const function returns
a constant value where the formulas would have been. This
simulates a formula with period length of 1. The real ecbs8
function does not use constant1 and constant2, they are
replacements for the formula lines in ecbs8const() only.
None of the program control options are used as seed data or
counted as seed bytes used, regardless whether they are used or
rejected as out of bounds.
Any other CLI arguments not used to control the program are used
as seed data, applied byte by byte as recieved into the LFSR state.
The numbers for -n , -s, -c, -r, -C1, -C2 and the filename
for -f may follow immediately after the name or number, or
separated by a space.
Later CLI arguments may override earlier CLI arugments, as you
would expect. The -D and -E options cause any -ss or -n to be
ignored regardless of position in argument list
If a seed option is a readable file greater then 0 bytes in
size, then the file is opened and all bytes are read in and
added to the LFSR state. If the option is a file but its not
readable or it doesn't exist, then the filename is used as seed
data and counted as bytes read in. If the file is opened and read,
then the filename itself is not used as seed data. All CLI seed
options are tested for being a file that can be opend and read.
Seed data is added to the counters first, and then the LFSR
elements in order until finally wrapping back to the counters
and then LFSR elements again if enough seed data is provided.
If no seed data is provided and no dump file, then /dev/urandom
is used to fill in the state. This defaults to MAXLEN-1 initial
size. If user seed input is provided, then the lfsrlen is first
set to MAXLEN-1 and setsize is called fill all lfsr elements.
After this, the adders are updated by ecbs8 and then ecbs8setsize
is called a second time with user specifiied or determined by
totalseedchars lfsrlen. This becomes the initial lfsralen.
By this method, the adders are always randomized with lfsr
elements and taps.
The ecbs8setsize function does not alter the adders, only
the taps and lfara elements. Thats why we update them
initially here. That could all be in a seed function, but
you can seed and initialize any way you want. Nobody will
ever want to use my CLI processing but it doesn't matter
much, the ecbs8setsize function is really all you need, and
a few seed bytes in lfsra.
This is the 8 bit version. The maximum LFSR length can only be
127 bytes long. I use MINLEN 8 and MAXLEN 127 for simulating
the algorithm on something like a 6502 chip.
See the readme file, testecbs8.readme for more algorithm
discussion.
Last Update: Fri Apr 15 02:10:35 PDT 2022
(MINLEN + 1) = 9 (MAXLEN - 1) = 31
#----------------------------------------------------------------------------
# testecbs64
#----------------------------------------------------------------------------
testecbs64 is a Pseudo Random Number Generator, (PRNG).
By default, testecbs64 will simply print out pseudo random numbers
to stdout forever. It is meant for testing the algorithm and showing
that the algorithm can pass statistical tests even with some features
disabled.
Usage: testecbs64 -ffilename -d -dd -n[0-9.+BKMGTP] -r[0-9]+ -s[0-9]+ -c[1-4] -l -t -z|Z -E -D -C1n -C2n "string" filename
Command line arguments are optional. There are program control
arguments, and there are PRNG seed arguments. Anything that starts
with "-" is a control option. Control options are never used for
seed data. Anything that does NOT start with "-" is used as seed
data.
The program control options have two varieties that may or may not
require some numeric argument. The output CLI options are about
controling output, how many numbers to output, logfile or not,
dump the state and so on. The configuration options turn off parts
of the algorithm or set specific values for parts of the state.
-d
-dd dump the state to STDOUT. They first intialize with
any other CLI options or default, then print the state and exit.
The single -d omits the LFSR element values. The double -dd
includes the LFSR elements, and that can be saved to a file
and used for the -f option to set the state from a file.
-l saves the starting state like -dd, to a logfile named
testecbs64.log, and continues on, outputting pseudo random
numbers. -l creates a new file named testecbs64.log if it does
not exist, otherwise it appends to the existing file.
-E encrypts data read from STDIN and writes to STDOUT.
No Fiestel structure, just a couple of XORs and intermmediate
feedback into the LFSR state.
-D Decrypts data read from STDIN and writes to STDOUT.
-ss causes single step output of the state variables for every
pseudo random number generated. -ss also turns off stdout of the
binary pseudorandom numbers, only the single step output is seen.
These CLI options require a numeric argument consisting of ascii
digits specify the value of the parameter you are setting.
-n specifies how many numbers to output. The digit string can be
ended with an upper case units specifier, B = bytes, K = kilobytes,
and so on. These are base 2 units K = 1024, NOT 1000.
-s sets the LFSR length (size) and turns off resizing. -S allows
for later resizing but will start with the initially specified
size.
-r sets the ressize interval in powers of 2 where the setsize
function will be called pseudorandomly, approximately once in
every 2^resetpower output numbers. -R allows the resize function
to be used even if the -s option is used to set the initial size.
-e sets the entropyflag which cuases the resize function to add
entropy in the form of a call to gettime() using CLOCK_MONOTONIC.
Adding entropy will generate pseudo random numbers that cannot be
predicted forwards or backwards even given the complete state.
-f filename, requires a file name which may immediately follow
or follow whitespace as the next CLI argument, and reads state
configuration from that file if it's a valid dump file.
All the above options are used to configure the normal algorithm.
The ones below, disable some algorithm functions so it can be
tested with various incomplete implementations in a single program.
-c specifies the number of counters to REMOVE from the algorithm.
-c also requires a digit from 1 to 4. 4 disables all counters, 3
leaves one counter, and it starts from the last counter, so the
least used counters are removed first.
-t disables tap swapping. This is just a binary toggle.
-z sets all state values to 0. This also disables resizing and
sets the LFSR length to MINVAL+1 which is currently 9. -s can
be used to set the size to any other value. The upper case
switches can override the -z option and allow resizing.
-Z sets all LFSR element values to 0 but randomizes tap positions.
-C1n
-C2n sets constant1 and constant2 and uses ecbs64const function
instead of ecbs64. The ecbs64const function is identical to
ecbs64 except the two formula lines are replaces with constant
value updates.
All other CLI provided input is checked for being a readable
file and if so, opened and read for seed input. If the CLI
argument is not a valid control option and not a readable file,
then the ascii values are used as seed data.
Below is more detailed explanation
of each CLI option and arguments
-d = dump the config state (except LFSR elements), to STDOUT
and exit. Regardless of any other options, dump config
except the LFSR element values. Use this to see maximum
and minimum compiled LFSR sizes.
-dd = Dump the config state plus LFSR state to STDOUT and exit.
Like -d, this will dump and exit regardless of any other
CLI otptions. lower case -dd also prints out every element
of the LFSR in addition to adders and taps. Redirect this
output to a file and you can use that file with -f switch
to set the state to exactly those same values. You can edit
the file to set whatever numbers you want, just keep the
same format and make sure the values are in the proper
range. No negative numbers for example.
-l = Log initial state in a logfile. This option will log the
full state of the LFSR, exactly like -dd, but to a logfile
named testecbs64.log. Sections of the logfile can be used
as configuration file, but they must be split out into
separate, standalone files.
-E = Encrypt data from STDIN. All the algorithm controls will
still work, and its just toy encryption. But it can be
used for testing. -E and -D require a file piped through
the program to encrypt the data from. The user seed is
not hashed in any way and some of it may be skipped or
ignored. See the tesetecbs64.readme file for details.
Encrypt and Decrypt ignore single step and outputlimit.
-D = Decrypt data from STDIN. All the algorithm controls will
still work, and its just toy encryption. But it can be
used for testing.
-ss = single step output of the state variables for every pseudo
random number generated. -ss also turns off stdout of the
binary pseudorandom numbers, so only the single step output
is seen. Each number generated produces three lines of
output similar to these for LFSR of size 16 elements.
154 36 184 14 RETVAL 246 A
153 141 206 107 129 113 110 45 227 133 250 115 118 77 58 12 S
6 2 4 7 3 5 8 1 T
The position of the taps in the T line indicates the LFSR
element they currently point to. Single step cannot be used
with -E or -D
-f = Read state config from previously dumped data file. The
file must be exactly the same format as a file created
using the -dd option. It will include all LFSR values. If a
file is specified for state initialization, then the setsize
option "-s" can still be used, but will also reset all the
state data. Edit the file rather tha using CLI option.
-z = Zero out all LFSR state and set taps to 0-7. This initially
sets lfsralen to MINLEN+1 but it may be reset by the resize
function. The -z switch does not affect other program
control options, it just removes the seed step and starts
the lfsr with all zero's in the state, except the tap values
which have to be unique. The tap values are set to elements
0 - 7 of the LFSR. Since seeding is skipped, the lfsr
length is never set, so it defaults to MINLEN-1 unless
overridden by the -S option. The resize function turns off
resizing unless the special CLI option -S (upper case) is
used for the size, OR -R (upper case), is used to set the
resetpower value.
-Z = Zero out LFSR state and counters, but randomizes the taps.
Otherwise its the same as -z. The uppercase -Z option calls
the setsize function, but zero's out everything except
the tap positions.
-s = Set the lfsrlength. This sets the LFSR length if possible.
The -s option also turns of resizing completely because
it makes no sense to set a length and have it randomly
changed. If no seed bytes are provided, then the size can
be any value between MINLEN and MAXLEN. But if seed bytes
are provided, then the ecbs64seed function sets the LFSR
length to number of seed bytes recieved. The -s switch can
set the length greater than number of seed bytes recieved,
if some are also provided. If setsize is used with -f to
read from a dump file, then resetpower will be set to zero
if not zero and the resize function will be called. This
will change the LFSR taps and LFSR element values.
-S = Allow resizing after starting from specified LFSR length.
Normally the lower case -s option turns off reszing. The
upper case option allows for a specified initial LFSR length,
and resizing thereafter. The -z option also normally turns
off resizing and sets minimal length. Either -S or -R can
be used to allow the resize function when it would normally
be ignored with the lower case switches.
-r = Set the reset interval. The -r option requires a number
from 9 to 63 be provided. The number can be a separate
CLI argument or immediately follow the -r. By default the
LFSR resets it's size and taps pseudorandomly every 16
million calls or so. The reset interval is a power of 2,
from 9 to 63 which is used to set the reset frequency.
We set the reset value to (2^reset) -1 and if a certain
state value & reset == 0, then we call the resize function.
This means, we are calling based on the number of 1 bits
in a row on the small end of the state value. The reset
interval is stored as variable resetpower. If resetpower = 0,
then resetting and resizing the LFSR is completely turned
off. Otherwise, the value is used to set the AND value to
that many one bits in a row from small end. Values less than
17 can cause extra inefficient CPU usage, because ecbs64()
might try to call ecbs64) while ecbs64setsize() is
calling ecbs64(). These calls are ignored. The default
value is 24. Any value < 9 is treated same as zero and
turns off resizing altogether.
-R = Set the resetpower when using -s or -z. The -z option
normally turns off resizing, even with the -s switch.
The -s switch normally turns off resizing. Upper case
R can be used to force the resize function. Either -S
or -R can be used to force the resize function when it
would normally be ignored with the lower case switches.
-e = Add entropy in the ecbs64setsize function. This causes setsize
to add current seconds and nanoseconds from
gettime(CLOCK_MONOTONIC, &curtime) system call. The values
returned are mixed and stored in variables seconds and ns,
and also the previous values are stored in lastseconds and
lastns. Those last values are used to update the LFSR elements
determined by the value of the shift variable. The use of the
last values introduces a delay, and adding to LFSR elements
will also introduce an amount of delay. This output cannot
be reproduced. The best you can do is start from the same
initial seed. The delay is intentional but you can simply
call ecbs64setsize() a second time before obtaining any numbers.
-t = Turn off tap swapping. This causes the taps to be fixed in
position, like most other LFSRs where the LFSR is defined
by the tap values. By default, (without the -t switch), one
tap is randomly selected to be swpped with its neighbor to
the right on each call to ecbs64.
-c = Cripple the adders by removing the last n adders. The
number n may follow the -c without a space or may be given
as the following CLI argument. The value ranges from 1 to 4
inclusive. 0 does not make sense, that would do nothing.
Adders are removed in order, adder4, adder3, adder2 and adder1.
They are simply not used anymore.
1 is the leaset extreme, 4 removes ALL adders.
1 = dont use adder4
2 = dont use adder4 adder3
3 = dont use adder4 adder3 adder2
4 = dont use adder4 adder3 adder2 adder1
-n = Output exactly n 8 bit numbers. Output bytes will be same
as n. The -n option requires a number and optionally, a
Units tag consisting of one of the following letters:
B = Bytes
K = Kilobytes
M = Megabytes
G = Gigabytes
T = Terabytes
P = Petabytes
The optional Units specifier, must be appended to the last
digit of the number given. It cannot be a seprate CLI
argument. This will output exactly that many numbers unless
overriden by a dump switch, (-d or -dd. Source of seed data
makes no difference, if numbers will be output, then it will
be this many, if specified. The outputlimit is ignored when
using -D and -E.
-C1n
-C2n sets constant1 and constant2 repectively where n may
follow immediately or separated by a space. Defaults
are constant1 = 170, constant2 = 85. They are always
used together so if only one is set the other will use
its default value. When either of these are set from CLI,
a flag is set that uses a modified ecbs64 PRNG algorithm
which is identical to the real ecbs64, EXCEPT, instead of
using the two formula lines, ecbs64const function returns
a constant value where the formulas would have been. This
simulates a formula with period length of 1. The real ecbs64
function does not use constant1 and constant2, they are
replacements for the formula lines in ecbs64const() only.
None of the program control options are used as seed data or
counted as seed bytes used, regardless whether they are used or
rejected as out of bounds.
Any other CLI arguments not used to control the program are used
as seed data, applied byte by byte as recieved into the LFSR state.
The numbers for -n , -s, -c, -r, -C1, -C2 and the filename
for -f may follow immediately after the name or number, or
separated by a space.
Later CLI arguments may override earlier CLI arugments, as you
would expect. The -D and -E options cause any -ss or -n to be
ignored regardless of position in argument list
If a seed option is a readable file greater then 0 bytes in
size, then the file is opened and all bytes are read in and
added to the LFSR state. If the option is a file but its not
readable or it doesn't exist, then the filename is used as seed
data and counted as bytes read in. If the file is opened and read,
then the filename itself is not used as seed data. All CLI seed
options are tested for being a file that can be opend and read.
Seed data is added to the counters first, and then the LFSR
elements in order until finally wrapping back to the counters
and then LFSR elements again if enough seed data is provided.
If no seed data is provided and no dump file, then /dev/urandom
is used to fill in the state. This defaults to MAXLEN-1 initial
size. If user seed input is provided, then the lfsrlen is first
set to MAXLEN-1 and setsize is called fill all lfsr elements.
After this, the adders are updated by ecbs64 and then ecbs64setsize
is called a second time with user specifiied or determined by
totalseedchars lfsrlen. This becomes the initial lfsralen.
By this method, the adders are always randomized with lfsr
elements and taps.
The ecbs64setsize function does not alter the adders, only
the taps and lfara elements. Thats why we update them
initially here. That could all be in a seed function, but
you can seed and initialize any way you want. Nobody will
ever want to use my CLI processing but it doesn't matter
much, the ecbs64setsize function is really all you need, and
a few seed bytes in lfsra.
This is the 8 bit version. The maximum LFSR length can only be
127 bytes long. I use MINLEN 8 and MAXLEN 127 for simulating
the algorithm on something like a 6502 chip.
See the readme file, testecbs64.readme for more algorithm
discussion.
Last Update: Fri Apr 15 02:10:35 PDT 2022
(MINLEN + 1) = 9 (MAXLEN - 1) = 31
#----------------------------------------------------------------------------
# ecbscrypto
#----------------------------------------------------------------------------
ecbscrypto is a cipher program based on ecbs64 PRNG. ecbscrypto
uses multiple rounds of a feistel structure, operating on 64 bit
blocks of data. This program reads input data from STDIN and
writes to STDOUT. This means you must use OS redirects to read
and write files.
Usage: cat inputfile | ecbscrypto -E|-D -r[0-255] key > outputfile
-E encrypts data read from STDIN and writes to STDOUT.
-D Decrypts data read from STDIN and writes to STDOUT.
-r sets the number reounds to use on each block of input data.
The default is 4.
All other CLI provided input is checked for being a readable
file and if so, opened and read for seed input. If the CLI
argument is not a valid control option and not a readable file,
then the ascii values are used as seed data. The secret key data
must be at least 34 bytes. There is no upper limit. Up to 65536
bytes are read from any file opened for input.
See the readme file, ecbscrypto.readme for more algorithm
discussion.
Last Update: Thu 11 Aug 13:21:48 PDT 2022
#----------------------------------------------------------------------------
# ecbscryptogen
#----------------------------------------------------------------------------
ecbscryptogen - encrypt and decrypt files.
Usage: ecbscryptogen -E|-D -f filename -r[4-255] keyfile
ecbscryptogen is a cipher program based on ecbs64 PRNG. ecbscryptogen
uses multiple rounds of a feistel structure, operating on 64 bit
blocks of data. You must specify a file to work on and either -E
or -D for encrypt or decrypt, and you must provide a secret key.
The file will be ciphered and and new output file will be created.
The newly created filename will have ".enc" appended if it is for
encrypt, and for decrypt, ".dec" will be appeneded unless the
file ends with ".enc" in which case it is changed from enc to dec.
The secret key can be a file or any CLI input, quoted and backspaced
as needed to pass through the command shell. If any CLI argument is
NOT -D, -E, -r, or -f, then it is checked for being a readable file,
and if so, up to 65536 bytes are read from the file to seed the PRNG.
If the CLI argument is not a readable file, then, the argument
itself is used to the seed the PRNG. If the file contents are used
then the filename itself is not used.
Usage: ecbscryptogen -E|-D -f filename -r[4-255] keyfile
-E Encrypts data read from the -f filename.
For encryption, the filename specified is always appended with
".enc" to create the output filename.
-D Decrypts data read from the -f filename.
For decryption, the filename specified is appended with
".dec" to create the output filename, UNLESS the filename
ends with ".enc" in which case enc is changed to dec.
-f Specifies the file to encrypt or decrypt.
-r sets the number rounds to use on each block of input data.
The default is 4. Rounds are expensive, 8 rounds takes twice
as long as 4 rounds. Must be at least 4 and < 256
The secret key data must be at least 34 bytes. There is no upper
limit but only 65536 bytes are read from any file.
This file generates one of approximately 5809100936601600
possible variants of ecbs64(). See the readme file,
ecbscryptogen.readme for algorithm discussion.
If you use -g the generated files are left in place.
The generated program ecbscryptogen can be used to encrypt
but the same program cannot decrypt what it encrypted because it
expects the nonce from ecbscryptogen to be in the file and it
has to read those 5 64 bit values and discard the. Find that
extra fread(noncebuffer, 5 line and remove it. Then it can decrypt
files encrypted by the same program. No key is needed. The starting
secret key is built in. Each file encrypted uses two nonces, so
all encrypted files will be different. Of course, leaving this
program on your disk is risky, but if you only need privacy, it's
an easy way to encrypt for cloud storage or backups. If you want
security, never use the -g option and always use a very long key.
Last Update: Thu 11 Aug 13:21:48 PDT 2022
#----------------------------------------------------------------------------
# dump
#----------------------------------------------------------------------------
Usage: dump -n[0-9.+BKMGTP] -x -b -s -l -ll filename
dump reads the file specified and prints out the integer values
of the file data. The flags specify limited format options.
-n specifies a number of bytes to output where the optional uppercase
letter specifies the units. The digit string may follow the -n
immediately or the digits can be separated by space. The optional
units tag must immediately follow the last digit, it cannot be a
separate CLI argument. The number given is always used rounded to
ther next value equal to 0 modulao 16. In other words, the number
is always rounded up to the next 16 byte boundary if not aligned.
B = 8 bit bytes
K = 1024 bytes
M = 1024 * 1024 bytes
G = 1024 * 1024 * 1024 bytes
T = 1024 * 1024 * 1024 * 1024 bytes
P = 1024 * 1024 * 1024 * 1024 * 1024 bytes
The other CLI switches are mutually exclusive and specify the
bit length of the output.
-x = HEX numbers
-b = 8 bit bytes
-s = 16 bit short integers
-l = 32 bit integers
-ll = 64 bit integers
The filename can be any readable file.
#----------------------------------------------------------------------------
# findrepeat8
#----------------------------------------------------------------------------
findrepeat8 reads STDIN and searches for a repeating sequence of characters.
Usage: findrepeat8 -n -s [filename]\n";
Usage: cat filename | awkm \n";
With awk, you print the specified fields with format strings in
between the fields.
With awkm, you print a single format string, with fields specified
in between the characters of the format string.
The formatstring is inside quote marks and fields are specified
by Fn where n is the field number. Field numbers start from 1
and cannot contain leading zeros. Field numbers go up to F99.
Example:
awkm "F1 is the first field, F2 is the second"
This prints out for each line:
is the first field, is the second
If a field does not exist, then F#n is printed to mark the place
where it would have been if it existed. This can be turned off
by putting the letter "i" for ignore, as the very first character
of the formatstring. If the very first real character of the format
string happens to be the letter "i" then it must be escaped with
a backslash.
Field numbers start with 1, so the special field F0 means "The whole line."
Cat any text file through "awkm F1" and you will see only the first
word of every line, unless its a blank line and then you will see F#1.
The format string does not need quotes if it contains no spaces,
but special characters will need to be escaped to prevent shell
interpolation. But simple things like just F1 or F2F1
with no spaces don't require quotes.
awkm can split lines by inserting "\n" into the formatstring
This can be used to turn a single line into two or more lines with
only the fields you specify in each resulting line.
awkm can also join lines by inserting "\j" in the formatstring
To join two lines, we have one "\j" and everything before the
"\j" is applied to the first line, and everything after, is
is applied to the second line read in. If there are further joins
another line is read in, until the final join is complete. The
same process then continues through end of input. You can also
combine joins and splits on lines producing interesting results.
#----------------------------------------------------------------------------
# snip
#----------------------------------------------------------------------------
Usage: snip deletestring [replacestring] [gi]
snip - prints integers from start to stop, incrementing by step.
You must pipe input through STDIN to snip. snip does not read files.
Usage: snip delete-string optional-replace-string optional-modifier
The optional modifier can be i, g, ig, or gi.
i = case insensitive, g = global
The modifier must be the third CLI argument. In order to delete without
replacing, but also use g or i modifier, you have to give an empty
replace-string using double quotes. Replacing with nothing is
equivilent to delete. Examples: (assume cat filename | snip command below)
snip OLD "" i # delete the first instance of "OLD" ignoring case
snip OLD NEW # replace the first instance of "OLD" with "NEW"
snip OLD "" gi # delete instances of "OLD" globally ignoring case
snip OLD New gi # replace any case version of "OLD" with "New" globally
snip OLD # delete the first instance of "OLD" only
snip OLD New # replace the first instance of "OLD" with "New"
You can't specify a specific instance to delete or replace. It's either
the first only, or ALL intances. But you can replace with temporary
values and then replace them with what you need.
#----------------------------------------------------------------------------
# findin.pl
#----------------------------------------------------------------------------
Finds whats IN file1 AND IN file2
Usage : /home/ecanzler/bin/findin.pl file1 file2
findin.pl ignores blank lines. By default, findin.pl displays
lines with a prefix including the filename. Any third CLI argument
turns off the prefix and displays the lines exactly as they are
in the files.
#----------------------------------------------------------------------------
# findnotin.pl
#----------------------------------------------------------------------------
Finds whats NOT in file1 but IS in file2
Usage : findnotin.pl file1 file2
Optional third argument prints bare NOTIN lines only.
The third argument can be anything.
NOTIN lines are printed in the order they occur in the second
file. The number of times a line occurs is not considered.
Blank lines are ignored.
#----------------------------------------------------------------------------
# findnotinb.pl
#----------------------------------------------------------------------------
Finds whats NOT in file1 but IS in file2 and vice versa
Usage : findnotinb.pl file1 file2
findnotinb.pl is like running findnotin.pl twice, the second
time, with filename arguments reveresed.
Optional third argument prints bare NOTIN lines only.
The third argument can be anything.
NOTIN lines are printed in the order they occur in the second
file. The number of times a line occurs is not considered.
Blank lines are ignored.
#----------------------------------------------------------------------------
# skel.pl
#----------------------------------------------------------------------------
skel.pl: Reads STDIN and prints to STDOUT.
Usage: cat filename | skel.pl -c -l | less
or other similar pipes and redirects as needed.
skel.pl prints only the open/close code blocks indentified
by curly braces, and conditional statements identified by
parenthesis. This allows you to see the structure of a perl
program without all the distracting details. This is useful
for finding extra or missing open/close braces and paranthesis.
A CLI option -c will cause comments to be printed as well.
Comments are identified by pound sign.
skel.pl works reasonably well for C code but commanents can't
be displayed because this is a quick and dirty hack.
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
Links to professional PRNG sites and a lot of discussion about ecbs
Explanation and detailed description of the algorithms and why they are as they are
How to use testecbs8 and testecbs64
A cryptographic cipher program that leaves no trace of itself after use. How ecbscryptogen works.
Download testecbs64.c, testecbs8.c, ecbscrypto.c, ecbscryptogen.c and some minor utilities.
Last updated Fri Aug 26 17:47:26 PDT 2022