<s>
In	O
cryptography	O
,	O
an	O
alternating	B-Algorithm
step	I-Algorithm
generator	I-Algorithm
(	O
ASG	O
)	O
is	O
a	O
cryptographic	B-Algorithm
pseudorandom	I-Algorithm
number	I-Algorithm
generator	I-Algorithm
used	O
in	O
stream	B-Algorithm
ciphers	I-Algorithm
,	O
based	O
on	O
three	O
linear-feedback	B-Architecture
shift	I-Architecture
registers	I-Architecture
.	O
</s>
<s>
Its	O
output	O
is	O
a	O
combination	O
of	O
two	O
LFSRs	B-Architecture
which	O
are	O
stepped	O
(	O
clocked	O
)	O
in	O
an	O
alternating	O
fashion	O
,	O
depending	O
on	O
the	O
output	O
of	O
a	O
third	O
LFSR	B-Architecture
.	O
</s>
<s>
The	O
design	O
was	O
published	O
in	O
1987	O
and	O
patented	O
in	O
1989	O
by	O
C	B-Language
.	O
G	O
.	O
Günther	O
.	O
</s>
<s>
Linear-feedback	B-Architecture
shift	I-Architecture
registers	I-Architecture
(	O
LFSRs	B-Architecture
)	O
are	O
,	O
statistically	O
speaking	O
,	O
excellent	O
pseudorandom	O
generators	O
,	O
with	O
good	O
distribution	O
and	O
simple	O
implementation	O
.	O
</s>
<s>
An	O
ASG	O
comprises	O
three	O
linear-feedback	B-Architecture
shift	I-Architecture
registers	I-Architecture
,	O
which	O
we	O
will	O
call	O
LFSR0	O
,	O
LFSR1	O
and	O
LFSR2	O
for	O
convenience	O
.	O
</s>
<s>
The	O
initial	O
state	O
of	O
the	O
three	O
LFSRs	B-Architecture
is	O
the	O
key	O
.	O
</s>
<s>
Customarily	O
,	O
the	O
LFSRs	B-Architecture
use	O
primitive	O
polynomials	O
of	O
distinct	O
but	O
close	O
degree	O
,	O
preset	O
to	O
non-zero	O
state	O
,	O
so	O
that	O
each	O
LFSR	B-Architecture
generates	O
a	O
maximum	O
length	O
sequence	O
.	O
</s>
<s>
Example	O
code	O
in	O
C	B-Language
:	O
</s>
<s>
In	O
particular	O
,	O
contrary	O
to	O
the	O
shrinking	B-Algorithm
generator	I-Algorithm
and	O
self-shrinking	B-Algorithm
generator	I-Algorithm
,	O
an	O
output	O
bit	O
is	O
produced	O
at	O
each	O
clock	O
,	O
ensuring	O
consistent	O
performance	O
and	O
resistance	O
to	O
timing	O
attacks	O
.	O
</s>
<s>
with	O
asymptotic	O
complexity	O
and	O
bits	O
,	O
where	O
is	O
the	O
size	O
of	O
the	O
shortest	O
of	O
the	O
three	O
LFSRs	B-Architecture
.	O
</s>
