08 Odds and Ends v2 Annotated PDF
08 Odds and Ends v2 Annotated PDF
Key Deriva1on
Dan
Boneh
Deriving
many
keys
from
one
Typical
scenario.
a
single
source
key
(SK)
is
sampled
from:
• Hardware
random
number
generator
• A
key
exchange
protocol
(discussed
later)
Even
if
two
apps
sample
same
SK
they
get
indep.
keys
It’s
good
prac1ce
to
label
strings
with
the
app.
name
It
serves
no
purpose
What
if
source
key
is
not
uniform?
Recall:
PRFs
are
pseudo
random
only
when
key
is
uniform
in
K
•
SK
not
uniform
⇒
PRF
output
may
not
look
random
Dan
Boneh
Extract-‐then-‐Expand
paradigm
Step
1:
extract
pseudo-‐random
key
k
from
source
key
SK
prob
prob
extractor
SK
k
salt
salt:
a
fixed
non-‐secret
string
chosen
at
random
step
2:
expand
k
by
using
it
as
a
PRF
key
as
before
Dan
Boneh
HKDF:
a
KDF
from
HMAC
Implements
the
extract-‐then-‐expand
paradigm:
• extract:
use
k
⟵
HMAC(
salt,
SK
)
Dan
Boneh
Password-‐Based
KDF
(PBKDF)
Deriving
keys
from
passwords:
• Do
not
use
HKDF:
passwords
have
insufficient
entropy
• Derived
keys
will
be
vulnerable
to
dic1onary
aaacks
(more
on
this
later)
Dan
Boneh
Online
Cryptography
Course
Dan
Boneh
Determinis1c Encryp1on
Dan
Boneh
The
need
for
det.
Encryp1on
(no
nonce)
Alice data ??
Dan
Boneh
The
need
for
det.
Encryp1on
(no
nonce)
??
Alice
data
k1,
k2
Bob
data
,
“A lic e ”)
⋮
Later:
o rd
E(k 1
i eve
rec encrypted
Retr database
data
Alice
det.
enc.
enables
later
lookup
Dan
Boneh
Problem:
det.
enc.
cannot
be
CPA
secure
The
problem:
aaacker
can
tell
when
two
ciphertexts
encrypt
the
same
message
⇒
leaks
informa1on
equal
ciphertexts
means
same
index
Dan
Boneh
Problem:
det.
enc.
cannot
be
CPA
secure
The
problem:
aaacker
can
tell
when
two
ciphertexts
encrypt
the
same
message
⇒
leaks
informa1on
b
Chal.
m0
,
m0
∈
M
Adv.
c0
←E(k,
m0)
k←K
m0
,
m1
∈
M
output
0
c
←
E(k,
mb)
if
c
=
c0
Dan
Boneh
A
solu1on:
the
case
of
unique
messages
Suppose
encryptor
never
encrypts
same
message
twice:
the
pair
(k
,
m)
never
repeats
This
happens
when
encryptor:
• Chooses
messages
at
random
from
a
large
msg
space
(e.g.
keys)
• Message
structure
ensures
uniqueness
(e.g.
unique
user
ID)
Dan
Boneh
Determinis1c
CPA
security
E =
(E,D)
a
cipher
defined
over
(K,M,C). For
b=0,1
define
EXP(b)
as:
for
i=1,…,q:
b
Chal.
Adv.
k←K
mi,0
,
mi,1
∈
M
:
|mi,0|
=
|mi,1|
where m1,0, …, mq,0 are dis1nct and m1,1, …, mq,1 are dis1nct
Def:
E
is
sem.
sec.
under
det.
CPA
if
for
all
efficient
A:
AdvdCPA
[A,E]
=
|Pr[EXP(0)=1]
–
Pr[EXP(1)=1]
|
is
negligible.
Dan
Boneh
A
Common
Mistake
CBC
with
fixed
IV
is
not
det.
CPA
secure.
Let
E:
K
×
{0,1}n
⟶
{0,1}n
be
a
secure
PRP
used
in
CBC
ciphertext
Yes
b
No
m
,
m
Adv.
Chal.
c
←m⨁F(k,
FIV)
It
depends
k←K
m0
,
m1
output
0
if
c’
←
mb⨁F(k,
FIV)
c⨁c’=m⨁m0
End
of
Segment
Dan
Boneh
Online
Cryptography
Course
Dan
Boneh
Determinis1c
Encryp1on
Construc1ons:
SIV
and
wide
PRP
Dan
Boneh
Determinis1c
encryp1on
Needed
for
maintaining
an
encrypted
database
index
• Lookup
records
by
encrypted
index
PRF
F
message
k1
CTR
mode
with
PRF
Fctr
k2
Fctr(k2,
IV)
ll
Fctr(k2,
IV+1)
ll
…
ll
Fctr(k2,
IV+L)
IV
ciphertext
Dan
Boneh
Det.
Auth.
Enc.
(DAE)
for
free
DecrypJon:
IV
ciphertext
CTR
mode
with
PRF
Fctr
k2
Fctr(k2,IV)
ll
Fctr(k2,
IV+1)
ll
…
ll
Fctr(k2,IV+L)
k1
PRF
F
message
if
≠IV
output
⊥
Thm:
if
F
is
a
secure
PRF
and
CTR
from
Fctr
is
CPA-‐secure
then
SIV-‐CTR
from
F,
Fctr
provides
DAE
Dan
Boneh
Construc1on
2:
just
use
a
PRP
Let
(E,
D)
be
a
secure
PRP.
E:
K
×
X
⟶
X
E
E
E
E
⨁
⨁
⨁
E
E
E
⨁
⨁
⨁
Dan
Boneh
PRP-‐based
Det.
Authen1cated
Enc.
Let
(E,
D)
be
a
secure
PRP.
E:
K
×
(X×{0,1}n)
⟶
X×{0,1}n
Dan
Boneh
Online
Cryptography
Course
Dan
Boneh
Tweakable encryp1on
Dan
Boneh
Disk
encryp1on:
no
expansion
Sectors
on
disk
are
fixed
size
(e.g.
4KB)
⇒
encryp1on
cannot
expand
plaintext
(i.e.
M
=
C)
⇒
must
use
determinis1c
encryp1on,
no
integrity
Lemma:
if
(E,
D)
is
a
det.
CPA
secure
cipher
with
M=C
then
(E,
D)
is
a
PRP.
⇒
every
sector
will
need
to
be
encrypted
with
a
PRP
Dan
Boneh
sector
1
sector
2
sector
3
Dan
Boneh
sector
1
sector
2
sector
3
Syntax: E , D : K × T × X ⟶ X
Dan
Boneh
Secure
tweakable
block
ciphers
E
,
D
:
K
×
T
×
X
⟶
X
.
For
b=0,1
define
experiment
EXP(b)
as:
b
b=1:
π←(Perms[X])|T|
Chal.
Adv.
A
b=0:
k←K,
π[t]
←E(k,t,⋅)
t1,
x1
t2,
x2
…
tq,
xq
π
π[t1](x1)
π[t2](x2)
…
π[tq](xq)
b’
∈
{0,1}
• Def:
E
is
a
secure
tweakable
PRP
if
for
all
efficient
A:
AdvtPRP[A,E]
=
|Pr[EXP(0)=1]
–
Pr[EXP(1)=1]
|
is
negligible.
Dan
Boneh
Example
1:
the
trivial
construc1on
Let
(E,D)
be
a
secure
PRP,
E:
K
×
X
⟶
X
.
⇒
to
encrypt
n
blocks
need
2n
evals
of
E(.,.)
Dan
Boneh
2.
the
XTS
tweakable
block
cipher
[R’04]
Let
(E,D)
be
a
secure
PRP,
E:
K
×
{0,1}n
⟶
{0,1}n
.
x
x c
Dan
Boneh
End
of
Segment
Dan
Boneh
Online
Cryptography
Course
Dan
Boneh
Format
preserving
encryp1on
Dan
Boneh
Encryp1ng
credit
card
numbers
Credit
card
format:
bbbb
bbnn
nnnn
nnnc
(
≈
42
bits
)
k
k
POS
terminal
Then
to
encrypt
a
credit
card
number:
(s
=
total
#
credit
cards)
1. map
given
CC#
to
{0,…,s-‐1}
2. apply
PRP
to
get
an
output
in
{0,…,s-‐1}
3. map
output
back
a
to
CC#
Dan
Boneh
Step
1:
from
{0,1}n
to
{0,1}t
(t<n)
Want
PRP
on
{0,…,s-‐1}
.
Let
t
be
such
that
2t-‐1
<
s
≤
2t
.
t/2
bits
R0
R1
R2
R3
F’(k1,⋅ F’(k2,⋅ F’(k3,⋅
)
)
)
t/2
bits
L0
⊕
L1
⊕
L2
⊕
L3
input
output
(beaer
to
use
7
rounds
a
la
Patarin,
Crypto’03)
Dan
Boneh
Step
2:
from
{0,1}t
to
{0,…,s-‐1}
Given
PRP
(E,D):
K
×
{0,1}t
⟶
{0,1}t
we
build
(E’,D’):
K
×
{0,…,s-‐1}
⟶
{0,…,s-‐1}
E’(k,
x):
on
input
x
∈
{0,…,s-‐1}
do:
y⟵x;
do
{
y
⟵
E(k,
y)
}
un1l
y∈
{0,…,s-‐1};
output
y
Expected
#
itera1ons:
2
{0,…,s-‐1}
{0,1}t
Dan
Boneh
Security
Step
2
is
1ght:
∀A
∃B:
PRPadv[A,E]
=
PRPadv[B,E’]
Intui1on:
∀sets
Y
⊆
X,
applying
the
transforma1on
to
a
random
perm.
π:
X⟶
X
gives
a
random
perm.
π':
Y
⟶
Y
Step
1:
same
security
as
Luby-‐Rackoff
construc1on
(actually
using
analysis
of
Patarin,
Crypto’03)
note:
no
integrity
Dan
Boneh
Further
reading
• Cryptographic
Extrac1on
and
Key
Deriva1on:
The
HKDF
Scheme.
H.
Krawczyk,
Crypto
2010
• Determinis1c
Authen1cated-‐Encryp1on:
A
Provable-‐Security
Treatment
of
the
Keywrap
Problem.
P.
Rogaway,
T.
Shrimp1on,
Eurocrypt
2006
• A
Parallelizable
Enciphering
Mode.
S.
Halevi,
P.
Rogaway,
CT-‐RSA
2004
• Efficient
Instan1a1ons
of
Tweakable
Blockciphers
and
Refinements
to
Modes
OCB
and
PMAC.
P.
Rogaway,
Asiacrypt
2004
• How
to
Encipher
Messages
on
a
Small
Domain:
Determinis1c
Encryp1on
and
the
Thorp
Shuffle.
B.
Morris,
P.
Rogaway,
T.
Stegers,
Crypto
2009
Dan
Boneh
End
of
Segment
Dan Boneh