mirror of
https://github.com/cryb-to/cryb-to.git
synced 2024-12-21 12:01:08 +00:00
Finish and hook up half-written name-to-enum / enum-to-name conversion for OATH modes.
This commit is contained in:
parent
a36ae775dd
commit
be954631db
3 changed files with 21 additions and 17 deletions
|
@ -45,9 +45,11 @@ const char *cryb_oath_version(void);
|
|||
#define oath_key_alloc cryb_oath_key_alloc
|
||||
#define oath_key_create cryb_oath_key_create
|
||||
#define oath_key_dummy cryb_oath_key_dummy
|
||||
#define oath_key_from_uri cryb_oath_key_from_uri
|
||||
#define oath_key_free cryb_oath_key_free
|
||||
#define oath_key_from_uri cryb_oath_key_from_uri
|
||||
#define oath_key_to_uri cryb_oath_key_to_uri
|
||||
#define oath_mode_name cryb_oath_mode_name
|
||||
#define oath_mode_value cryb_oath_mode_value
|
||||
|
||||
struct oath_key *oath_key_alloc(void);
|
||||
struct oath_key *oath_key_create(const char *, enum oath_mode,
|
||||
|
@ -59,6 +61,7 @@ char *oath_key_to_uri(const struct oath_key *);
|
|||
|
||||
struct oath_key *oath_key_dummy(enum oath_mode, enum oath_hash, unsigned int);
|
||||
|
||||
enum oath_mode oath_mode(const char *);
|
||||
const char *oath_mode_name(enum oath_mode);
|
||||
enum oath_mode oath_mode_value(const char *);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -11,6 +11,7 @@ libcryb_oath_la_SOURCES = \
|
|||
cryb_oath_key_from_uri.c \
|
||||
cryb_oath_key_free.c \
|
||||
cryb_oath_key_to_uri.c \
|
||||
cryb_oath_mode.c \
|
||||
\
|
||||
cryb_oath.c
|
||||
|
||||
|
|
|
@ -27,15 +27,13 @@
|
|||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
#include "cryb/impl.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <strings.h>
|
||||
|
||||
#include <security/oath.h>
|
||||
#include <cryb/oath.h>
|
||||
|
||||
static const char *oath_mode_names[om_max] = {
|
||||
[om_hotp] = "hotp",
|
||||
|
@ -43,13 +41,10 @@ static const char *oath_mode_names[om_max] = {
|
|||
};
|
||||
|
||||
/*
|
||||
* OATH
|
||||
*
|
||||
* Converts a mode name to the corresponding enum value
|
||||
* Returns the enum value that corresponds to an OATH mode name
|
||||
*/
|
||||
|
||||
enum oath_mode
|
||||
oath_mode(const char *str)
|
||||
oath_mode_value(const char *str)
|
||||
{
|
||||
enum oath_mode om;
|
||||
|
||||
|
@ -62,9 +57,14 @@ oath_mode(const char *str)
|
|||
return (om_undef);
|
||||
}
|
||||
|
||||
/**
|
||||
* The =oath_mode function returns the =enum oath_mode value that
|
||||
* corresponds to the specified string.
|
||||
*
|
||||
* AUTHOR UIO
|
||||
/*
|
||||
* Returns the name of an OATH mode given its enum value
|
||||
*/
|
||||
const char *
|
||||
oath_mode_name(enum oath_mode om)
|
||||
{
|
||||
|
||||
if (om >= 0 && om < om_max)
|
||||
return (oath_mode_names[om]);
|
||||
return (NULL);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue