This is modified from PolyLibTLS-master. For advancement.