diff options
author | Harald Welte <laforge@gnumonks.org> | 2011-12-07 02:33:11 +0100 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2011-12-07 02:33:11 +0100 |
commit | a5ab1620f4fcd01306c82789f60975d646c1fad4 (patch) | |
tree | 0b489ba3d7821b041b00b4e11009387b56bbca12 | |
parent | 5c6032393bb997c9ca15378c13e0045a839cf53f (diff) |
auth_core: add functions for parsing algorithm names
-rw-r--r-- | include/osmocom/crypt/auth.h | 3 | ||||
-rw-r--r-- | src/gsm/auth_core.c | 20 |
2 files changed, 23 insertions, 0 deletions
diff --git a/include/osmocom/crypt/auth.h b/include/osmocom/crypt/auth.h index 12690f84..23e104c1 100644 --- a/include/osmocom/crypt/auth.h +++ b/include/osmocom/crypt/auth.h @@ -84,4 +84,7 @@ int osmo_auth_load(const char *path); int osmo_auth_supported(enum osmo_auth_algo algo); +const char *osmo_auth_alg_name(enum osmo_auth_algo alg); +enum osmo_auth_algo osmo_auth_alg_parse(const char *name); + #endif /* _OSMOCRYPTO_AUTH_H */ diff --git a/src/gsm/auth_core.c b/src/gsm/auth_core.c index c578df9d..c2a13a58 100644 --- a/src/gsm/auth_core.c +++ b/src/gsm/auth_core.c @@ -91,3 +91,23 @@ int osmo_auth_gen_vec_auts(struct osmo_auth_vector *vec, return impl->gen_vec_auts(vec, aud, rand_auts, auts, _rand); } + +const struct value_string auth_alg_vals[] = { + { OSMO_AUTH_ALG_NONE, "None" }, + { OSMO_AUTH_ALG_COMP128v1, "COMP128v1" }, + { OSMO_AUTH_ALG_COMP128v2, "COMP128v2" }, + { OSMO_AUTH_ALG_COMP128v3, "COMP128v3" }, + { OSMO_AUTH_ALG_XOR, "XOR" }, + { OSMO_AUTH_ALG_MILENAGE, "MILENAGE" }, + { 0, NULL } +}; + +const char *osmo_auth_alg_name(enum osmo_auth_algo alg) +{ + return get_value_string(auth_alg_vals, alg); +} + +enum osmo_auth_algo osmo_auth_alg_parse(const char *name) +{ + return get_string_value(auth_alg_vals, name); +} |