sumption of an embedded device. In the HW model,
the leakage is assumed to rely on the number of bits
that are set in the handled data. It is considered as a
special case of the HD model, which assumes that the
leakage depends on the bits switching from one state
to the next one. The latter is usually considered to bet-
ter integrate the behavior of CMOS circuits, however
it requires significant knowledge of the implementa-
tion. As for the HW model, it can always be used
and gives valid results for a large number of devices
(Kocher et al., 1999; Messerges, 2000; Mangard et al.,
2007).
Related Works. Several DPA scenarios have been
proposed in the literature to attack the HMAC al-
gorithm. Okeya et al. addressed in several papers
(Okeya, 2006; Gauravaram and Okeya, 2007; Gau-
ravaram and Okeya, 2008) the question of protect-
ing HMAC against DPA. They focused their study on
block-cipher based hash functions. As well, (Zhang
and Shi, 2011) dealt with HMAC based on Whirlpool.
In (Lemke et al., 2004), Lemke et al. described a the-
oretical attack on HMAC based on the hash func-
tions RIPEMD-160 and SHA-1 in the HW model.
McEvoy et al. (McEvoy et al., 2008) proposed an at-
tack against HMAC based on SHA-2 functions. They
chose the HD model to characterize the physical leak-
age of the device. The paper (Fouque et al., 2009)
presents a template attack on HMAC SHA-1, which
implies a more powerful adversary than DPA (Chari
et al., 2002). More recently, DPA on keyed versions
of KECCAK have been explored in (Zohner et al.,
2012; Bertoni et al., 2013).
Contributions. In this paper, we improve the state
of the art on the security of HMAC against DPA by
proposing an attack in the HW model. Contrary to
(McEvoy et al., 2008), our attack can be used even
when no information about the HMAC implemen-
tation is available. Moreover, our attack can easily
be adapted to the HD model, and it turns out that
the resulting attack requires weaker assumptions on
the HMAC implementation than the ones made in
(McEvoy et al., 2008). Indeed, the attack by McEvoy
et al. relies on a constraining HMAC implementation,
which reduces the scope of their attack. We also study
the cost and the success rate of the attack, that leads to
the first complete study of a full DPA attack complex-
ity on HMAC. We focus our study on HMAC based
on SHA-256, however our work can be straightfor-
wardly adapted to all SHA-2 family functions, and to
RIPEMD-160, MD5 and SHA-1 with small modifica-
tions.
Paper Organisation. The rest of the paper is or-
ganized as follows. Section2 introduces the neces-
sary backgroundon HMAC and SHA-256 algorithms.
Section3 discusses the interest of our attack and de-
scribes the details. Section 4 exhibits the results of
simulations and evaluates the efficiency of the new
attack on unprotected implementations. Eventually,
Sect. 5 deals with the protections required to secure
a HMAC implementation against our attack, and no-
tably it evaluates the impact on performances.
2 TECHNICAL BACKGROUND
2.1 The HMAC Construction
The HMAC cryptographic algorithm involves a hash
function H in combination with a secret key k. Ac-
cording to (FIPS 198-1, 2008), it is defined as follows:
HMAC
k
:
{0,1}
∗
−→ {0,1}
h
m 7−→ H((k⊕ opad) k H((k⊕ ipad) k m)) ,
where ⊕ denotes the bitwise exclusive or, k denotes
the concatenation, and opad and ipad are two pub-
lic fixed constant. We call inner hash the first hash
computation H((k⊕ ipad) k m) and the second one is
referred to as the outer hash.
In this paper, we focus on HMAC instantiated
with a hash function H based on the Merkle-Damg˚ard
construction (Merkle, 1989; Damg˚ard, 1989) (MD5,
SHA-1 and SHA-2 are among the most widely used).
An overview of this construction is given in Fig. 1.
The input message m is first padded using a specific
procedure to obtain N blocks of bit-length n denoted
by m
1
,... ,m
N
. Then each block m
i
is processed with
a h-bit chaining value CV
i−1
through a one-way com-
pression function F that outputs a new h-bit chaining
value CV
i
. The chaining value CV
0
, also denoted by
k
1
, is fixed and depends only on the secret key k. It is
computed as F(IV, k⊕ ipad), with IV being the pub-
lic Initial Value of the hash function. The final chain-
ing value CV
N
, also denoted by z, is the input of the
outer hash. It is processed with a second fixed key-
dependent value k
0
= F(IV, k⊕ opad) in the last call
of the compression function that outputs the MAC. So
we rewrite the HMAC procedure as follows:
HMAC
k
(m) =
F(k
0
,F(... F(F(k
1
,m
1
),m
2
), ... ,m
N
) k pad) ,
where pad is the bit-string used to pad the input of
the outer hash. For the sake of simplicity and without
loss of generality, we omit this value in the following.
In the rest of the paper we make our analysis on
the HMAC algorithm based on SHA-256. We assume
F to be the SHA-256 compression function. A brief
description is given in the next section.
DifferentialPowerAnalysisofHMACSHA-2intheHammingWeightModel
231