The increasing adoption of wireless sensor networks as a flexible and inexpensive tool for the most diverse applications, ranging from environmental monitoring to home automation, has raised more and more attention to the issues related to the design of specifically customized security mechanisms. The scarcity of computational, storage, and bandwidth resources cannot definitely be disregarded in such context, and this makes the implementation of security algorithms particularly challenging. This paper proposes a security framework for the generation of true random numbers, which are paramount as the core building block for many security algorithms; the intrinsic nature of wireless sensor nodes and their capability of reliably providing measurements of environmental quantities make them natural candidates as true random number generators. In order to provide robustness to common attacks, we additionally devised a protocol aimed at obscuring the actual source of data, by making nodes cooperate with their neighbors. Furthermore, we describe an enhanced version of our framework consisting in an optimization for use in the context of resource-constrained systems. SECURE RANDOM NUMBER GENERATION IN WIRELESS SENSOR NETWORKS 3843 the produced sequences show some periodicity and are actually reproducible. The attacker could in principle collect generated random numbers until the sequence restarts and then deterministically predict the rest of the sequence; a common used countermeasure consists in periodically changing the key after a certain time interval. PRNGs are widely used because they ensure good statistical properties and high bit rates; however, their viability completely depends on the actual randomness of the initialization seeds.As the name suggests, the physical approach relies on measurements related to physical phenomena; in this case, random numbers are generated as a function of a set of samples coming from sensory readings, and the generator is named a true random number generator (TRNG), because the sequence is actually non-deterministic and unpredictable. TRNGs do not need seeds nor secret keys and do not exhibit periodicity because of the independence of the current random number from its past values. TRNGs usually require post-processing operations because they often do not ensure sufficiently good statistical properties, so they are intrinsically characterized by lower bit rates with respect to the PRNGs counterpart. TRNGs are thus often used as random seed generators for PRNGs because they are too slow for standalone usage in applications requiring high-bit-rate random sequences.However, secure applications in the specific context of WSNs seldom require high-bit-rate random sequences; we will thus focus on TRNGs as the basic building block for a security infrastructure for WSNs.Moreover, sensor nodes are obvious candidates as data providers for TRNGs, because their natural purpose is to collect great amount of data for environmental monitoring. As reported in the recent literature, many of the typic...