<s>
In	O
cryptography	O
,	O
a	O
one-way	B-Algorithm
compression	I-Algorithm
function	I-Algorithm
is	O
a	O
function	O
that	O
transforms	O
two	O
fixed-length	O
inputs	O
into	O
a	O
fixed-length	O
output	O
.	O
</s>
<s>
One-way	B-Algorithm
compression	I-Algorithm
functions	I-Algorithm
are	O
not	O
related	O
to	O
conventional	O
data	B-General_Concept
compression	I-General_Concept
algorithms	I-General_Concept
,	O
which	O
instead	O
can	O
be	O
inverted	O
exactly	O
(	O
lossless	O
compression	O
)	O
or	O
approximately	O
(	O
lossy	O
compression	O
)	O
to	O
the	O
original	O
data	O
.	O
</s>
<s>
One-way	B-Algorithm
compression	I-Algorithm
functions	I-Algorithm
are	O
for	O
instance	O
used	O
in	O
the	O
Merkle	B-Algorithm
–	I-Algorithm
Damgård	I-Algorithm
construction	I-Algorithm
inside	O
cryptographic	B-Algorithm
hash	I-Algorithm
functions	I-Algorithm
.	O
</s>
<s>
One-way	B-Algorithm
compression	I-Algorithm
functions	I-Algorithm
are	O
often	O
built	O
from	O
block	O
ciphers	O
.	O
</s>
<s>
Some	O
methods	O
to	O
turn	O
any	O
normal	O
block	O
cipher	O
into	O
a	O
one-way	B-Algorithm
compression	I-Algorithm
function	I-Algorithm
are	O
Davies	O
–	O
Meyer	O
,	O
Matyas	O
–	O
Meyer	O
–	O
Oseas	O
,	O
Miyaguchi	O
–	O
Preneel	O
(	O
single-block-length	O
compression	O
functions	O
)	O
and	O
MDC-2/Meyer	O
–	O
Schilling	O
,	O
MDC-4	O
,	O
Hirose	O
(	O
double-block-length	O
compression	O
functions	O
)	O
.	O
</s>
<s>
(	O
MDC-2	B-Algorithm
is	O
also	O
the	O
name	O
of	O
a	O
hash	B-Algorithm
function	I-Algorithm
patented	O
by	O
IBM	O
.	O
)	O
</s>
<s>
A	O
one-way	B-Algorithm
compression	I-Algorithm
function	I-Algorithm
(	O
also	O
called	O
hash	B-Algorithm
function	I-Algorithm
)	O
should	O
have	O
the	O
following	O
properties	O
:	O
</s>
<s>
Due	O
to	O
the	O
birthday	O
paradox	O
(	O
see	O
also	O
birthday	O
attack	O
)	O
there	O
is	O
a	O
50%	O
chance	O
a	O
collision	O
can	O
be	O
found	O
in	O
time	O
of	O
about	O
where	O
is	O
the	O
number	O
of	O
bits	O
in	O
the	O
hash	B-Algorithm
function	I-Algorithm
's	O
output	O
.	O
</s>
<s>
An	O
attack	O
on	O
the	O
hash	B-Algorithm
function	I-Algorithm
thus	O
should	O
not	O
be	O
able	O
to	O
find	O
a	O
collision	O
with	O
less	O
than	O
about	O
work	O
.	O
</s>
<s>
Ideally	O
one	O
would	O
like	O
the	O
"	O
infeasibility	O
"	O
in	O
preimage-resistance	O
and	O
second	O
preimage-resistance	O
to	O
mean	O
a	O
work	O
of	O
about	O
where	O
is	O
the	O
number	O
of	O
bits	O
in	O
the	O
hash	B-Algorithm
function	I-Algorithm
's	O
output	O
.	O
</s>
<s>
A	O
common	O
use	O
of	O
one-way	B-Algorithm
compression	I-Algorithm
functions	I-Algorithm
is	O
in	O
the	O
Merkle	B-Algorithm
–	I-Algorithm
Damgård	I-Algorithm
construction	I-Algorithm
inside	O
cryptographic	B-Algorithm
hash	I-Algorithm
functions	I-Algorithm
.	O
</s>
<s>
Most	O
widely	O
used	O
hash	B-Algorithm
functions	I-Algorithm
,	O
including	O
MD5	B-Algorithm
,	O
SHA-1	B-Algorithm
(	O
which	O
is	O
deprecated	O
)	O
and	O
SHA-2	B-Algorithm
use	O
this	O
construction	O
.	O
</s>
<s>
A	O
hash	B-Algorithm
function	I-Algorithm
must	O
be	O
able	O
to	O
process	O
an	O
arbitrary-length	O
message	O
into	O
a	O
fixed-length	O
output	O
.	O
</s>
<s>
This	O
can	O
be	O
achieved	O
by	O
breaking	O
the	O
input	O
up	O
into	O
a	O
series	O
of	O
equal-sized	O
blocks	O
,	O
and	O
operating	O
on	O
them	O
in	O
sequence	O
using	O
a	O
one-way	B-Algorithm
compression	I-Algorithm
function	I-Algorithm
.	O
</s>
<s>
The	O
last	O
block	O
processed	O
should	O
also	O
be	O
length	B-Algorithm
padded	I-Algorithm
,	O
which	O
is	O
crucial	O
to	O
the	O
security	O
of	O
this	O
construction	O
.	O
</s>
<s>
When	O
length	O
padding	B-Algorithm
(	O
also	O
called	O
MD-strengthening	O
)	O
is	O
applied	O
,	O
attacks	O
cannot	O
find	O
collisions	O
faster	O
than	O
the	O
birthday	O
paradox	O
(	O
,	O
being	O
the	O
block	O
size	O
in	O
bits	O
)	O
if	O
the	O
used	O
function	O
is	O
collision-resistant	O
.	O
</s>
<s>
Hence	O
,	O
the	O
Merkle	B-Algorithm
–	I-Algorithm
Damgård	I-Algorithm
hash	B-Algorithm
construction	O
reduces	O
the	O
problem	O
of	O
finding	O
a	O
proper	O
hash	B-Algorithm
function	I-Algorithm
to	O
finding	O
a	O
proper	O
compression	O
function	O
.	O
</s>
<s>
One-way	B-Algorithm
compression	I-Algorithm
functions	I-Algorithm
are	O
often	O
built	O
from	O
block	O
ciphers	O
.	O
</s>
<s>
Block	O
ciphers	O
take	O
(	O
like	O
one-way	B-Algorithm
compression	I-Algorithm
functions	I-Algorithm
)	O
two	O
fixed	O
size	O
inputs	O
(	O
the	O
key	O
and	O
the	O
plaintext	O
)	O
and	O
return	O
one	O
single	O
output	O
(	O
the	O
ciphertext	O
)	O
which	O
is	O
the	O
same	O
size	O
as	O
the	O
input	O
plaintext	O
.	O
</s>
<s>
Thus	O
,	O
to	O
turn	O
a	O
block	O
cipher	O
into	O
a	O
one-way	B-Algorithm
compression	I-Algorithm
function	I-Algorithm
some	O
extra	O
operations	O
have	O
to	O
be	O
added	O
.	O
</s>
<s>
Some	O
methods	O
to	O
turn	O
any	O
normal	O
block	O
cipher	O
into	O
a	O
one-way	B-Algorithm
compression	I-Algorithm
function	I-Algorithm
are	O
Davies	O
–	O
Meyer	O
,	O
Matyas	O
–	O
Meyer	O
–	O
Oseas	O
,	O
Miyaguchi	O
–	O
Preneel	O
(	O
single-block-length	O
compression	O
functions	O
)	O
and	O
MDC-2	B-Algorithm
,	O
MDC-4	O
,	O
Hirose	O
(	O
double-block-length	O
compressions	O
functions	O
)	O
.	O
</s>
<s>
If	O
a	O
block	O
cipher	O
has	O
a	O
block	O
size	O
of	O
say	O
128	O
bits	O
single-block-length	O
methods	O
create	O
a	O
hash	B-Algorithm
function	I-Algorithm
that	O
has	O
the	O
block	O
size	O
of	O
128	O
bits	O
and	O
produces	O
a	O
hash	B-Algorithm
of	O
128	O
bits	O
.	O
</s>
<s>
Double-block-length	O
methods	O
make	O
hashes	B-Algorithm
with	O
double	O
the	O
hash	B-Algorithm
size	O
compared	O
to	O
the	O
block	O
size	O
of	O
the	O
block	O
cipher	O
used	O
.	O
</s>
<s>
So	O
a	O
128-bit	O
block	O
cipher	O
can	O
be	O
turned	O
into	O
a	O
256-bit	O
hash	B-Algorithm
function	I-Algorithm
.	O
</s>
<s>
These	O
methods	O
are	O
then	O
used	O
inside	O
the	O
Merkle	B-Algorithm
–	I-Algorithm
Damgård	I-Algorithm
construction	I-Algorithm
to	O
build	O
the	O
actual	O
hash	B-Algorithm
function	I-Algorithm
.	O
</s>
<s>
Using	O
a	O
block	O
cipher	O
to	O
build	O
the	O
one-way	B-Algorithm
compression	I-Algorithm
function	I-Algorithm
for	O
a	O
hash	B-Algorithm
function	I-Algorithm
is	O
usually	O
somewhat	O
slower	O
than	O
using	O
a	O
specially	O
designed	O
one-way	B-Algorithm
compression	I-Algorithm
function	I-Algorithm
in	O
the	O
hash	B-Algorithm
function	I-Algorithm
.	O
</s>
<s>
This	O
is	O
because	O
all	O
known	O
secure	O
constructions	O
do	O
the	O
key	B-Algorithm
scheduling	I-Algorithm
for	O
each	O
block	O
of	O
the	O
message	O
.	O
</s>
<s>
Black	O
,	O
Cochran	O
and	O
Shrimpton	O
have	O
shown	O
that	O
it	O
is	O
impossible	O
to	O
construct	O
a	O
one-way	B-Algorithm
compression	I-Algorithm
function	I-Algorithm
that	O
makes	O
only	O
one	O
call	O
to	O
a	O
block	O
cipher	O
with	O
a	O
fixed	O
key	O
.	O
</s>
<s>
In	O
practice	O
reasonable	O
speeds	O
are	O
achieved	O
provided	O
the	O
key	B-Algorithm
scheduling	I-Algorithm
of	O
the	O
selected	O
block	O
cipher	O
is	O
not	O
a	O
too	O
heavy	O
operation	O
.	O
</s>
<s>
But	O
,	O
in	O
some	O
cases	O
it	O
is	O
easier	O
because	O
a	O
single	O
implementation	O
of	O
a	O
block	O
cipher	O
can	O
be	O
used	O
for	O
both	O
a	O
block	O
cipher	O
and	O
a	O
hash	B-Algorithm
function	I-Algorithm
.	O
</s>
<s>
It	O
can	O
also	O
save	O
code	B-Language
space	O
in	O
very	O
tiny	O
embedded	B-Architecture
systems	I-Architecture
like	O
for	O
instance	O
smart	O
cards	O
or	O
nodes	B-Device
in	I-Device
cars	I-Device
or	O
other	O
machines	O
.	O
</s>
<s>
Therefore	O
,	O
the	O
hash-rate	O
or	O
rate	O
gives	O
a	O
glimpse	O
of	O
the	O
efficiency	O
of	O
a	O
hash	B-Algorithm
function	I-Algorithm
based	O
on	O
a	O
certain	O
compression	O
function	O
.	O
</s>
<s>
The	O
rate	O
of	O
an	O
iterated	O
hash	B-Algorithm
function	I-Algorithm
outlines	O
the	O
ratio	O
between	O
the	O
number	O
of	O
block	O
cipher	O
operations	O
and	O
the	O
output	O
.	O
</s>
<s>
Generally	O
,	O
the	O
usage	O
of	O
fewer	O
block	O
cipher	O
operations	O
results	O
in	O
a	O
better	O
overall	O
performance	O
of	O
the	O
entire	O
hash	B-Algorithm
function	I-Algorithm
,	O
but	O
it	O
also	O
leads	O
to	O
a	O
smaller	O
hash-value	O
which	O
could	O
be	O
undesirable	O
.	O
</s>
<s>
The	O
hash	B-Algorithm
function	I-Algorithm
can	O
only	O
be	O
considered	O
secure	O
if	O
at	O
least	O
the	O
following	O
conditions	O
are	O
met	O
:	O
</s>
<s>
The	O
resulting	O
hash	B-Algorithm
size	O
is	O
big	O
enough	O
.	O
</s>
<s>
According	O
to	O
the	O
birthday	O
attack	O
a	O
security	O
level	O
of	O
280	O
(	O
generally	O
assumed	O
to	O
be	O
infeasible	O
to	O
compute	O
today	O
)	O
is	O
desirable	O
thus	O
the	O
hash	B-Algorithm
size	O
should	O
be	O
at	O
least	O
160	O
bits	O
.	O
</s>
<s>
The	O
last	O
block	O
is	O
properly	O
length	B-Algorithm
padded	I-Algorithm
prior	O
to	O
the	O
hashing	O
.	O
</s>
<s>
(	O
See	O
Merkle	B-Algorithm
–	I-Algorithm
Damgård	I-Algorithm
construction	I-Algorithm
.	O
)	O
</s>
<s>
Length	O
padding	B-Algorithm
is	O
normally	O
implemented	O
and	O
handled	O
internally	O
in	O
specialised	O
hash	B-Algorithm
functions	I-Algorithm
like	O
SHA-1	B-Algorithm
etc	O
.	O
</s>
<s>
The	O
algorithm	O
returns	O
1	O
,	O
if	O
two	O
responses	O
result	O
in	O
a	O
collision	O
involving	O
the	O
hash	B-Algorithm
function	I-Algorithm
that	O
is	O
built	O
from	O
a	O
compression	O
function	O
applying	O
this	O
block	O
cipher	O
(	O
0	O
else	O
)	O
.	O
</s>
<s>
It	O
feeds	O
the	O
previous	O
hash	B-Algorithm
value	O
(	O
)	O
as	O
the	O
plaintext	O
to	O
be	O
encrypted	O
.	O
</s>
<s>
The	O
output	O
ciphertext	O
is	O
then	O
also	O
XORed	O
( ⊕	O
)	O
with	O
the	O
previous	O
hash	B-Algorithm
value	O
(	O
)	O
to	O
produce	O
the	O
next	O
hash	B-Algorithm
value	O
(	O
)	O
.	O
</s>
<s>
In	O
the	O
first	O
round	O
when	O
there	O
is	O
no	O
previous	O
hash	B-Algorithm
value	O
it	O
uses	O
a	O
constant	O
pre-specified	O
initial	O
value	O
(	O
)	O
.	O
</s>
<s>
If	O
the	O
same	O
block	O
cipher	O
uses	O
a	O
block	O
size	O
of	O
128	O
bits	O
then	O
the	O
input	O
and	O
output	O
hash	B-Algorithm
values	O
in	O
each	O
round	O
is	O
128	O
bits	O
.	O
</s>
<s>
The	O
Matyas	O
–	O
Meyer	O
–	O
Oseas	O
single-block-length	O
one-way	B-Algorithm
compression	I-Algorithm
function	I-Algorithm
can	O
be	O
considered	O
the	O
dual	O
(	O
the	O
opposite	O
)	O
of	O
Davies	O
–	O
Meyer	O
.	O
</s>
<s>
The	O
output	O
ciphertext	O
is	O
then	O
also	O
XORed	O
( ⊕	O
)	O
with	O
the	O
same	O
message	O
block	O
(	O
)	O
to	O
produce	O
the	O
next	O
hash	B-Algorithm
value	O
(	O
)	O
.	O
</s>
<s>
The	O
previous	O
hash	B-Algorithm
value	O
(	O
)	O
is	O
fed	O
as	O
the	O
key	O
to	O
the	O
block	O
cipher	O
.	O
</s>
<s>
In	O
the	O
first	O
round	O
when	O
there	O
is	O
no	O
previous	O
hash	B-Algorithm
value	O
it	O
uses	O
a	O
constant	O
pre-specified	O
initial	O
value	O
(	O
)	O
.	O
</s>
<s>
If	O
the	O
block	O
cipher	O
has	O
different	O
block	O
and	O
key	O
sizes	O
the	O
hash	B-Algorithm
value	O
(	O
)	O
will	O
have	O
the	O
wrong	O
size	O
for	O
use	O
as	O
the	O
key	O
.	O
</s>
<s>
Then	O
the	O
hash	B-Algorithm
value	O
is	O
first	O
fed	O
through	O
the	O
function	O
to	O
be	O
converted/padded	O
to	O
fit	O
as	O
key	O
for	O
the	O
cipher	O
.	O
</s>
<s>
The	O
Miyaguchi	O
–	O
Preneel	O
single-block-length	O
one-way	B-Algorithm
compression	I-Algorithm
function	I-Algorithm
is	O
an	O
extended	O
variant	O
of	O
Matyas	O
–	O
Meyer	O
–	O
Oseas	O
.	O
</s>
<s>
The	O
output	O
ciphertext	O
is	O
then	O
XORed	O
( ⊕	O
)	O
with	O
the	O
same	O
message	O
block	O
(	O
)	O
and	O
then	O
also	O
XORed	O
with	O
the	O
previous	O
hash	B-Algorithm
value	O
(	O
)	O
to	O
produce	O
the	O
next	O
hash	B-Algorithm
value	O
(	O
)	O
.	O
</s>
<s>
The	O
previous	O
hash	B-Algorithm
value	O
(	O
)	O
is	O
fed	O
as	O
the	O
key	O
to	O
the	O
block	O
cipher	O
.	O
</s>
<s>
In	O
the	O
first	O
round	O
when	O
there	O
is	O
no	O
previous	O
hash	B-Algorithm
value	O
it	O
uses	O
a	O
constant	O
pre-specified	O
initial	O
value	O
(	O
)	O
.	O
</s>
<s>
If	O
the	O
block	O
cipher	O
has	O
different	O
block	O
and	O
key	O
sizes	O
the	O
hash	B-Algorithm
value	O
(	O
)	O
will	O
have	O
the	O
wrong	O
size	O
for	O
use	O
as	O
the	O
key	O
.	O
</s>
<s>
Then	O
the	O
hash	B-Algorithm
value	O
is	O
first	O
fed	O
through	O
the	O
function	O
to	O
be	O
converted/padded	O
to	O
fit	O
as	O
key	O
for	O
the	O
cipher	O
.	O
</s>
<s>
The	O
Hirose	O
double-block-length	O
one-way	B-Algorithm
compression	I-Algorithm
function	I-Algorithm
consists	O
of	O
a	O
block	O
cipher	O
plus	O
a	O
permutation	O
.	O
</s>
<s>
It	O
uses	O
a	O
block	O
cipher	O
whose	O
key	O
length	O
is	O
larger	O
than	O
the	O
block	O
length	O
,	O
and	O
produces	O
a	O
hash	B-Algorithm
of	O
size	O
.	O
</s>
<s>
For	O
example	O
,	O
any	O
of	O
the	O
AES	B-Algorithm
candidates	O
with	O
a	O
192	O
-	O
or	O
256-bit	O
key	O
(	O
and	O
128-bit	O
block	O
)	O
.	O
</s>
<s>
The	O
advantage	O
of	O
this	O
scheme	O
over	O
other	O
proposed	O
double-block-length	O
schemes	O
is	O
that	O
both	O
encryptions	O
use	O
the	O
same	O
key	O
,	O
and	O
thus	O
key	B-Algorithm
scheduling	I-Algorithm
effort	O
may	O
be	O
shared	O
.	O
</s>
<s>
The	O
sponge	B-Algorithm
construction	I-Algorithm
can	O
be	O
used	O
to	O
build	O
one-way	B-Algorithm
compression	I-Algorithm
functions	I-Algorithm
.	O
</s>
