Some modifications to handle unknown shared key