Refactored common used operations into TLS crypto helper