Pairwise and triple key distribution in wireless sensor networks with applications