Adverse conditions improve distinguishability of auditory, motor and perceptuo-motor theories of speech perception: an exploratory Bayesian modeling study

Keywords: Auditory, Motor and Perceptuo-motor theories of speech communication, Bayesian modeling, speech perception in adverse conditions, model distinguishability

In this paper, we put forward a computational framework for the comparison between motor, auditory and perceptuo-motor theories of speech communication. We first recall the basic arguments of these three sets of theories, either applied to speech perception or to speech production. Then we expose a unifying Bayesian model able to express each theory in a probabilistic way. Focusing on speech perception, we demonstrate that under two hypotheses, regarding communication noise and inter-speaker variability, providing perfect conditions for speech communication, motor and auditory theories are indistinguishable. We then degrade successively each hypothesis to study the distinguishability of the different theories in "adverse" conditions. We first present simulations on a simplified implementation of the model with monodimensional sensory and motor variables, and secondly we consider a simulation of the human vocal tract providing more realistic auditory and articulatory variables. Simulation results allow us to emphasize the respective roles of motor and auditory knowledge in various conditions of speech perception in adverse conditions, and to suggest some guidelines for future studies aiming at assessing the role of motor knowledge in speech perception.

Introduction

A central issue in speech science concerns the nature of representations and processes involved in communication. Three major sets of theories have been widely argued for and against in this long-standing debate: motor, auditory and perceptuo-motor theories. Arguments have so far mostly been based on experimental data about variability and invariance (coarticulation phenomena supposedly in favor of motor theories: [START_REF] Galantucci | The motor theory of speech perception reviewed[END_REF] or motor equivalence principles supposedly in favor of auditory theories: e.g. [START_REF] Guenther | A theoretical investigation of reference frames for the planning of speech movements[END_REF][START_REF] Diehl | Speech perception[END_REF] or co-structuration of the perceptual and motor repertories in the Perception-for-Action-Control Theory, PACT, [START_REF] Schwartz | The perception-for-action-control theory (pact): A perceptuo-motor theory of speech perception[END_REF].

However, none of these observed isolated properties and their associated arguments are decisive, and the theoretical debate appears to be stagnating. It is our belief that mathematical modeling of these theories could provide breakthroughs in this regard. More precisely, we propose that casting these theories into a single, unified mathematical framework would be the most efficient way of comparing the theories and their properties in a systematic manner.

Bayesian modeling is a mathematical framework that precisely allows such comparisons. The trick is that the same tool, namely probabilities, can be used both for defining the models and for comparing them. Such comparisons are more and more widespread in cognitive science; see for instance the recent works on causal inference and probability matching strategies in multimodal perception [START_REF] Körding | Causal inference in multisensory perception[END_REF], or on theoretical comparison of memory models [START_REF] Myung | Optimal experimental design for model discrimination[END_REF]. Moreover, the use of a unified framework implies that common hypotheses would have common mathematical translations. This also helps toward more principled studies of the competing theories.

In this paper, we thus cast the motor, auditory and perceptuo-motor theories into three instances of the same Bayesian model, and compare them in varied speech perception situations. Using simulations, we study their behavior both in nominal and adverse conditions. Adverse conditions in this respect could involve various dimensions such as communication in noisy or multi-speaker environments, multisensory binding in complex or incoherent scenes, communication in foreign languages or between various accents, sensory or cognitive deficits. Here, we focus on the effect of noise and speaker variability on performance in speech perception. This allows us to study both the level of performance predicted by each theory but also, and surely more importantly, how the level of noise influences the distinguishability of models. It suggests some predictions for future behavioral studies aiming at assessing the role of motor processes in speech perception.

The rest of this paper is structured as follows. We first recall various illustrations of auditory, motor and perceptuo-motor theories of speech perception and speech production, and organize them into a single unifying Bayesian framework in which they all appear as instances of various questions asked to a single probabilistic communicating agent model. Then, we present the detailed implementation of auditory, motor and perceptuo-motor speech perception models. We present theoretical evidence that the auditory and motor models are indistinguishable in perfect conditions. Finally, we provide a series of simplified simulations of the recognition of speech in adverse conditions, enabling to better assess what could be the respective roles of auditory processing and motor knowledge.

A unified theoretical Bayesian framework for speech communication theories

Theories of speech perception and production

A major question in speech communication studies concerns the nature of the reference frame. Surprisingly, the question is generally asked independently in the speech production and speech perception domains, while the perceptuo-motor link is central in the theoretical debate. Indeed, we can find in the literature various occurrences of motor, auditory and perceptuo-motor theories of both speech production and speech perception (see Table 1; and [START_REF] Moulin-Frier | A unified theoretical Bayesian model of speech communication[END_REF].

Motor theories

Motor theories consider the reference frame of speech communication as gestures. In the context of speech production, Articulatory Phonology [START_REF] Browman | Articulatory Gestures as Phonological Units[END_REF]) models speech motor control as scores of overlapping gestures, able to express the context-dependent variability of speech, without taking explicitly into account the auditory consequence of a motor event. Concerning speech perception, the Motor Theory [START_REF] Liberman | The motor theory of speech perception revised[END_REF] proposes that perceiving speech amounts to perceiving gestures. A main argument is coarticulation-driven signal variability, which makes the auditory content of a given phoneme dependent on the phonetic context (see a review in [START_REF] Galantucci | The motor theory of speech perception reviewed[END_REF].

The interest for the Motor Theory of Speech Perception was recently renewed by the discovery of mirror neurons in monkeys (see e.g., [START_REF] Rizzolatti | Premotor cortex and the recognition of motor actions[END_REF] and of a "mirror system" in humans [START_REF] Fadiga | Speech listening specifically modulates the excitability of tongue muscles: a TMS study[END_REF].

Auditory theories

Auditory Theories consider that the reference frame for speech is auditory. In the case of speech production, the target would be a region in the auditory space [START_REF] Guenther | A theoretical investigation of reference frames for the planning of speech movements[END_REF]. The main argument is motor equivalence, showing that various articulatory configurations are used for achieving the same auditory goal, as shown for instance in perturbation experiments. In the case of speech perception, proponents of auditory theories consider that speech perception involves auditory or multisensory representations and processing, with no reference to speech production [START_REF] Diehl | Speech perception[END_REF].

In terms of neuroanatomical correlates, it remains a question to know if the sensorimotor connection between temporal auditory and audiovisual regions, parietal somesthesic/proprioceptive areas and frontal motor and premotor zones inside a dorsal cortical network plays or not a significant role in speech comprehension [START_REF] Hickok | The cortical organization of speech processing[END_REF][START_REF] Scott | A little more conversation, a little less action: candidate roles for motor cortex in speech perception[END_REF].

Perceptuo-motor theories

Perceptuo-motor theories have recently emerged for both speech perception (e.g., [START_REF] Skipper | Hearing lips and seeing voices: how cortical areas supporting speech production mediate audiovisual speech perception[END_REF], Schwartz et al., 2010) and production (e.g., [START_REF] Guenther | Cortical interactions underlying the production of speech sounds[END_REF]. They generally consider auditory frames as the core for communication, but they include the perceptuo-motor link inside the global architecture. They claim that in normal conditions, production involves cortical motor (frontal) areas and perception involves cortical auditory (temporal) ones, but that the perceptuo-motor (dorsal) link, necessary for speech acquisition, could also play a role in adverse conditions.

Regarding speech production, the DIVA model [START_REF] Guenther | Cortical interactions underlying the production of speech sounds[END_REF] combines a feedforward control sub-system for on-line production, and a feedback control sub-system when the auditory consequence of a gesture is not congruent. In a similar way, perceptuo-motor theories of speech perception argue for a core auditory (or audio-visual) system for speech perception, enhanced by motor processes in complex conditions such as noise, through "binding" [START_REF] Schwartz | The perception-for-action-control theory (pact): A perceptuo-motor theory of speech perception[END_REF] or "prediction" [START_REF] Skipper | Hearing lips and seeing voices: how cortical areas supporting speech production mediate audiovisual speech perception[END_REF].

Communicating agents based on internalization of the communication loop

We propose here to model a general interaction process, in which a speaker and a listener communicate about an object of the environment. For this aim, the speaker, willing to communicate about the object O S , performs a gesture M producing a sound S enabling the listener to understand and recover an object O L (Fig. 1a). Efficient communication can be assessed by an external validation system (success vs. failure indicator C env ), whether it is an outside oracle (as in a supervised learning stage, for instance), or a shared attention mechanism.

A central hypothesis of the general model is that the communication loop (Fig. 1a), in which a speaker interacts with a listener through the environment, can be internalized and emulated into the brain of a single agent (Fig. 1b). Firstly, the agent can take both roles, listener and speaker, and thus contains both subsystems, motor and sensory. Secondly, the agent has some knowledge about the articulatory-to-acoustic transformation performed by the environment. When it is internalized, it takes the form of an internal forward model, allowing the agent to predict sensory consequences of motor gestures. Finally, the external validation system is also internalized; in other words, the agent has two internal representations of objects, linked by a system that verifies whether they refer to the same object. This internalization hypothesis could be discussed in the framework of general cognitive theories of social communication and human evolution (e.g. [START_REF] Baron-Cohen | Mindblindness: an essay on autism and theory of mind[END_REF][START_REF] Tomasello | Understanding and sharing intentions: The origins of cultural cognition[END_REF]; see also [START_REF] Moore | Spoken Language Processing: Piecing Together the Puzzle[END_REF] for similar views about internalization, expressed in a control theory framework).

Bayesian model of communicating agents

We now propose a computational model of the communicating agent defined according to the internalized communication loop in Fig. 1b. The model is built using Bayesian Programming [START_REF] Lebeltel | Bayesian Robots Programming[END_REF]Bessiere et al., 2008). Bayesian Programming aims at defining models of reasoning agents using probability distributions to represent knowledge and Bayesian inference to manipulate knowledge in a mathematically principled manner. This view of probabilities as states of knowledge allows one to formally represent different preliminary knowledge [START_REF] Colas | Common bayesian models for common cognitive issues[END_REF]. In the remainder, we use symbols to identify different models (e.g., in π Env , the model of the simulated environment, some noise is represented, which may or may not be properly captured in some agent's internal model π Ag ). In this context, the model of a perceptuo-motor agent is defined as a joint probability distribution over variables of interest (typically motor, sensory and internal variables). This joint distribution is broken down as a product of simpler distributions, using Bayes rule and conditional independence hypotheses. Using this knowledge, a behavior is then defined as a conditional probability distribution computed from the joint distribution (for example: "given values of some sensory variables, what is the probability distribution over the speech objects?"), called a question to the model, and is solved using Bayesian inference.

Variables

Our model of a general communicating agent is based on five probabilistic variables, which are a direct translation of our conceptual model of the communication situation:

• M Ag : the agent motor gesture,

• S Ag : the agent sensory representation,

• O Ag S , O Ag L : the object of communication, when the agent respectively takes the speaker's and the listener's point of view, • C Ag : the internalization of the communication validation system. C is a Boolean variable, and is true (value 1) when

O Ag S = O Ag L .
Here it must be acknowledged that an "object" may take a very wide spectrum of definitions.

Ideally, it refers to the level at which the link between phonology and semantics takes place in linguistic communication: typically the word. In the remainder of this paper, it however refers to any phonological category shared by the speaker and the listener in the speech communication process (e.g., a syllable or a phoneme). We do not consider in this paper all the (many) problems associated with defining the adequate level. We just assume that at some stage, a given phonological unit can be successfully exchanged between a speaker and a listener.

Joint probability distribution

There are five subsystems to define. The first three depend on the precise definition of the sensory and motor variables: they are introduced here and made precise in Section 3.2.

• The motor subsystem is defined as a conditional probability distribution P(M Ag | O Ag S ):

given an object to communicate, what is the probability distribution over motor gestures? • The sensory (or auditory) subsystem is defined as a conditional probability distribution P( O Ag L | S Ag ): given a sensory input, what is the probability distribution over the perceived objects? • The perceptuo-motor subsystem is defined as a conditional probability distribution P(S Ag | M Ag ): given a motor gesture, what is the probability distribution over the sensory inputs? The last two systems are independent of sensory and motor variables, and defined as follows.

• The internalized communication validation subsystem is defined as a conditional probability distribution

P(C Ag | O Ag S O Ag L ):
given objects in the motor and sensory subsystems, C Ag is true (=1) when both refer to the same object. It is defined as a Dirac probability distribution such that:

Technically, C Ag is a coherence variable [START_REF] Gilet | Bayesian Action-Perception computational model: interaction of production and recognition of cursive letters[END_REF], which allows connecting or disconnecting the sensory and motor routes in the agent's cognitive architecture. • Finally, the object prior P( O Ag S ), is defined as a Uniform probability distribution: the objects are assumed to be present with the same frequency in the environment.

Therefore, the general model of a communicating agent π Ag is the following joint probability distribution, illustrated in Fig. 2:

Bayesian inference for simulating speech perception and production tasks

From the joint probability distribution we can apply Bayesian inference in order to simulate speech perception and production tasks, which appear as probabilistic questions addressed to the general distribution. Perception tasks can be simulated by computing probability distributions over objects, given an input sensory signal. Production tasks can be simulated by computing probability distributions over motor gestures, given an object to communicate about.

The driving reasoning in our Bayesian modeling is that motor vs. auditory theories can be defined in reference to the pivot role provided to O Ag S vs. O Ag L in the probabilistic reasoning.

In motor theories, the speaker is the pivot, and the direct connection between S Ag and O Ag L is disabled.

In terms of speech production, this provides a simple probabilistic question to solve for speech motor control, that is

P(M Ag | O Ag S )
: what is the adequate action for a given speaker?

But in terms of speech perception, this leads to a "motor theory of speech perception" in which the question to solve is P( O Ag S | S Ag ): knowing the sensory input, what is the object which was in the speaker's mind? Bayesian inference yields:

This question can be interpreted as a motor inference: indeed, motor terms are involved in the equation, whereas the sensory system P( O Ag L | S Ag ) is marginalized away. In this equation, the P(S Ag | M Ag ) term expresses the search for motor values able to lead to the perceived sensory input (this is classically referred to as "inversion" or "analysis by synthesis"). The P(M Ag | O Ag S ) factor can be conceived as an "articulatory decoder", assuming that invariance rather lies in motor than in auditory cues.

In auditory theories, the listener is the pivot, and the direct connection between O Ag S and M Ag Finally, perceptuo-motor theories take into account the information provided by both motor and sensory subsystems. Furthermore, inference is performed under the assumption that both subsystems are coherent, that is, C Ag =1. For example, for speech perception this yields:

Note that : both O Ag L and O Ag S can interchangeably be considered pivot during this perceptuo-motor inference.

This can be seen as a combination of the two previous inferences. The probability of the object O L directly inferred from the sensory input S through an auditory theory is modified by the knowledge that S was also produced from the object O S (= O L ) using motor variables M. In other words, the coherence variable effect can be seen here as forcing a fusion between purely perceptual and purely motor inferences. In our case, this perceptuo-motor fusion takes the form of a product between both processes.

A similar result is obtained for speech production.

This results in the taxonomy of Table 2 in which each of the speech perception and production theories displayed in Table 1 actually corresponds to different inferences in the same probabilistic model, or, alternatively, processes involving different portions of a unique knowledge set. The unifying process in this framework is that both perception and production models derive from a single internalized communication model, in which the coherence variable C Ag , expressing the hypothesis of internal coherence, yields a fusion between the motor and perceptual branches for both perception and production. Pure auditory and motor theories just consist in cutting this connection and keeping only either the perceptual or the motor branch for both speech production and perception.

Studying perception tasks using the Bayesian model of communicating agent

We now narrow down our focus to the study of perception tasks. We consider an environment, populated with several agents (see Fig. 3). We take the point of view of one of the agents, Ag, which performs perception tasks. It interacts with another agent, Master, which provides it with both learning and test signals. Both agents are instances of the communicating agent model we defined (Section 2).

Our goal is to compare the three auditory, motor and perceptuo-motor variants of speech perception, considered as probabilistic questions and displayed in the right column of Table 2, asked to the agent Ag.

We consider in Section 5 two agent models of increasing complexity and realism (in terms of the forms of all variable distributions). The first one, however, already contains all properties that are needed to justify our first two theoretical results, and is also the basis of the first simulation experiment in Section 5.1. The other model can thus be seen as a variant of this first, core model. Therefore, we now provide its full detailed definition, and only present the variant as needed in Section 5.2.

Variable domains

The domains of M Ag , M Master , S Ag and S Master vary in our different experiments. In the first, simple model, they are mono-dimensional, discrete variables (with values regularly distributed between -10 and 10).

Probability distribution forms

The model structure being set according to Section 2.3.2, we define each of the probabilistic terms of interest that are implied by Fig. 3.

Object prior P( O Ag

S )

The first term of the decomposition is a prior probability distribution over objects. In our first experiment, the set of possible objects contains two values, and we define both P( ) and P( O Master S ) as uniform probability distributions over this set. In other words, o+ and o-each have a prior probability of 0.5 to be the communication object. ) are probability distributions over motor gestures, one for each possible communication object. Their definitions depend on the dimensionality and nature of the motor variable. In our first experiment, motor variables are discrete and mono-dimensional; therefore they are defined as 1-D Gaussian probability distributions, approximated over the discrete domain of M (Fig. 4).

Motor models P(M

Motor to acoustic mappings P(S Ag | M Ag ) and P(S Ag | M Master )

The relation between motor gestures and the resulting speech sounds, characterized by the formants of the acoustic signal, is known to feature non-linear events. Proponents of sensory theories of speech perception argue that processing the acoustic signal is easier in the acoustic domain than back in motor space, because non-linearities would naturally structure the acoustic domain into plateaus and boundaries (Quantal Theory, [START_REF] Stevens | The quantal nature of speech: Evidence from articulatory-acoustic data[END_REF][START_REF] Stevens | On the quantal nature of speech[END_REF]: see Fig. 5a).

In our model, terms of the form P(S | M) encode the articulatory-to-acoustic transformation. They are defined as sets of mono-dimensional Gaussian probability distributions, one for each discrete motor value, defined by parameters µ and σ. µ is given by a sigmoid function of M, defined by and σ models a dispersion around the central value predicted by the sigmoid. The parameter a controls the linear vs. nonlinear nature of the µ(M) function (Fig. 5b), whereas b controls the range of the function.

Two articulatory-to-acoustic mappings are to be defined. The first, P(S Ag | M Master ), is the one performed by the simulated environment model π Env , of parameters µ Env , σ Env : σ Env models the noise in the simulated environment. The second, P(S Ag | M Ag ), is the one internalized in the agent model π Ag , of parameters µ Ag , σ Ag : σ Ag models the uncertainty the agent has about the articulatory-to-acoustic transformation (e.g., when µ Env = µ Ag , and σ Env = σ Ag , the agent has perfect knowledge about the environment characteristics).

Auditory model P( O Ag L | S Ag )

In our framework, the auditory model P( O Ag L | S Ag ) of the agent Ag is assumed to be learned in a supervised manner.

The master agent provides object-to-acoustic signal couples to the learner using the following algorithm:

• Thus the learner can, using a history of such couples <s, o>, identify the parameters of the probability distributions of P( O Ag L | S Ag ).

Perfect communication leads to theoretical equivalence between motor and auditory models

In this section, we consider the motor and auditory processes of speech perception, as defined above. We put forward two hypotheses on the learner agent knowledge, under which motor and auditory speech perception models cannot be distinguished.

Let us consider the purely auditory speech perception of the learner. As defined before, it is performed by simply accessing the auditory model P( O Ag L | S Ag ). But this model, when learned in the supervised manner we defined, is based on <s, o> couples that have been generated by the master agent, using its motor model (and the model of acoustic propagation through the environment). Mathematically, our learning algorithm of Section 3.2.4 performs the following computation:

We now add two hypotheses:

• H1: : we assume that the learner perfectly captured the environment articulatory-to-acoustic transformation; • H2:

: the learner and master agent have the same motor model. Under these hypotheses, we obtain:

In the last equation, the left member is the expression of an auditory theory of speech perception, while the right member is the expression of a motor theory of speech perception (see Table 2). This shows that auditory and motor models of speech perception are indistinguishable in "perfect" communication conditions, that is with identical motor models in the agents, and perfect learning of the environment properties. This is the first result of our Bayesian approach.

The models can be distinguished only if either H1 or H2 is wrong: this is what we consider here as "adverse conditions". Departure from H1 (imperfect forward model) can be produced in various ways. The learner could have a limited learning capability, with not enough memory or inadequate expressiveness. Or it could have an inadequate model of the articulatory-toacoustic transformation, for example in cases where the noise level assumed by the learner is different from the noise level during subsequent perception. Departure from H2 with different motor models in the master and the learner could be due to any biomechanical or idiosyncrasy differences. Of course, speech impediment or accented speech would provide other, more severe, discrepancies.

In summary, this theoretical result shows that, outside of adverse conditions (incomplete or imperfect learning, noisy environment, degraded or accented speech), auditory and motor processes of speech perception cannot be distinguished in the Bayesian framework presented here 1 .

Simulating speech perception in adverse conditions

To achieve distinguishability, we consider two kinds of degradation of the communication paradigm, which correspond to departures from the two hypotheses H1 and H2.

The first one involves communication noise in the environment. To do so, we vary the value of σ Env which controls dispersion in the P(S Ag | M Master ) articulatory-to-acoustic transformation (Section 3.2.3). If σ Env equals zero, P(S Ag | M Master ) becomes deterministic, which means that S Ag is completely determined by M Master in a communication occurrence. Increasing σ Env in- creases the uncertainty on S Ag , which simulates communication noise. The second one is based on imposing differences in motor prototypes between π Ag and π Master in the P(M | O S ) distributions (Section 3.2.2).

We have five expectations in these simulations.

(1) According to H1, incorrect representation of the noise will induce distinguishability between models. (2) According to H2, difference between learner and master agent motor prototypes will also induce distinguishability between models.

(3) Applying a nonlinear P(S | M) articulatory-to-acoustic transformation results in a natural organization of the S space in two categories (see Fig. 5). An auditory model of speech perception is naturally suited to this structure. On the contrary, a motor model first inverses the sensory to motor representations and hence loses this structure (this is the basic argument which led [START_REF] Schwartz | The perception-for-action-control theory (pact): A perceptuo-motor theory of speech perception[END_REF] to discard a purely motor theory of speech perception). Therefore, at small to moderate noise levels, the auditory model of speech perception should surpass the motor model of speech per-1 Notice that the perceptuo-motor model is actually different from both the auditory and the motor models here. Indeed, since it is based on a fusion of the perceptual and motor inputs, it questions twice the classifier P(O L | S) (equal to P(O S | S) in this situation) and keeps only coherent answers, thus decreasing the error rate. ception. (4) Noise should degrade the auditory model. However, motor knowledge represented in P(M Ag | O Ag S ) contains some information that could be likely to compensate -to a certain extent -for the degradation. Therefore, it may be hypothesized that at high noise levels, the motor model of speech perception should surpass the auditory model of speech perception (this is the basic argument which led [START_REF] Schwartz | The perception-for-action-control theory (pact): A perceptuo-motor theory of speech perception[END_REF] towards a perceptuo-motor theory of speech perception, PACT). ( 5) The perceptuo-motor model, combining auditory and motor branches for a global decision process (Section 2.3.3), should surpass both the auditory and the motor model at all noise levels.

We first test these expectations on the core 1D model, and then consider stimuli generated by a realistic articulatory-to-acoustic model of the human vocal tract.

1D core model

Let us recall that in this first variant, sensory and motor variables are one-dimensional varying between arbitrary values -10 and 10, and perception deals with two speech objects o+ and o-.

Varying communication noise

In this first simulation, we test how auditory, motor and perceptuo-motor models of speech perception perform at various levels of communication noise (σ Env varying from 0 to large values) for three different values of the slope of the P(S Ag | M Master ) transform, producing transforms from quasi linear to highly nonlinear (Fig. 5b).

For each model:

• Objects are drawn with equal probabilities from both categories o+ and o-.

• From these objects, values for S Ag are drawn according to the master production system P(M Master | O Master

S

) followed by the articulatory-to-acoustic transformation of the environment P(S Ag | M Master ) (including the noise σ Env ).

• They are given as input to the probabilistic question of the model (a motor, sensory, or sensorimotor question, corresponding to probability distributions displayed in the right column of Table 2). • From the comparison of the probability distribution of the answers with the known category of the object for all the drawn values of S Ag , a confusion matrix is built, from which we define the correct recognition rate as the sum of the diagonal terms. This score describes the probability that the model recognizes the right category for any input S Ag .

The results are displayed on Figure 6.

We observe the following results.

• The superiority of the motor or sensory model over the other one depends on both the value of the noise and the amplitude of the nonlinearity in the P(S Ag | M Master ) transform. • As predicted, without noise (i.e., when σ Env = σ Ag , that is, hypothesis H1 is true) and since motor prototypes are equal (hypothesis H2) the auditory and motor models perform exactly the same. • In the linear case, the sensory model is always poorer than the motor one. Nonlinearity induces a range (for small noise) in which the sensory model performs better than the motor one. A high value for the slope parameter (highly nonlinear transform) makes the sensory model better than the motor model on a larger range.

• The motor model becomes better than the sensory model when noise increases.

• The sensorimotor model has always equal or better recognition scores than the two other models.

Varying motor prototypes between master and learner agent

In this second simulation with a constant small communication noise (σ Env = 1), we consid- Master =5 and µ - Master =-5, and we suppose that the motor prototypes for the Agent differ from them by a δ value:

µ + Ag =µ + Master + δ, µ - Ag =µ - Master -δ.
A negative (resp. positive) value of the δ parameter means that the learner's motor prototypes are closer (resp. further) than the master's. When δ=0, motor prototypes of Master and Ag are identical (i.e., hypothesis H2 is true). Applying a delta bias between the means of the motor prototypes in the master and the learner could be interpreted as a motor idiosyncrasy or an accent. Once again, we considered three different values for the slope parameter of the P(S Ag | M Master ) transform, from quasi linear to highly nonlinear. The results are displayed on Fig. 7, with the same presentation as in Fig. 6.

These show that:

• The superiority of the motor or sensory model over the other one depends on the discrepancy between motor prototypes in the master and the agent. • The sensory model does not depend on values of the agent motor prototypes (since sensory inputs are the same in all cases) while the motor model improves when the distance between the agent motor prototypes increases (better internal separation between motor prototypes). Interestingly, this shows that in a motor theory of speech perception, the best perceptual performances are obtained for an agent dispersing its motor prototypes as much as possible, rather than perfectly fitting with its interlocutor. • A high value for the slope parameter (highly nonlinear transform) makes the sensory model better than the motor model on a larger range. • As in the previous simulation, the sensorimotor model has always equal or better recognition scores than the two other models.

Simulations on stimuli provided by a realistic model of the human vocal tract

We now extend the previous simulations to more realistic articulatory-acoustic configurations generated by a realistic model of the human vocal tract. This model, developed by [START_REF] Maeda | Compensatory Articulation during Speech: Evidence from the Analysis and Synthesis of Vocal-Tract Shapes using an Articulatory Model[END_REF], delivers sagittal contours and lip shapes from seven input parameters driving the jaw, tongue and lips, which are interpretable in terms of phonetic commands and are closely related to muscle commands [START_REF] Maeda | From EMG to formant patterns of vowels: the implication of vowel spaces[END_REF]. After the control parameters are entered, the area function of the vocal tract is estimated, from which the transfer function and the formants are calculated [START_REF] Badin | Notes on vocal tract computations[END_REF].

In the following, we replicated the communication noise experiment (described in Section 5.1.1) on two vowel corpora produced with this vocal tract model. For each corpus, a single articulatory parameter controls the acoustic (F1, F2, F3, F4) trajectory between two vowels. Then, F2, F3 and F4 are summarized by a "perceptual second formant" F'2 computed by an analytical formula derived from experimental data on vowel perception [START_REF] Schwartz | The Dispersion-Focalization theory of vowel systems[END_REF]. Therefore, each corpus associates a single articulatory variable to a two-dimensional (F1, F'2) perceptual space. Objects all along Section 5.2 are phonemes (i.e. vowel categories).

An [i]-[y] corpus with highly nonlinear articulatory-to-acoustic transform

The first corpus is generated by varying the lip shape (by an adequate combination of lip height and lip protrusion) from the high front unrounded [i] to the high front rounded [y]. This produces a well-known trajectory in which the resonances of the back cavity do not change while only the resonance of the front cavity decreases from a high F3 value close to F4, to a low F2 value. F'2 enhances and summarizes this perceptual variation by providing a quasi quantal variation (Fig. 8a).

We generated with the vocal tract model two sets of vocalic configurations respectively around [i] and [y], also displayed on Fig. 8a, and we applied the auditory, motor and perceptuo-motor speech recognition models to these data, in the same conditions as in Section 5.1.1 -including communication noise σ Env -though sensory variables were now bi-dimensional (F1, F'2) rather than mono-dimensional. The results are displayed in Fig. 8b. They are quite similar with those of Fig. 6f, with a large range of noise values for which the sensory model performs much better than the motor one, while the perceptuo-motor is always the best one.

An [y]-[a] corpus with quasi-linear articulatory-to-acoustic transform

The second corpus is generated by varying the jaw and tongue configuration from high to low (by an adequate combination of so-called "mandible" and "tongue body" parameters) from the high front rounded [y] to the low [a]. This produces a trajectory in which F1 increases and F2 decreases, while F3 does not change much, resulting in a smooth F'2 decrease (Fig. 9a).

Once again, we generated with the vocal tract model two sets of vocalic configurations respectively around [y] and [a], also displayed on Fig. 9a, and we applied the auditory, motor and perceptuo-motor speech recognition models to these data, in the same conditions as in Section 5.1.1 -including communication noise σ. The results are displayed in Fig. 9b. They are quite similar to those of Fig. 6b, the sensory model performing always worse than the motor one, which is almost equal to the perceptuo-motor one.

General discussion

Perceptuo-motor interactions conceived as a fusion problem

The integrative approach that we propose here, in which the basic ingredients of contrastive theories of speech perception and speech production are embedded in the same Bayesian framework for better comparative assessment, seems highly productive, and already results in four important achievements in this paper.

(1) Auditory, motor and perceptuo-motor theories of speech perception and production are described, within a general model of speech communication (Fig. 1), and formalized through a set of probabilistic equations (Table 2) allowing further quantitative tests in various paradigms.

(2) In this probabilistic framework, focusing on speech perception theories, it appears that in perfect communication conditions (without any kind of noise and with perfect agreement between perceptuo-motor properties of communicating agents) auditory and motor theories of speech perception provide exactly the same outputs and are hence experimentally indistinguishable. (3) If communication noise or inter-agent variability of any kind is introduced, auditory and motor theories become distinguishable. For small amounts of noise, the auditory model performs better than the motor one. The noise range where this happens is increased when the articulatory-to-acoustic transform is nonlinear. This may be linked to Stevens' quantal theory. On the contrary, for large noise levels, the motor model performs better than the auditory one. (4) The perceptuo-motor model of speech perception, based on a multiplicative fusion of the auditory and motor models, performs always better than both the auditory and motor models whatever the experimental conditions.

The conception of perceptuo-motor models of speech perception as operating a fusion between an auditory and a motor sub-model provides an interesting perspective for a new paradigm in the study of speech perception. Multisensory fusion in audiovisual speech has generated a large number of experimental data (typically on conflicting auditory and visual inputs and on speech in noise) and computational models and simulations (typically varying the kind of fusion models and the consequence on predictions and performances). The present work suggests that the question of perceptuo-motor fusion could be set at the center of the agenda of future experimental and computational studies on auditory vs. motor theories of speech perception. We elaborate a little more on this in the next sections.

Implications and predictions for further experimental tests

This general portrait sheds some light on the debate between theories of speech perception. To begin with, it provides a formal basis for better understanding why it is so difficult to disentangle auditory from motor theories: the motor knowledge is stored to a certain extent in the auditory model P(O L | S), hence if the learning and communication conditions are "perfect" in the sense of H1 and H2, experimental data cannot conclude. This formalizes in a rigorous way an argument explicitly stated by auditory theorists, e.g., [START_REF] Diehl | Speech perception[END_REF]: "listeners do not recover gestures, but they do perceive the acoustic consequences of gestures. Any regularities of speech production (e.g., context dependencies) will be reflected in the acoustic signal, and, through general mechanisms of perceptual learning, listeners come to make use of the acoustic correlates of these production regularities in judging the phonemic content of speech signals."

It also suggests some directions for further experimental tests comparing theories. Let us mention some of these proposals derived from testable predictions suggested by the results in Section 5. Firstly, linear vs. nonlinear configurations produce very different predictions in auditory vs. motor models: while the degradation with noise is similar in both cases in the motor model, it produces very different effects in the auditory model, with a larger plateau and a steeper decrease in the nonlinear case (compare Fig. 6f with 6b, or 8b with 9b). Comparing degradation of phoneme categorization with noise in linear vs. nonlinear cases could provide some hints in the debate between auditory vs. motor theories of speech perception.

Secondly, the role of motor processes should be easier to display for noisy communication rather than for clear speech: this is actually in line with some recent data assessing how perturbations of the motor system intervene in speech perception, and displaying effects only when speech stimuli are contaminated with noise (e.g., [START_REF] Meister | The essential role of premotor cortex in speech perception[END_REF][START_REF] D'ausilio | The motor somatotopy of speech perception[END_REF]Sato et al., in press). Interestingly, comparisons of perceptuo-motor vs. auditory models in Fig. 6, 8 and 9 show that the role of motor processes in noise appears sooner in linear than in nonlinear configurations: that is, if motor processes do intervene in e.g. vowel perception, lip perturbation in assessing vowel rounding in an [i]-[y] task should produce less effect than tongue or jaw perturbation in assessing vowel height in an [i]-[e] or [y]-[a] task.

Perspectives

A perceptuo-motor theory such as developed in the Perception-for-Action-Control Theory seems to provide a quantitatively efficient computational compromise between properties of the auditory system (non-linear shaping) and exploitation of motor procedural knowledge in perception (see [START_REF] Viviani | Biological movements look uniform: evidence of motorperceptual interactions[END_REF], for the first introduction of the concept of "motor procedural knowledge" in human perception). This also fits an increasing number of such proposals, developed in the context of both behavioral and neuroanatomical data (e.g. [START_REF] Skipper | Hearing lips and seeing voices: how cortical areas supporting speech production mediate audiovisual speech perception[END_REF].

The work presented in this paper can be extended and developed in various directions. Firstly, we are presently beginning to test more realistic and complex speech perception tasks, involving complete vowel, consonant or syllabic sets associated with multi-dimensional articulatory and perceptual spaces defined on the vocal tract model presented in Section 5.2. We expect that contextual effects should enable to better display the role of articulatory knowledge in speech perceptual processing, typically concerning coarticulation. For example, in syllables involving the same plosive embedded in various vowel contexts, the motor information on the plosive, naturally captured in the motor sub-system, should result in enhancing the plosive recognition score in a perceptuo-motor model compared with a pure auditory model.

Secondly, more sophisticated paradigms and models should be explored in various directions.

Processing of atypical stimuli (e.g., produced by a speaker with a specific idiosyncrasy, or a foreign accent) will involve three-agent paradigms in which there is a perceiving agent, a master agent (providing prototypical stimuli in learning) and a speaker agent, all possibly different. Comparison of perceptuo-motor fusion models could be also explored in various directions. Since fusion is basically obtained in the perceptuo-model by the coherence variable C set to 1 by a Dirac probability distribution, other types of fusion could be obtained by relaxing this Dirac into a softer fusion mechanism, possibly driven by additional information such as noise or context (see [START_REF] Schwartz | Ten years after Summerfield... A taxonomy of models for audiovisual fusion in speech perception[END_REF], for a discussion on fusion models in the context of audiovisual speech perception).

Thirdly, we shall design auditory, motor and perceptuo-motor models of speech production associated with the equations in the left column of Table 2, and study their ability to deal with classical speech production questions such as motor equivalence, coarticulation, perturbation, or learning.

The models should also be extended to questions about the behavioral and neuroanatomical correlates of each component of the Bayesian implementation. This relates to such questions as how and where are represented sensory and motor variables, how are they linked in perception and production, how can the potential role of auditory knowledge in speech production and motor knowledge in speech perception be assessed, are the phonological input (related to O L ) and output (related to O S ) systems equivalent and/or identical (see evidence for a distinction between these systems in [START_REF] Jacquemot | Breaking the mirror: Asymmetrical disconnection between the phonological input and output codes[END_REF]. Notice that the computational Bayesian models of speech communication introduced in this paper can also be extended towards models of the emergence of language in societies of computational sensori-motor agents in interaction [START_REF] Moulin-Frier | Emergence of articulatoryacoustic systems from deictic interaction games in a "Vocalize to Localize" frame work[END_REF]. This should enable to better link what we know about online speech communication with our knowledge about the shape and evolution of sound systems in human languages (e.g., [START_REF] Schwartz | The Dispersion-Focalization theory of vowel systems[END_REF].

Motor

Articulatory Phonology [START_REF] Browman | Articulatory Gestures as Phonological Units[END_REF] Motor Theory [START_REF] Liberman | The motor theory of speech perception revised[END_REF] Auditory Auditory reference frames for speech planning [START_REF] Guenther | A theoretical investigation of reference frames for the planning of speech movements[END_REF] Auditory theories [START_REF] Diehl | Speech perception[END_REF] Perceptuo-motor DIVA model [START_REF] Guenther | Cortical interactions underlying the production of speech sounds[END_REF] Perception for Action Control Theory [START_REF] Schwartz | The perception-for-action-control theory (pact): A perceptuo-motor theory of speech perception[END_REF]

  is disabled. This leads to auditory theories of speech perception through the question P( O Ag L | S Ag ) (direct inference without any motor knowledge, typical of these theories). It leads to auditory theories of speech production through P(M Ag | O Ag L ) attempting to estimate through auditory inference what gestures should the speaker produce to make the listener perceive the adequate object for the listener. Bayesian inference yields: This corresponds to associating auditory targets, defined by the term P( O Ag L | S Ag ), with forward models, defined by the term P(S Ag | M Ag ), for estimating the adequate motor command.

  The object variables O Ag S , O Master S , O Ag L and O Master L each denote two possible speech objects: o+ and o-.

  we first choose a random object o in the domain of O Master S to communicate, • we compute, in model π Master , a motor gesture m by drawing at random according to the master agent's production model P(M Master | [ O Master S =o]), • we compute, in model π Env , from m, a resulting auditory signal s, by drawing at ran- dom according to the environment articulatory-to-acoustic model P(S Ag | [M Master =m]), • the object o is then transferred without error to the learner, that is, C Env =1, assuming a perfect shared-attention mechanism, outside of spoken communication, that allows to agree on the object of interest. The learning agent takes the object o as an O Ag L value.

  FIGURE 1. Conceptual model of a communication interaction. (a) A speaker and a listener are in presence of an object and, using acoustic signals, designate it. (b) The whole communication loop is internalized in the "brain" of each agent.

FIGURE 2 .

 2 FIGURE 2. Structure of the communicating agent model, represented with a Bayesian network. Nodes correspond to variables, and arrows represent probability distributions, which illustrate the dependency structure.

FIGURE 4 .

 4 FIGURE 4. Motor prototype models. The left curve is P(M | [O S =o-]), the right curve is P(M | [O S =o+]).

FIGURE 6 .

 6 FIGURE 6. Experimental results for the 1D simulation of communication noise. See text for details. The plots of the left column show the motor prototypes P(M | O S ) in the bottom right corner, the articulatory-to-acoustic link P(S | M) (in terms of mean of the sensory variable for a given motor variable) in the top right corner, and the auditory prototypes P(S | O L ) in the top left corner. The plots on the right column show the corresponding variations of the correct recognition rate for the different models, when the environment noise σ Env varies. Top row: linear case; middle row: nonlinear case; bottom row: strongly nonlinear case.

FIGURE 7 .

 7 FIGURE 7. Experimental results for the 1D simulation of variation in motor prototypes between the learner agent Ag and the master agent Master. Same presentation as in Fig. 6. In the right column, the x-axis corresponds to the departure δ between the Master and Ag agent motor prototypes (0 means equal prototypes in the Master and Ag models).

  ered differences in master and learner agent motor prototypes by applying different values of means µ of the Gaussian probability distributions P(M Master | O Master Ag the means for the two categories o+ and o-respectively. We set µ +

				S	) in the master (used for
	learning the P( O Ag L | S Ag ) distribution, see Section 3.2.4) and P(M Ag | O Ag S ) in the learner. We
	note µ +	Master , µ -	Master and µ +	Ag and µ -

Table 1 .

 1 Taxonomy of speech production and perception theories and models

	Theory	Task	Production	Perception

Table 2 .

 2 Model Taxonomy

	Motor
	Object of interest
	is O S
	Auditory
	Object of interest
	is O L
	Perceptuo-motor
	Both O S and O L
	must be equal
	(C=1)

Task Theory Production Inference of the form P(M | O) Perception Inference of the form P(O | S)


Jean-François Lalande
email: jean-francois.lalande@insa-cvl.fr

Karine Heydemann
email: karine.heydemann@lip6.fr

Pascal Berthomé
email: pascal.berthome@insa-cvl.fr

Software countermeasures for control flow integrity of smart card C codes

Keywords: control flow integrity, fault attacks, smart card, source level

Fault attacks can target smart card programs in order to disrupt an execution and gain an advantage over the data or the embedded functionalities. Among all possible attacks, control flow attacks aim at disrupting the normal execution flow. Identifying harmful control flow attacks as well as designing countermeasures at software level are tedious and tricky for developers. In this paper, we propose a methodology to detect harmful intra-procedural jump attacks at source code level and to automatically inject formally-proven countermeasures. The proposed software countermeasures defeat 100% of attacks that jump over at least two C source code statements or beyond. Experiments show that the resulting code is also hardened against unexpected function calls and jump attacks at assembly level.

Introduction

Smart cards or more generally secure elements are essential building blocks for many security-critical applications. They are used for securing host applications and sensitive data such as cryptographic keys, biometric data, pin counters, etc. Malicious users aim to get access to these secrets by performing attacks on the secure elements. Fault attacks consists in disrupting the circuit's behavior by using a laser beam or applying voltage, clock or electromagnetic glitches [START_REF] Barenghi | Fault Injection Attacks on Cryptographic Devices: Theory, Practice, and Countermeasures[END_REF][START_REF] Barenghi | Fault attacks on stream ciphers[END_REF][START_REF] Moro | Electromagnetic Fault Injection: Towards a Fault Model on a 32-bit Microcontroller[END_REF]. Their goal is to alter the correct progress of the algorithm and, by analyzing the deviation of the corrupted behavior with respect to the original one, to retrieve the secret information [START_REF] Dehbaoui | Electromagnetic glitch on the AES round counter[END_REF]. For java card, fault attacks target particular components of the virtual machine [START_REF] Barbu | Java card operand stack: fault attacks, combined attacks and countermeasures[END_REF][START_REF] Barbu | Attacks on java card 3.0 combining fault and logical attacks[END_REF][START_REF] Bouffard | Combined software and hardware attacks on the java card control flow[END_REF].

Many protections have therefore been proposed to counteract attacks. Fault detection is generally based on spatial, temporal or information redundancy at hardware or software level. In java card enabled smart cards, software components of the virtual machine can perform security checks [START_REF] Iguchi-Cartigny | Evaluation of Countermeasures Against Fault Attacks on Smart Cards[END_REF][START_REF] Lackner | A defensive virtual machine layer to counteract fault attacks on java cards[END_REF][START_REF] Bouffard | Detecting laser fault injection for smart cards using security automata[END_REF].

In practice, developers of security-critical applications often manually add countermeasures into an application code. This operation requires knowledge about the target code vulnerabilities. Both these tasks are time-consuming with direct impact on the certification of the product. One harmful consequence of fault attacks is control flow disruption which may bypass some implemented countermeasures. It is difficult for programmers to investigate all possible control flow disruption in order to detect sensitive parts of the code and then investigate how to add countermeasures inside these sensitive parts. Moreover, secure smart cards have strong security requirements that have to be certified by an independent qualified entity before being placed on the market. Certification can rely on a review of source code and the implemented software countermeasures. The effectiveness of software security countermeasures is then guaranteed by the use of a certified compiler [START_REF] Leroy | Formal certification of a compiler back-end or: programming a compiler with a proof assistant[END_REF]. Injecting control flow integrity checks at compile time would require to certify the modified compiler. To avoid this difficult and expensive task, countermeasures must be designed and inserted at a high code level.

In this paper, we propose a full methodology 1) to detect harmful attacks that disrupt the control flow of native C programs executed on a secure element and 2) to automatically inject formally verified countermeasures into the code. In the first step of our methodology, the set of harmful attacks is determined through an exhaustive search relying on a classification of attack effects from a functional point of view. The identified harmful attacks can be visualized spatially in order to identify the affected functions and to precisely locate the corresponding sensitive code regions. Following our methodology, a tool automatically injects countermeasures into the code to be protected without any direct intervention of a developer. The countermeasure scheme proposed in this paper operates at function level. Countermeasures rely on counters that are incremented and checked throughout execution enabling detection of any attack that disrupts control flow by not executing at least two adjacent statements of the code. The effectiveness of the proposed countermeasure scheme has been formally verified: any attack that jumps over more than two C statements is detected. This is confirmed by experimental results for three well-known encryption algorithms and additionally results show that 1) attacks are much more difficult to perform on the secured code and that 2) attacks trying to call an unexpected function are detected.

The paper is organized as follows: Section 2 discusses related work. Section 3 gives an overview of our methodology detecting application weaknesses and automatically securing an application code. Section 4 details the detection of weaknesses and visualization. Section 5 and 6 respectively presents the countermeasures for hardening a code against control flow attacks and the formal approach used for verifying their correctness. Section 7 presents experimental results.

Related work

This section discusses work related to fault models before presenting previously proposed countermeasures for smart card and control flow integrity.

Fault models

Countermeasures are necessarily designed with respect to a fault model specifying the type of faults an attacker is able to carry out [START_REF] Verbauwhede | The fault attack jungle -a classification model to guide you[END_REF]. Elaborating a fault model requires analysis of the consequences of physical attacks and modeling them at the desired level (architectural level, assembly code level, source code level). Consequences of fault attacks, at program level, include the processing of corrupted values by the program, a corrupted program control flow or a corrupted program as a result of changed instructions. In this paper, we focus on attacks that impact control flow of native C programs.

Several works [START_REF] Moro | Electromagnetic Fault Injection: Towards a Fault Model on a 32-bit Microcontroller[END_REF][START_REF] Balasch | An in-depth and black-box characterization of the effects of clock glitches on 8-bit MCUs[END_REF] have shown that attacks can induce instruction replacements. For example, electromagnetic pulse injections can induce a clock glitch on the bus during transmission of instruction from the Flash memory resulting in an instruction replacement [START_REF] Moro | Electromagnetic Fault Injection: Towards a Fault Model on a 32-bit Microcontroller[END_REF]. Such an instruction replacement can provoke a control flow disruption in the two following cases:

1. The evaluation of a condition is altered, by the replacement of one instruction involved in the computation, causing the wrong branch to be taken.

Inverting the condition of a conditional branch instruction by only replacing the opcode in the instruction encoding has the same consequence. 2. The replacement of a whole instruction by a jump at any location of the program. The executed instruction becomes a jump to an unexpected target [START_REF] Bouffard | Combined software and hardware attacks on the java card control flow[END_REF][START_REF] Moro | Electromagnetic Fault Injection: Towards a Fault Model on a 32-bit Microcontroller[END_REF]. The same effect is obtained if the target address of a jump is changed by corrupting the instruction encoding or, in case of indirect jump, if computation of the target address is disrupted. This also happens if the program counter becomes the destination operand of the replacing instruction, e.g.

an ALU instruction such a PC = PC +/-cst which are the most likely to succeed into a correct jump.

In this paper, we consider jump attacks as described in the second case just above.

Code securing and control flow securing

Code securing techniques can be applied to the whole application or only to specific parts. Securing only sensitive code regions requires to know weaknesses which need to be strengthened for a given fault model. When considering some convenient fault models or when varying input, tractable static analysis, such as taint analysis, can be used to infer the impact of a fault on control flow [START_REF] Ceara | Detecting Software Vulnerabilities -Static Taint Analysis[END_REF] or to detect missing checks [START_REF] Yamaguchi | Chucky: exposing missing checks in source code for vulnerability discovery[END_REF]. To the best of our knowledge, no previous work has considered a jump attack fault model probably due to its complexity: all possible jumps from one point of the program to another point have to be considered.

Protections against control flow attacks depend then on the nature of the attacks. If the evaluation of a condition involved in a conditional branch is disrupted at runtime, recovering techniques must strengthen the condition computation. This can be achieved by inserting redundancy and appropriate checks [START_REF] Barenghi | Fault Injection Attacks on Cryptographic Devices: Theory, Practice, and Countermeasures[END_REF]. Countermeasures designed for ensuring control flow integrity or code integrity often rely on signature techniques or on checks to ensure the validity of accesses to the instruction memory or of the target address of jump instructions.

Signature techniques typically rely on an offline computation of a checksum for each basic block. At runtime, the protected code recomputes the checksum of the basic block being executed and compares with the expected result. Dedicated hardware [START_REF] Xia | CFIMon: Detecting violation of control flow integrity using performance counters[END_REF][START_REF] Fiskiran | Runtime execution monitoring (REM) to detect and prevent malicious code execution[END_REF] can be used to compute signatures dynamically. However, solutions requiring hardware modification are unpractical for smart cards. Several works proposed to integrate the checks at software level [START_REF] Oh | Control-flow checking by software signatures[END_REF][START_REF] Chen | Oblivious hashing: A stealthy software integrity verification primitive[END_REF][START_REF] Goloubeva | Soft-error detection using control flow assertions[END_REF]. Oh et al. [START_REF] Oh | Control-flow checking by software signatures[END_REF] only checks the destinations of all jumps. Bletsch et al. [START_REF] Bletsch | Mitigating code-reuse attacks with control-flow locking[END_REF] focus on return-oriented attacks. Abadi et al. [START_REF] Abadi | Control-flow integrity[END_REF] proposed a broader method for ensuring control flow integrity which checks for both the source and the destination of jumps. However, this approach relies on a new machine instruction.

For javacard enabled smart card, software components of the virtual machine can perform security checks. Basic block signature computations and checks can then be carried out by the virtual machine, as proposed by [START_REF] Iguchi-Cartigny | Evaluation of Countermeasures Against Fault Attacks on Smart Cards[END_REF]. A transition automaton, in which each state corresponds to a basic block and each transition corresponds to allowed control flow, can also be built by analyzing the bytecode [START_REF] Bouffard | Detecting laser fault injection for smart cards using security automata[END_REF]. Calls to setState(), added to the source code, instruct the virtual machine to check the integrity of the control flow by comparing the current state with the allowed ones according to the automaton. The virtual machine can also check the validity of the bytecode address to avoid the execution of any bytecode stored outside the applet currently being executed [START_REF] Lackner | A defensive virtual machine layer to counteract fault attacks on java cards[END_REF]. However, a small jump inside the allowed bytecode, for example inside a function, would not be detected and might have serious consequences for security. These java card approaches rely on the ability to perform runtime checks during the interpretation of the bytecode. For native programs, it is mandatory to include any software countermeasure inside the code, as proposed in [START_REF] Oh | Control-flow checking by software signatures[END_REF][START_REF] Chen | Oblivious hashing: A stealthy software integrity verification primitive[END_REF][START_REF] Goloubeva | Soft-error detection using control flow assertions[END_REF].

Approaches that verify the direction or the target address of branches or jumps only harden the control flow integrity at basic blocks boundaries. This is not sufficient to cover physical faults that cause an unconditional jump from an instruction inside a basic block to another instruction inside another basic block. The approach proposed in this paper enforces the control flow integrity with a granularity of one C statement, which is finer than basic block granularity.

Two previously proposed approaches also use a step counter to protect a code region [START_REF] Bouffard | Detecting laser fault injection for smart cards using security automata[END_REF][START_REF] Nicolescu | SIED: Software implemented error detection[END_REF]. The former targets computation disruption while the latter combined counters with a signature approach at assembly level to ensure tolerance to hardware fault. The use of a certified compiler requires to work at the source code level as proposed in this paper. Our approach, based on counters, is similar to the intra basic block approach of [START_REF] Nicolescu | SIED: Software implemented error detection[END_REF] for securing sequential code. But our approach operates at higher code level and is able to harden control flow of high level constructs.

Thus, in the specific context of smart cards or secure elements, to the best of our knowledge, no research work has proposed formally verified and experimentally evaluated countermeasures at C level that ensure control flow integrity in the presence of jump attacks during native execution. This section gives an overview of our methodology, supported by tools and represented in Figure 1, to help developers to improve the security of smart card C codes subject to physical attacks inducing jumps. Our approach starts with a functional C code of the application. A distinguisher is necessary in order to discriminate between an execution that gives advantage to an attacker and an execution that does not. The full code security analysis and securing methodology can be split into two main steps.

The first step identifies the weaknesses in the code by simulating all possible attacks during code execution. The output of all these executions is passed to a classification tool that classifies attacks as harmful or as harmless. We refer to these classes as bad and good, respectively. While the bad class contains all attacks that give advantages to the attacker, the good class is the set of attacks that have no effect from a security point of view.

The second step consists in hardening the code. It relies on automated injection of countermeasures that ensure control flow integrity for any function that has been successfully attacked in the first step. The design of the countermeasures is detailed in Section 5 and the verification of their correctness is explained in Section 6. Note that, once a code has been secured, the evaluation of the efficiency of the implemented countermeasures or the identification of remaining weaknesses can be achieved by returning to the weaknesses detection step.

We have also implemented a visualization tool offering a graphical representation of the attacks classification and enabling to have a look at the code regions corresponding to harmful attacks.

In this section, we describe the part of our methodology that identifies harmful attacks. The identification of weaknesses is carried out by simulating, classifying and visualizing physical attacks at source code level.

Simulation of attacks

Motivations to work at source code level. As code securing is often performed at source level by developers, simulating attacks at this level allows to identify the harmful ones as well as the code regions that should be secured. Simulating attacks at assembly level would require to match assembly instructions with the source code which is not trivial [START_REF] Berthomé | High level model of control flow attacks for smart card functional security[END_REF]. Furthermore, assembly programs are tightly coupled to specific architectures. Thus, simulating attacks at assembly programming limits portability. It is also time-consuming. Indeed, simulation of attack injection at the source code level speeds up the detection of weaknesses compared to injection at assembly level due to the lower number of source statements. However, jump attacks that start/arrive inside a C statement cannot be simulated at C level [START_REF] Berthomé | High level model of control flow attacks for smart card functional security[END_REF]. Nevertheless, it is helpful to detect as many weaknesses as possible at source code level, and as we show in the experimental results, working at this level enables to strengthen code security by making successful attacks very difficult to perform.

Simulation of C level attacks. In order to discover harmful attacks, we simulate jump attacks using software hacks at C level, as proposed in [START_REF] Berthomé | High level model of control flow attacks for smart card functional security[END_REF]. For each function of the application, all possible intra-procedural jump attacks that jump backward or forward C statements are injected at source level. Figure 2 illustrates all possible jumps within a function, sorted according to their distance expressed in statements. Statements in this context are C statements such as assignments, conditional expressions (e.g. if (cond1) or while(cond2)) and also any bracket or syntactic elements (e.g. }else{ or the bracket between P14 to P15) that impact control flow.

Classification of simulated attacks

The benefits of an attack differ depending on the application and the context of its use. A successful attack may break data confidentiality (by forcing a leak of sensitive data such as an encryption key or a PIN code) or may break the integrity of an application (by corrupting an embedded service). In order to cover the various benefits for an attacker in a general way, our methodology requires a distinguisher to be provided. This distinguisher must be able to classify as bad any execution where an attack has succeeded in breaking the expected security property of the code. Other attacks can be assigned to the good class. A finer classification of the effects of an attack can be achieved by providing a more precise distinguisher. In the remainder of the paper, we consider four different classes: bad: during execution a benefit has been obtained by the attacker; good: We assume that no benefit can be obtained by an erroneous or endless execution, so both error and timeout cases are distinguished from bad cases in the remainder of the paper. If an error is preceded by a gain, such as a leak of sensitive information, the distinguisher must be able to discriminate between these attack effects.

Weaknesses analysis and visualization

Since our securing scheme operates at function level, the detection of weaknesses aims at identifying harmful attacks at source code level in order to identify the functions to be secured. Thus, any function that, when attacked, exhibits a bad case is considered for the countermeasure injection. The tools supporting our methodology offer a visualization tool that can be used by a security expert or a developer to quickly understand which variables and functionalities are involved in the generation of harmful attacks by analyzing the jumped part of the code. The visualization tool builds a graphical representation of the results of the identification of weaknesses by drawing a square at the coordinate (source line, target line) using the color associated to its class. To illustrate this, consider the function aes addRoundKey cpy of an implementation of AES-256 [START_REF] Levin | A byte-oriented AES-256 implementation[END_REF] in C, used later in experiments, given in Figure 3. The distinguisher considers as bad any execution producing incorrect encrypted data, representing the attacker's ability to disrupt the encryption. The visualization of the weaknesses is illustrated in the right part of Figure 3. All except one forward jump generate a bad case (orange squares correspond to a jump size of one statement, red squares to a larger jump distance). Analyzing statements impacted by these harmful attacks shows that the whole loop body, hence the whole function, must be secured. In this section, we present the countermeasures we have designed to detect jump attacks with a distance of at least two C statements. These countermeasures deal with the different high-level control-flow constructs such as straight line flow, ifthen-else and loops. Countermeasures are presented in C-style in Appendix A and use the macros shown in Figure 4. Note that all macros are expanded to only one line of source code.

Protection of a function and straight-line flow of statements

To secure the control flow integrity of a whole function or a whole block of straight-line statements, our securing scheme uses a dedicated counter. Each function or each block of sequential code has its own counter to ensure its control flow integrity. Counters are incremented after each C statements of the original source code using the CHECK INCR macro. Before any incrementation, a check of the expected value of the counter is performed. When a check fails, a handler named, killcard() as the one used in smart card community, stops the execution.

To ensure control flow integrity, checks and incrementations of counters need to be nested. Consider the example in Figure 5 that illustrates the countermeasure for a function g with a straight-line control flow composed of N statements. The dedicated statement counter cnt g is declared and initialized outside the function, i.e., in any function f calling g prior to each call to g. The initialization associated to the counter declaration is surrounded by two checks and incrementations of the counter cnt f dedicated to the block of the function f where g is called. Moreover, the initialization value is different for each function which enables the detection of any call to another function as shown in the experiments. A reference to the counter cnt g is passed to g as an extra parameter. Upon return from g, a check of the values of both counters cnt f and cnt g is performed in order to detect any corruption of the flow inside the function g. This way, any jump to the beginning of the function is detected inside the called function g. Any jump to the end of a function is caught when the control flow returns to the calling function. The nesting of counter checks is at the core of our countermeasure scheme ensuring control flow integrity.

Conditional if-then and if-then-else constructs

High level conditional control flow refers to if-then or if-then-else constructs, illustrated by the example on the left part of Figure 6. The securing scheme for conditional flow is illustrated in the right part of the Figure . For such a construct, our securing scheme requires 2 counters cnt then and cnt else (for the control flow integrity of each branch of the conditional construct) and one extra variable b to hold the value of the condition of the conditional flow. Declarations and initializations of cnt then, cnt else and b are performed outside the if-thenelse block. Similar to functions or straight-line blocks, these new statements are interleaved with checks and incrementations of the counter cnt used for the control flow of the surrounding block. This is performed by the additionnal statements in the red box on the upper right part of Figure 6. The condition evaluation in the secured version is performed through the macro CHECK INCR COND: if the counter cnt for the flow integrity of the surrounding block holds the expected value, cnt is incremented and the condition is evaluated. Thus, any jump attack over the condition evaluation is detected after the if-then-else construct, when checking the cnt counter. The extra variable b is set to the value of the condition, in order to be able to distinguish, after the execution of the if-then-else construct, which branch has been taken. Both counters dedicated to the conditional branches are then checked according to the value of b. This is performed by the code corresponding to the CHECK END IF ELSE Fig. 6. Securing conditional control flow macro inserted between two checks of the counter cnt. Again, this nesting of counter checks is at the core of the effectiveness of our countermeasure scheme.

Loop constructs

We have also designed a countermeasure scheme for loops. Due to lack of space, we only present while loops. Any other loop constructs (for, do while) can be rewritten into a while construct. The left part of Figure 7 shows a while loop and the corresponding control flow between statements stmt 1, stmt 2 and stmt 3 of the surrounding sequential code. Our countermeasure scheme uses one counter, cnt while, for securing the control flow of the loop body. Similar to conditional constructs, our countermeasure scheme requires an extra variable b to hold the value of the loop condition. The variable b is needed at the end of the loop to verify correct execution of the loop body and correct termination of the loop. This is performed by the CHECK END LOOP macro which is surrounded by CHECK INCR of the counter cnt. The b variable is declared and initialized outside the loop as for the other constructs. The initial value must be true: if an attack jumps over the loop, b holds true and the CHECK END LOOP macro, checking for b being false after the loop, detects the attack. The cnt while counter is reset before each initial iteration using the RESET CNT(cnt while, val) macro with val being the final value of the counter after one iteration.

The reset is performed only if cnt while is equal to 0 or to the value val that is expected after one complete iteration. As a jump from the end of the loop to the beginning of the body would result in a correct value for cnt while that is reset before each new iteration, the first check inside the loop body of the while counter is guarded with b to detect a jump attack leading to an additional iteration of the loop. Moreover, the evaluation of the condition (that may update an induction variable) is performed along with a check and an incrementation of the counter cnt while using the CHECK INCR COND macro. Hence, any attack that jumps over the evaluation of the condition of the loop will then be detected inside the loop.

We have also designed a countermeasure scheme for other C constructs such as switch case, break, multiple returns, goto. Due to space limitations and their absence in applications we have considered, they are not presented here.

Formal verification of countermeasures

Formal verification of our securing scheme helped us designing effective countermeasures and gives strong confidence in their effectiveness against attacks. In this section, we present the models used for program execution from a control flow point of view and for jump attacks, as well as properties to check to ensure the control flow integrity of a secured program execution even in presence of attacks. The verification of the correctness of the secured code is based on an equivalence checking with the original code.

Code representation and decomposition for CFI verification

From a control flow perspective, a program execution can be viewed as the execution of a sequence of statements. A high-level program can be represented as a transition system whose states are defined by the values of variables of the program (contents of the memory) and of the program counter whose value specifies a source code line in the C program. Any transition mimics the state transformation induced by the execution of an individual statement: updating the program counter and potentially changing variables or the contents of memory. Figure 8 illustrates the representation of a program as a transition system.

A program can be decomposed into functions, and any function body can be decomposed into top-level code regions containing either only straight-line statements or a single control flow construct (loops or if-then-else). Sequential execution of these regions guarantees that, if the control flow integrity is ensured at the end of a code region, the following code region starts with a correct input from a control flow point of view. Thus, the integrity of the control flow of both code regions can be proven by proving the control flow integrity of each code region. Our countermeasure scheme relies on securing each control flow construct (function call/sequential code, if-then-else, while constructs) nested with few straight-line statements of the surrounding block. Then, our approach consists in verifying separately for each control flow construct enclosed with straight-line statements of the surrounding block that all possible executions of the secured version are stopped by a countermeasure in presence of harmful attacks or their control flow is upstanding with respect to the initial code.

As control flow constructs can be nested, many combinations of control flow constructs could be modeled. However, any control flow construct can be viewed as a single statement which is correctly executed or not. Thus, in the models used for verification of our countermeasures, we only consider straight-line statements inside control flow constructs. The idea is that, if properties hold for each individual construct, they hold for all of their combinations.

Models for verification of control flow integrity

State machine model. To model and verify the integrity of the control flow, we associate to each statement stmt i of the original code of a function α a dedicated verification counter denoted cntv αi. In the remainder of the paper, we refer to such counters as statement counter. We model the execution of a statement stmt i by incrementing its associated statement counter cntv αi.

Then, the execution of a sequence of statements is modeled by a transition system T S, defined by T S = {S, T, S 0 , S f , L}, where S is the set of states, T the set of transitions T : S → S, S 0 and S f are the subsets of S containing the initial states and final states respectively. The final states from S f are absorbing states. A state from S is defined by the value of the program counter and the value of statement counters associated to every statement of the initial code. L is a set of labels corresponding to the possible values of the program counter, i.e. line numbers in the source code. Initial states are states with a program counter value equal to the first line of the modeled code and where all statement counters hold 0. Any transition from T is defined by the effect of the statement stmt i associated to the program counter value. Transitions change the program counter value to the next line number to be executed and increment the statement counter cntv αi associated to stmt i of function α. A jump attack, as considered, can only corrupt the program counter. Thus, for such attacks, modeling the memory and other registers is not relevant.

To prove that our countermeasure scheme for a construct c is robust against a jump attack and that its secured version is equivalent to the initial one, we build two transition systems: one for the initial control-flow construct named M(c) and another one for the version including countermeasures named CM(c). Jump attack model. A jump attack is equivalent to the modification of the program counter with an unexpected value. As our countermeasures are effective against attacks that jump at least two lines, we add faulty transitions between every pair of states of CM(c) separated by at least one line of C. These transitions only update the program counter. The green arrows in CM(c) in Figure 8 illustrate all possible jump attacks occurring at line 3 of the code. As we assume that only a single fault can occur, every fault transition is guarded with a boolean indicating that a fault has already occurred.

Specification of control flow integrity and equivalence checking

To perform the verification of the control flow integrity and the correctness of a secured code, we connect the two transition systems M(c) and CM(c) in order to force the input (such as condition value, iteration counts), if any, to be identical. The model checker builds a product of both models. We explain in this section, the properties to verify on this product.

To verify the correctness of the secured code, in the presence or absence of an attack, we need to prove that: Property 2 ensures the right execution counts of statements in CM(c) if the execution reaches a correct final state. Property 3 checks that line i is always executed before line i+1 and after line i-1 or the execution will reach a killcard state. By transitivity, this property, if verified by all statement counters, ensures that in a straight-line flow, the statement of line k is always executed after line i and before line l with i < k < l both in M(c) and CM(c). Hence, Property 3 ensures the right order of execution of statements.

For a conditional flow or for a loop, Properties 1 and 2 are the same but the Property 3 changes slightly. For a conditional flow, such as the example in Figure 6, Property 3 specifies that at any time in an execution path that reaches a correct final state 1) the straight-line flow before and after the branches, condition included, is correct and 2) inside both branches, condition included, the straight-line flow is correct. Property 2 ensures that only one branch is executed. For a while loop as in Figure 7, Property 3 says that at any time in an execution that reaches a correct final state 1) the statements before and after the loop (condition excluded) are executed only once and in order; 2) the condition is never executed before its preceding statements, 3) statements inside the loop, condition included, are executed in order but their execution counts is not limited. Property 2 ensures the right number of iterations and Property 3 ensures the right control flow during execution.

We have chosen the Vis model checker [START_REF] Brayton | Vis: A system for verification and synthesis[END_REF] to prove the effectiveness of our countermeasure scheme. After modeling all the constructs given in this section and expressing the properties in CTL, all properties hold.

Experimental results

We implemented all software components4 presented in Figure 1. The countermeasures for control flow securing as well as the jump attacks for the detection of weaknesses are injected using a python C parser that manipulates the C instructions. For the experiments, we considered three well-known encryption algorithms available in C: AES [START_REF] Levin | A byte-oriented AES-256 implementation[END_REF], SHA [START_REF] Guthaus | MiBench: A free, commercially representative embedded benchmark suite[END_REF] and Blowfish [START_REF] Guthaus | MiBench: A free, commercially representative embedded benchmark suite[END_REF]. First, we simulated all the intra-procedural jump attacks at C level for each function (such as in Figure 2). A simulated attack is transient and triggered once during execution. However, using the gcov tool to determine how many times each line is executed, we simulated all possible instances of jump attacks from a Line i to a Line j. In all our experiments, the distinguisher classifies as bad any attack that provokes program termination with corrupted output. The second column of Table 1 shows that all attacks with a jump distance greater than or equal to two C statements are captured by our countermeasures. For example, 32 818 jump attacks were harmful for SHA whereas none was for its secured version (SHA + CM). The number of attacks jumping only one C statements is also reduced (third column). More important, the ratio of the remaining jump attacks of size one becomes very low (≤ 0.3%). For example, for AES the bad cases of size one decrease from 33.2% to 0.2%. Also, we simulated all possible intra-procedural jump attacks at assembly level targeting the aes encrypt function of AES executed by an ARM Cortex-M3 processor. We used the Keil ARM-MDK compiler and Keil simulator [START_REF]Keil uVision for ARM processors[END_REF] for the replacement of any instruction by a jump anywhere into the same function. We considered only one function due to a very long simulation time (3 weeks), highlighting the benefits to perform the attack simulation at source level. Results are presented in the asm jump attacks section of Table 1. The harmful attacks in the secured version represent only 40% of the ones in the original code: our countermeasures enable to defeat 60% of the attacks on this example. Moreover, only 0.2% of attacks give advantage to the attacker while 78.4% are detected. Thanks to the frequent checks added by our countermeasures, the harmful attacks are much harder to perform on the secured code. It shows our countermeasures are effective while being implemented at source code level.

Finally, we simulated attacks that call an unexpected function instead of the expected one for all the benchmarks using the Keil simulator. Results, presented in the asm call attacks section of Table 1, show that all harmful attacks are captured and many harmless attacks are also detected. Thus, our countermeasures are also very effective against unexpected function calls.

Table 2 reports code sizes as well as execution times of both the original version and the secured one, for a x86 target machine and a cortex-M3 processor. For the x86 platform, the execution time overhead ranges from +59% (blowfish) up to +106% (AES). For the embedded ARM processor, the overhead is higher as the simpler processor does not exploit instruction level parallelism. The highest overhead is also achieved for AES (+400%). As all functions of our benchmarks exhibit vulnerabilities, they were all fully secured by our methodology. We will consider in future work how to achieve at least the same level of security without fully securing sensitive functions. However, as a smart card is primarily the host of sensitive operations, ensuring the required security level is crucial. Full code securing often implies such a high overhead [START_REF] Moro | Formal verification of a software countermeasure against instruction skip attacks[END_REF][START_REF] Nicolescu | SIED: Software implemented error detection[END_REF].

Conclusion

This paper has presented a methodology to automatically secure any C application with formally verified countermeasures at source level. Results has shown that these countermeasures defeat 100% of C jump attacks with a distance of two statements or beyond. Moreover, our countermeasures are able to capture all unexpected function calls. They also have been able to reduce significantly the number of attacks injected at assembly level: for the studied function, 60% of the assembly jump attacks were eliminated. Future work will address the optimization of countermeasure injection according to the weaknesses detection step. If harmless attacks are found inside a function, countermeasures might be adapted accordingly to reduce their cost while preserving their effectiveness.

Fig. 1 .Fig. 2 .

 12 Fig. 1. Code securing methodology

#Fig. 4 .

 4 Fig. 4. Security macros used for control flow securing

Fig. 5 .

 5 Fig. 5. Securing function call and straight-line flow

Fig. 7 .

 7 Fig. 7. Securing loop control flow

Fig. 8 .

 8 Fig. 8. Compact representation of TS for a function call and straight-line statements

  Figure 8 illustrates a compact representation of both transition systems for a generic example code with a call to a function composed of straight-line statements. In a secured version, checks may result in a call to killcard(). Hence, there is an additional program counter value denoted killcard in any CM(c). All states with this program counter value are final. All transitions labeled with a countermeasure macro may change the program counter to killcard. Due to the high number of such transitions, only a subset is represented in order to keep the Figure readable.

1 .

 1 Any path in M(c) or CM(c) reaches a final absorbing state. 2. The statement counter values in any final correct state in CM(c) (with a program counter value different from killcard) are equal to the statement counter values in final states of M(c). 3. In CM(c) at any time and in any path, counters cntv αi and cntv α(i+1) for two adjacent statements stmt i and stmt i+1 in a straight-line flow respects 1 ≥ cntv αi ≥ cntv α(i+1) ≥ 0 or execution will reach a final state with the killcard value for the program counter.

Table 1 .

 1 Jump attack classification for original and secured version (+ CM)

		bad	bad	good	killcard	error	total
		size > 1	size = 1
	c jump attacks	Attacking all functions at C level for all transient rounds
	AES	7786 29% 1104 4.2% 17 372 65%		108 0.4%	26 370
	AES + CM	0	528 0.2% 18 015 5.3% 318 972 94%	1 0.0% 337 516
	SHA	32 818 75% 1528 3.5%	8516 19%		412 1.0%	43 274
	SHA + CM	0	1149 0.3%	5080 1.2% 421 200 98%	261 0.1% 427 690
	Blowfish	70 086 32% 3550 1.7% 134 360 62%		5725 2.7% 213 721
	Blowfish + CM	0	2470 0.2% 331 664 23% 1 060 156 75% 6065 0.4% 1 400 355
	asm jump attacks Attacking the aes encrypt function at ASM level for the first transient round
	aes encrypt	1566 82.8%	36 1.9%	179 9.4%		111 5.9%	1892
	aes encrypt + CM	627 0.2%	21 0%	63 040 20.2% 239 303 78.4% 2264 0.7% 305 255
	asm call attacks	Attacking all function calls at ASM level for the first transient round
	AES	249 59.3%		139 33.1%		32 5%	420
	AES + CM	0		21 5%	398 94.8%	1 0.2%	420
	SHA	35 48.7%		13 18%		24 33.3%	72
	SHA + CM	0		8 11.1%	61 84.7%	3 4.2%	72
	Blowfish	9 21.4%		18 42.9%		15 35.7%	42
	Blowfish + CM	0		18 42.9%	17 40.5%	7 16.6%	42

Table 2 .

 2 Size and overhead for original and secured version (+ CM)

			x86			arm-v7m
		Simulation	Size	Execution time	Size	Execution time
		time	bytes overhead time overhead bytes overhead time	overhead
	AES	27m 17 996	1.27 ms	4216	38.3 ms
	AES + CM	9h 46m 30 284 (+68%) 2.61 ms (+106%) 15 696 (+272%) 191.7 ms (+400.5%)
	SHA	1h 18m 13 235	1.47 µs	3184	106.5µs
	SHA + CM	16h 52m 21 702 (+64%) 2.81 µs (+91%)	7752 (+143%) 499.1µs (+368%)
	Blowfish	5h 52m 30 103	47.6 µs	6292	3.02 ms
	Blowfish + CM 3d 6h 19m 46 680 (+55%) 70.6 µs (+48%) 16 396 (+161%) 6.3 ms (+109%)

A demonstration video is available at: http://dai.ly/x205n3x

A Countermeasures securing codes

This section presents the implementation of the countermeasures of Figure 5, 6 and 7 using the macros of Figure 4.

The implementation of countermeasures for function calls and sequence of statements are shown in the two listings below. The statement counter cnt g for a function g must be initialized with a value different that the one for all other functions in order to capture jump attacks that try to call another function. Moreover, the range of values taken by the statement counter of a function must be different from the ones of other functions in order to detect inter-procedural jumps. The listings below illustrate the implementation of the countermeasures for an if construct (left) and for a while construct (right). The while construct example contains the statements to be inserted to handle a for construct for the initialization of the induction variable and its incrementation.