enum class SignatureAlgorithm(val code: Byte) { ANON(0), RSA(1), DSA(2), ECDSA(3), UNKNOWN(-1); companion object { /** * Find signature algorithm instance by it's numeric [code] * @throws TLSExtension if no hash algorithm found by code */ fun byCode(code: Byte): SignatureAlgorithm = values().find { it.code == code } ?: UNKNOWN //throw TLSException("Unknown signature algorithm: $code") } }