<s>
A	O
Cryptographically	B-Protocol
Generated	I-Protocol
Address	I-Protocol
(	O
CGA	O
)	O
is	O
an	O
Internet	B-Protocol
Protocol	I-Protocol
Version	I-Protocol
6	I-Protocol
(	O
IPv6	B-Protocol
)	O
address	O
that	O
has	O
a	O
host	O
identifier	O
computed	O
from	O
a	O
cryptographic	B-Algorithm
hash	I-Algorithm
function	I-Algorithm
.	O
</s>
<s>
This	O
procedure	O
is	O
a	O
method	O
for	O
binding	O
a	O
public	B-Application
signature	I-Application
key	I-Application
to	O
an	O
IPv6	B-Protocol
address	I-Protocol
in	O
the	O
Secure	B-Protocol
Neighbor	I-Protocol
Discovery	I-Protocol
Protocol	I-Protocol
(	O
SEND	O
)	O
.	O
</s>
<s>
A	O
Cryptographically	B-Protocol
Generated	I-Protocol
Address	I-Protocol
is	O
an	O
IPv6	B-Protocol
address	I-Protocol
whose	O
interface	O
identifier	O
has	O
been	O
generated	O
according	O
to	O
the	O
CGA	O
generation	O
method	O
.	O
</s>
<s>
The	O
interface	O
identifier	O
is	O
formed	O
by	O
the	O
least-significant	O
64	O
bits	O
of	O
an	O
IPv6	B-Protocol
address	I-Protocol
and	O
is	O
used	O
to	O
identify	O
the	O
host	O
's	O
network	O
interface	O
on	O
its	O
subnet	O
.	O
</s>
<s>
Apart	O
from	O
the	O
public	B-Application
key	I-Application
that	O
is	O
to	O
be	O
bound	O
to	O
the	O
CGA	O
,	O
the	O
CGA	O
generation	O
method	O
takes	O
several	O
other	O
input	O
parameters	O
including	O
the	O
predefined	O
subnet	O
prefix	O
.	O
</s>
<s>
modifier	O
:	O
a	O
random	O
128-bit	O
unsigned	B-Algorithm
integer	O
;	O
</s>
<s>
collCount	O
:	O
an	O
8-bit	O
unsigned	B-Algorithm
integer	O
that	O
must	O
be	O
0	O
,	O
1	O
,	O
or	O
2	O
;	O
</s>
<s>
publicKey	O
:	O
the	O
public	B-Application
key	I-Application
as	O
a	O
DER-encoded	O
ASN.1	B-Protocol
structure	O
of	O
the	O
type	O
SubjectPublicKeyInfo	O
;	O
</s>
<s>
This	O
is	O
a	O
3-bit	O
unsigned	B-Algorithm
integer	O
that	O
can	O
have	O
any	O
value	O
from	O
0	O
up	O
to	O
(	O
and	O
including	O
)	O
7	O
and	O
is	O
encoded	O
in	O
the	O
three	O
leftmost	O
bits	O
of	O
the	O
CGA	O
's	O
interface	O
identifier	O
.	O
</s>
<s>
For	O
convenience	O
,	O
the	O
intermediate	O
Sec	O
values	O
in	O
the	O
pseudocode	O
below	O
are	O
assumed	O
to	O
be	O
stored	O
as	O
8-bit	O
unsigned	B-Algorithm
integers	I-Algorithm
that	O
cannot	O
have	O
a	O
value	O
greater	O
than	O
7	O
.	O
</s>
<s>
The	O
following	O
piece	O
of	O
pseudocode	O
represents	O
the	O
CGA	O
generation	O
method	O
,	O
which	O
is	O
used	O
to	O
create	O
a	O
new	O
Cryptographically	B-Protocol
Generated	I-Protocol
Address	I-Protocol
.	O
</s>
<s>
The	O
Sec	O
parameter	O
implements	O
a	O
hash	B-Algorithm
extension	O
by	O
enforcing	O
the	O
first	O
16	O
times	O
Sec	O
bits	O
of	O
another	O
hash	B-Algorithm
,	O
Hash2	O
,	O
to	O
be	O
0	O
.	O
</s>
<s>
This	O
hash	B-Algorithm
is	O
the	O
result	O
of	O
the	O
digested	O
CGA	O
Parameters	O
data	O
structure	O
with	O
subnetPrefix	O
and	O
collCount	O
essentially	O
set	O
to	O
0	O
.	O
</s>
<s>
A	O
brute-force	B-Algorithm
search	I-Algorithm
is	O
performed	O
to	O
find	O
a	O
suitable	O
Hash2	O
,	O
incrementing	O
the	O
modifier	O
by	O
1	O
each	O
iteration	O
(	O
lines	O
6	O
to	O
15	O
)	O
.	O
</s>
<s>
For	O
a	O
similar	O
reason	O
,	O
subnetPrefix	O
is	O
not	O
used	O
either	O
so	O
that	O
if	O
the	O
subnet	O
prefix	O
of	O
the	O
address	O
changes	O
but	O
the	O
host	O
's	O
public	B-Application
key	I-Application
does	O
not	O
,	O
then	O
the	O
same	O
modifier	O
could	O
be	O
reused	O
and	O
there	O
is	O
no	O
need	O
to	O
search	O
for	O
a	O
new	O
Hash2	O
.	O
</s>
<s>
A	O
Cryptographically	B-Protocol
Generated	I-Protocol
Address	I-Protocol
is	O
used	O
to	O
verify	O
that	O
received	O
signed	O
messages	O
were	O
sent	O
by	O
the	O
host	O
to	O
which	O
that	O
address	O
has	O
been	O
assigned	O
.	O
</s>
<s>
This	O
is	O
done	O
by	O
verifying	O
that	O
the	O
key	B-Application
pair	I-Application
used	O
for	O
signing	O
has	O
been	O
bound	O
to	O
the	O
CGA	O
.	O
</s>
<s>
Because	O
the	O
authenticity	O
of	O
the	O
public	B-Application
key	I-Application
can	O
be	O
verified	O
this	O
way	O
,	O
there	O
is	O
no	O
need	O
for	O
a	O
public	B-Application
key	I-Application
infrastructure	O
.	O
</s>
<s>
If	O
the	O
host	O
itself	O
is	O
required	O
to	O
be	O
authenticated	O
as	O
well	O
,	O
however	O
,	O
then	O
the	O
CGA	O
itself	O
needs	O
to	O
be	O
authenticated	O
beforehand	O
since	O
the	O
bound	O
public	B-Application
key	I-Application
cannot	O
be	O
trusted	O
if	O
the	O
address	O
is	O
not	O
trusted	O
in	O
such	O
a	O
case	O
(	O
assuming	O
it	O
has	O
not	O
been	O
verified	O
by	O
other	O
methods	O
than	O
CGA	O
)	O
.	O
</s>
<s>
The	O
CGA	O
verification	O
method	O
,	O
in	O
which	O
a	O
public	B-Application
key	I-Application
is	O
verified	O
to	O
be	O
bound	O
to	O
a	O
CGA	O
,	O
requires	O
the	O
corresponding	O
CGA	O
Parameters	O
data	O
structure	O
as	O
input	O
and	O
can	O
be	O
implemented	O
as	O
follows	O
.	O
</s>
<s>
From	O
line	O
6	O
to	O
18	O
,	O
Hash1	O
is	O
calculated	O
from	O
the	O
CGA	O
Parameters	O
data	O
structure	O
(	O
which	O
includes	O
the	O
public	B-Application
key	I-Application
and	O
the	O
subnet	O
prefix	O
)	O
and	O
the	O
relevant	O
bits	O
are	O
compared	O
to	O
those	O
of	O
the	O
CGA	O
's	O
interface	O
identifier	O
.	O
</s>
<s>
After	O
extracting	O
Sec	O
from	O
the	O
CGA	O
's	O
interface	O
identifier	O
,	O
Hash2	O
is	O
calculated	O
and	O
the	O
first	O
16	O
times	O
Sec	O
bits	O
of	O
the	O
hash	B-Algorithm
are	O
compared	O
to	O
0	O
(	O
lines	O
22	O
to	O
30	O
)	O
.	O
</s>
<s>
If	O
all	O
checks	O
turn	O
out	O
well	O
,	O
then	O
the	O
public	B-Application
key	I-Application
has	O
been	O
verified	O
to	O
be	O
bound	O
to	O
(	O
i.e.	O
</s>
<s>
In	O
order	O
for	O
an	O
attacker	B-General_Concept
to	O
make	O
a	O
client	B-Protocol
believe	O
it	O
received	O
a	O
valid	O
message	O
from	O
a	O
certain	O
CGA	O
that	O
is	O
n't	O
owned	O
by	O
the	O
attacker	B-General_Concept
,	O
the	O
attacker	B-General_Concept
must	O
find	O
a	O
hash	B-Algorithm
collision	I-Algorithm
for	O
the	O
relevant	O
bits	O
of	O
Hash1	O
and	O
Hash2	O
by	O
performing	O
a	O
brute-force	O
attack	O
.	O
</s>
<s>
If	O
the	O
attacker	B-General_Concept
finds	O
a	O
set	O
of	O
CGA	O
Parameters	O
(	O
including	O
a	O
public	B-Application
key	I-Application
for	O
which	O
the	O
attacker	B-General_Concept
knows	O
the	O
private	B-Application
key	I-Application
)	O
that	O
can	O
be	O
used	O
to	O
generate	O
the	O
same	O
CGA	O
as	O
the	O
target	O
CGA	O
,	O
then	O
the	O
attacker	B-General_Concept
can	O
impersonate	O
the	O
host	O
who	O
actually	O
owns	O
the	O
CGA	O
without	O
being	O
detected	O
(	O
except	O
perhaps	O
when	O
the	O
client	B-Protocol
has	O
contacted	O
the	O
host	O
before	O
and	O
notices	O
that	O
the	O
public	B-Application
key	I-Application
has	O
changed	O
but	O
the	O
CGA	O
has	O
not	O
)	O
.	O
</s>
<s>
it	O
implements	O
a	O
hash	B-Algorithm
extension	O
by	O
demanding	O
those	O
bits	O
to	O
be	O
equal	O
to	O
0	O
)	O
.	O
</s>
<s>
Because	O
Sec	O
is	O
not	O
part	O
of	O
the	O
CGA	O
Parameters	O
data	O
structure	O
but	O
of	O
the	O
address	O
itself	O
,	O
an	O
attacker	B-General_Concept
cannot	O
use	O
a	O
Sec	O
value	O
smaller	O
than	O
that	O
of	O
the	O
target	O
address	O
(	O
like	O
0	O
)	O
in	O
an	O
attempt	O
to	O
skip	O
(	O
or	O
scale	O
down	O
)	O
the	O
brute-force	O
attack	O
on	O
Hash2	O
.	O
</s>
<s>
This	O
parameter	O
must	O
be	O
verified	O
to	O
be	O
in	O
this	O
range	O
during	O
the	O
CGA	O
verification	O
process	O
in	O
order	O
to	O
prevent	O
an	O
attacker	B-General_Concept
from	O
exploiting	O
it	O
and	O
trying	O
all	O
different	O
values	O
without	O
the	O
need	O
to	O
perform	O
another	O
brute-force	B-Algorithm
search	I-Algorithm
for	O
Hash2	O
each	O
time	O
a	O
different	O
value	O
is	O
tried	O
.	O
</s>
<s>
By	O
including	O
the	O
subnet	O
prefix	O
in	O
the	O
digest	O
operation	O
that	O
results	O
in	O
Hash1	O
,	O
it	O
can	O
be	O
prevented	O
that	O
an	O
attacker	B-General_Concept
is	O
able	O
to	O
use	O
a	O
single	O
pre-computed	O
database	O
to	O
attack	O
addresses	O
with	O
different	O
subnet	O
prefixes	O
.	O
</s>
<s>
A	O
verifier	O
can	O
also	O
be	O
sure	O
that	O
the	O
public	B-Application
key	I-Application
has	O
been	O
bound	O
to	O
this	O
exact	O
address	O
and	O
not	O
possibly	O
to	O
an	O
address	O
with	O
the	O
same	O
interface	O
identifier	O
but	O
a	O
different	O
subnet	O
prefix	O
.	O
</s>
