0% found this document useful (0 votes)
7 views

Pseudo random number generator_RC4

Chapter 8 of 'Cryptography and Network Security' discusses random bit generation and stream ciphers, emphasizing the importance of randomness and unpredictability in cryptographic applications. It distinguishes between true random number generators (TRNGs) and pseudorandom number generators (PRNGs), detailing their mechanisms and requirements. The chapter also covers various algorithms for generating pseudorandom sequences, including the Linear Congruential Generator and the Blum Blum Shub generator, as well as considerations for stream cipher design.

Uploaded by

p2130671
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Pseudo random number generator_RC4

Chapter 8 of 'Cryptography and Network Security' discusses random bit generation and stream ciphers, emphasizing the importance of randomness and unpredictability in cryptographic applications. It distinguishes between true random number generators (TRNGs) and pseudorandom number generators (PRNGs), detailing their mechanisms and requirements. The chapter also covers various algorithms for generating pseudorandom sequences, including the Linear Congruential Generator and the Blum Blum Shub generator, as well as considerations for stream cipher design.

Uploaded by

p2130671
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 46

Cryptograph

y and
Network
Security
Eighth Edition, Global Edition
by William Stallings

Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..


Chapter 8
Random Bit Generation
and Stream Ciphers
Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..
Random Numbers
• A number of network security algorithms and protocols
based on cryptography make use of random binary
numbers:
• Key distribution and reciprocal authentication schemes
• Session key generation
• Generation of keys for the RSA public-key encryption
algorithm
• Generation of a bit stream for symmetric stream
encryption

There are two Randomness


distinct
requirements for
a sequence of
random
numbers: Unpredictability

Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..


Randomness
• The generation of a sequence of
allegedly random numbers being
random in some well-defined statistical
sense has been a concern
Two criteria are used to validate
that a sequence of numbers is
random:
Uniform distribution
• The frequency of occurrence of ones and
zeros should be approximately equal

Independence
• No one subsequence in the sequence can
be inferred from the others

Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..


Unpredictability
• The requirement is not just that the sequence of
numbers be statistically random, but that the
successive members of the sequence are
unpredictable
• With “true” random sequences each number is
statistically independent of other numbers in the
sequence and therefore unpredictable
• True random numbers have their limitations, such
as inefficiency, so it is more common to implement
algorithms that generate sequences of numbers
that appear to be random
• Care must be taken that an opponent not be able to
predict future elements of the sequence on the
basis
Copyright © 2023 Pearson ofLtd.earlier
Education, elements
All Rights Reserved..
Pseudorandom
Numbers
• Cryptographic applications typically
make use of algorithmic techniques for
random number generation

• These algorithms are deterministic and


therefore produce sequences of
numbers that are not statistically
random

• If the algorithm is good, the resulting


sequences will pass many tests of
randomness and are referred to as
Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..
Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..
True Random
Number Generator
(TRNG)
• Takes as input a source that is effectively random

• The source is referred to as an entropy source and is


drawn from the physical environment of the computer
• Includes things such as keystroke timing patterns, disk
electrical activity, mouse movements, and
instantaneous values of the system clock
• The source, or combination of sources, serve as input
to an algorithm that produces random binary output

• The TRNG may simply involve conversion of an


analog source to a binary output
• The TRNG may involve additional processing to
overcome any bias in the source
Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..
Pseudorandom
Number Generator

(PRNG)
Takes as input a fixed value,
called the seed, and produces
Two different forms of PRNG
a sequence of output bits using
a deterministic algorithm
• Quite often the seed is Pseudorando Pseudorando
generated by a TRNG m number m function
generator (PRF)
• The output bit stream is • An algorithm • Used to produce
determined solely by the input that is used to a pseudorandom
value or values, so an produce an string of bits of
open-ended some fixed
adversary who knows the sequence of bits length
algorithm and the seed can • Input to a • Examples are
reproduce the entire bit stream symmetric symmetric
stream cipher is encryption keys
a common and nonces
• Other than the number of bits application for
produced there is no difference an open-ended
between a PRNG and a PRF sequence of bits

Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..


PRNG Requirements
• The basic requirement when a PRNG or PRF
is used for a cryptographic application is
that an adversary who does not know the
seed is unable to determine the
pseudorandom string
• The requirement for secrecy of the output
of a PRNG or PRF leads to specific
requirements in the areas of:
• Randomness
• Unpredictability
• Characteristics of the seed
Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..
Randomness
• The generated bit stream needs to appear random
even though it is deterministic
• There is no single test that can determine if a
PRNG generates numbers that have the
characteristic of randomness
• If the PRNG exhibits randomness on the basis of
multiple tests, then it can be assumed to satisfy the
randomness requirement

• NIST SP 800-22 specifies that the tests should seek


to establish three characteristics:
• Uniformity
• Scalability
• Consistency
Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..
Unpredictability
• A stream of pseudorandom numbers should exhibit two
forms of unpredictability:
• Forward unpredictability
• If the seed is unknown, the next output bit in the sequence
should be unpredictable in spite of any knowledge of previous
bits in the sequence
• Backward unpredictability
• It should not be feasible to determine the seed from
knowledge of any generated values
• No correlation between a seed and any value generated from
that seed should be evident
• Each element of the sequence should appear to be the
outcome of an independent random event whose probability
is 1/2

• The same set of tests for randomness also provides a test


of unpredictability
• A random sequence will have no correlation with a fixed
Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..
value (the seed)
Seed Requirements
• The seed that serves as input to the
PRNG must be secure and
unpredictable

• The seed itself must be a random or


pseudorandom number
• Typically the seed is generated by
TRNG

Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..


Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..
Algorithm Design
• Algorithms fall into two categories:
• Purpose-built algorithms
• Algorithms designed specifically and solely for the
purpose of generating pseudorandom bit streams
• Algorithms based on existing cryptographic
algorithms
• Have the effect of randomizing input data
Three broad categories of cryptographic algorithms
are commonly used to create PRNGs:
• Symmetric block ciphers
• Asymmetric ciphers
• Hash functions and message authentication codes

Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..


Linear Congruential
Generator
• An algorithm first proposed by Lehmer that is parameterized
with four numbers:
m the modulus m > 0
a the multiplier 0 < a< m
c the increment 0≤ c < m
X0 the starting value, or seed 0 ≤ X0 < m

• The sequence of random numbers {Xn} is obtained via the


following iterative equation:
Xn+1 = (aXn + c) mod m

• If m , a , c , and X0 are integers, then this technique will produce


a sequence of integers with each integer in the range 0 ≤ Xn < m

• The selection of values for a , c , and m is critical in developing


a good random number generator

Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..


Blum Blum Shub
(BBS) Generator
• Has perhaps the strongest public proof of its
cryptographic strength of any purpose-built
algorithm
• Referred to as a cryptographically secure
pseudorandom bit generator (CSPRBG)
• A CSPRBG is defined as one that passes the
next-bit-test if there is not a polynomial-time
algorithm that, on input of the first k bits of an
output sequence, can predict the (k + 1)st bit
with probability significantly greater than 1/2

• The security of BBS is based on the


Copyright © 2023difficulty of
Pearson Education, Ltd. All factoring
Rights Reserved.. n
Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..
n=192649 and seed s=101355

Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..


PRNG Using Block Cipher
Modes of Operation
• Two approaches that use a block cipher
to build a PNRG have gained
widespread acceptance:
• CTR mode
• Recommended in NIST SP 800-90, ANSI
standard X.82, and RFC 4086
• OFB mode
• Recommended in X9.82 and RFC 4086

Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..


Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..
Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..
Stream Cipher Design
Considerations
• A pseudorandom number generator uses a function
The encryption that produces a deterministic stream of bits that
sequence should have a eventually repeats; the longer the period of repeat the
large period more difficult it will be to do cryptanalysis

The keystream should • There should be an approximately equal number of 1s


approximate the and 0s
properties of a true • If the keystream is treated as a stream of bytes, then
random number stream all of the 256 possible byte values should appear
as close as possible approximately equally often

• The output of the pseudorandom number generator is


A key length of at least conditioned on the value of the input key
128 bits is desirable • The same considerations that apply to block ciphers
are valid

With a properly
designed pseudorandom
number generator a • A potential advantage is that stream ciphers that do
stream cipher can be as not use block ciphers as a building block are typically
secure as a block cipher faster and use far less code than block ciphers
of comparable key
length
Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..
RC4
• Designed in 1987 by Ron Rivest for RSA Security

• Variable key size stream cipher with byte-oriented operations

• Based on the use of a random permutation

• Eight to sixteen machine operations are required per output


byte and the cipher can be expected to run very quickly in
software

• RC4 is used in the WiFi Protected Access (WPA) protocol


that are part of the IEEE 802.11 wireless LAN standard
• It is optional for use in Secure Shell (SSH) and Kerberos

• RC4 was kept as a trade secret by RSA Security until


September 1994 when the RC4 algorithm was anonymously
posted on the Internet on the Cypherpunks anonymous
remailers list
Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..
Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..
Strength of RC4
• A fundamental vulnerability was revealed in the RC4
key scheduling algorithm that reduces the amount of
effort to discover the key
• Recent cryptanalysis results exploit biases in the
RC4 keystream to recover repeatedly encrypted
plaintexts
• As a result of the discovered weaknesses the IETF
issued RFC 7465 prohibiting the use of RC4 in TLS
• In its latest TLS guidelines, NIST also prohibited the
use of RC4 for government use
Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..
Stream Ciphers
Using Feedback Shift
Registers
With the increasing use of highly constrained devices there has
been increasing interest in developing new stream ciphers that take
up minimal memory, are highly efficient, and have minimal power
consumption requirements

Most of the recently developed stream ciphers are based on the use
of feedback shift registers (FSRs)

• FSRs exhibit the desired performance behavior, are well-suited to compact


hardware implementation, and there are well-developed theoretical results on the
statistical properties of the bit sequences they produce
• An FSR consists of a sequence of 1-bit memory cells
• Each cell has an output line, which indicates the value currently stored, and an
input line
• At discrete time instants, known as clock times, the value in each storage device
is replaced by the value indicated by its input line
• The effect is as follows: The rightmost (least significant) bit is shifted out as the
output bit for this clock cycle; the other bits are shifted one bit position to the
right; the new leftmost (most significant) bit is calculated as a function of the
other
Copyright bitsPearson
© 2023 in the Education,
FSR Ltd. All Rights Reserved..
Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..
Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..
Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..
Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..
Grain-128a
• Grain is a family of hardware-efficient stream ciphers
• Grain was accepted as part of the eSTREAM effort to approve a number
of new stream ciphers
• The eSTREAM specification, called Grain v1, defines two stream ciphers,
one with an 80-bit key and a 64-bit initialization vector (IV), and one with
a 128-bit key and 80-bit IV
• Grain has since been revised and expanded to include authentication,
referred to as Grain-128a
• The eSTREAM final report states that Grain has pushed the state of the
art in terms of compact implementation
• Grain-128a consists of two shift registers, one with linear feedback and
the second with nonlinear feedback, and a filter function
• The registers are couple by very lightweight, but judiciously chosen
Boolean functions
• The LFSR guarantees a minimum period for the keystream, and it also
provides balancedness in the output.
• The NFSR, together with a nonlinear filter, introduces nonlinearity to the
Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..
Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..
Entropy Sources
• A true random number generator (TRNG) uses a
nondeterministic source to produce randomness

• Most operate by measuring unpredictable natural


processes such as pulse detectors of ionizing radiation
events, gas discharge tubes, and leaky capacitors

• Intel has developed a commercially available chip that


samples thermal noise by amplifying the voltage
measured across undriven resistors

• LavaRnd is an open source project for creating truly


random numbers using inexpensive cameras, open
source code, and inexpensive hardware
• The system uses a saturated CCD in a light-tight can as a
chaotic source to produce the seed; software processes the
result into truly random numbers in a variety of formats
Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..
Possible Sources of
Randomness
RFC 4086 lists the following possible sources of
randomness that can be used on a computer
to generate true random sequences:

Sound/video
Disk drives
input
The input from a sound
digitizer with no source Have small random
plugged in or from a fluctuations in their
camera with the lens cap rotational speed due to
on is essentially thermal chaotic air turbulence
noise
The addition of low-level
If the system has enough
disk seek-time
gain to detect anything,
instrumentation produces
such input can provide
a series of measurements
reasonable high quality
that contain this
random bits
randomness

There is also an online service (random.org) which can deliver random sequences securely over
the©Internet
Copyright 2023 Pearson Education, Ltd. All Rights Reserved..
Table 8.5

Comparison of PRNGs and TRNGs

Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..


Conditioning
• A TRNG may produce an output that is biased in some way (such as
having more ones than zeros or vice versa)
• Biased
• NIST SP 800-90B defines a random process as biased with respect to an
assumed discrete set of potential outcomes if some of those outcomes
have a greater probability of occurring than do others
• Entropy rate
• NIST 800-90B defines entropy rate as the rate at which a digitized noise
source provides entropy
• Is a measure of the randomness or unpredictability of a bit string
• Will be a value between 0 (no entropy) and 1 (full entropy)
• Conditioning algorithms/deskewing algorithms
• Methods of modifying a bit stream to further randomize the bits
• Typically conditioning is done by using a cryptographic algorithm to
scramble the random bits so as to eliminate bias and increase
entropy
• The two most common approaches are the use of a hash function or a
symmetric block cipher
Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..
Hash Function
• A hash function produces an n-bit output
from an input of arbitrary length
• A simple way to use a hash function for
conditioning is as follows:
• Blocks of m input bits, with m ≥ n, are
passed through the hash function and the n
output bits are used as random bits
• To generate a stream of random bits,
successive input blocks pass through the
hash function to produce successive hashed
output blocks
Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..
Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..
Health Tests on the
Noise Source
• The nature of the health testing of the noise source
depends strongly on the technology used to produce
noise
• In general, the assumption can be made that the
digitized output of the noise source will exhibit some bias
• Thus, traditional statistical tests are not useful for
monitoring the noise source, because the noise source is
likely to always fail
• The tests on the noise source need to be tailored to the
expected statistical behavior of the correctly operating
noise source
• The goal is not to determine if the source is unbiased, but
if it is operating as expected

Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..


Health Tests on the
Noise Source
• SP 800-90B specifies that continuous tests be done on digitized
samples obtained from the noise source
• The purpose is to test for variability and to determine if the noise
source is producing at the expected entropy rate

• SP 800-90B mandates the use of two tests


• Repetition Count Test
• Designed to quickly detect a catastrophic failure that causes the
noise source to become “stuck” on a single output value for a long
time
• Involves looking for consecutive identical samples
• Adaptive Proportion Test
• Designed to detect a large loss of entropy, such as might occur as a
result of some physical failure or environmental change affecting the
noise source
• The test continuously measures the local frequency of occurrence of
some sample value in a sequence of noise source samples to
determine if the sample occurs too frequently

Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..


Health Tests on the
Conditioning
Function
SP 800-90B specifies that health tests
should also be applied to the output of
the conditioning component, but does
not indicate which tests to use

The purpose of the health tests on the


conditioning component is to assure that
the output behaves as a true random bit
stream

It is reasonable to use the tests for


randomness defined in SP 800-22

Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..


Intel Digital Random
Number Generator
• TRNGs have traditionally been used only for key
generation and other applications where only a
small number of random bits were required
• This is because TRNGs have generally been
inefficient with a low bit rate of random bit production

• The first commercially available TRNG that achieves


bit production rates comparable with that of PRNGs
is the Intel digital random number generator offered
on new multicore chips since May 2012
• It is implemented entirely in hardware
• The entire DRNG is on the same multicore chip as the
processors

Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..


Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..
Copyright © 2023 Pearson Education, Ltd. All Rights Reserved..
Summary
• Explain the concepts of
randomness and
• Understand the
unpredictability with
respect to random differences among
numbers true random
number
• Present an overview of
generators,
requirements for
pseudorandom number
pseudorandom
generators number
generators, and
• Explain the pseudorandom
significance of skew functions
• Present an overview of
stream ciphers and • Explain how a
RC4
Copyright © 2023 Pearson Education, Ltd. All Rights Reserved.. block cipher can be

You might also like