* Convert stringified algorithm to enum class. * The string comparison is case insesitive. */
| 248 | * The string comparison is case insesitive. |
| 249 | */ |
| 250 | inline SCOPED_ENUM algorithm str_to_alg(const jwt::string_view alg) noexcept |
| 251 | { |
| 252 | if (!alg.length()) return algorithm::UNKN; |
| 253 | |
| 254 | if (!strcasecmp(alg.data(), "NONE")) return algorithm::NONE; |
| 255 | if (!strcasecmp(alg.data(), "HS256")) return algorithm::HS256; |
| 256 | if (!strcasecmp(alg.data(), "HS384")) return algorithm::HS384; |
| 257 | if (!strcasecmp(alg.data(), "HS512")) return algorithm::HS512; |
| 258 | if (!strcasecmp(alg.data(), "RS256")) return algorithm::RS256; |
| 259 | if (!strcasecmp(alg.data(), "RS384")) return algorithm::RS384; |
| 260 | if (!strcasecmp(alg.data(), "RS512")) return algorithm::RS512; |
| 261 | if (!strcasecmp(alg.data(), "ES256")) return algorithm::ES256; |
| 262 | if (!strcasecmp(alg.data(), "ES384")) return algorithm::ES384; |
| 263 | if (!strcasecmp(alg.data(), "ES512")) return algorithm::ES512; |
| 264 | |
| 265 | return algorithm::UNKN; |
| 266 | |
| 267 | JWT_NOT_REACHED("Code not reached"); |
| 268 | } |
| 269 | |
| 270 | /** |
| 271 | */ |
no test coverage detected