Now a days the wireless sensor technologies are mostly being used in a typical application areas including environmental, defence, medical, military and commercial enterprises. In upcoming years, wireless sensor networks will integrate more tiny sensors into a variety of application scenarios like cyber physical systems, IoT etc. The security of sensor networks is an important constraint for the healthy operations of overall system in untrusted areas as these entities may disturb the proper functioning of applications by injecting wrong data into sensor networks. One way to address this issue is to provide more security to sensor nodes and encrypt the communication among them. This paper presents methodology to design attack-aware efficient secure keying mechanism that provides secure data transmission from one sensor node to another. © 2019, Springer Nature Switzerland AG.