Device-to-device (D2D) communication represents a promising technique to enable devices to communicate directly without the interaction of access points or base stations. The ad hoc and proximity nature of this communication introduce some very important security vulnerabilities. Key management, access control, privacy, secure routing, and transmission need dedicated signaling procedures and optimized implementation mechanisms that are appropriate for the mobile, low-energy, and low-processing power environment. This paper proposes a security mechanism for D2D communication involving the use of physically unclonable functions (PUF) for unique key generation, elliptic-curve cryptography (ECC) and Diffie-Hellman key exchange (DHKE) for key management, and Salsa20/20 as stream cyphering encryption method, suitable for confidentiality of the wireless transmissions. All these methods are implemented and tested on a software defined radio (SDR) communication platform consisting of a Zync-based system-onchip (SoC), complemented by radio frequency (RF) daughter boards from analog devices-an integration using hardware and software co-design.