
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@885 ec53bebd-3082-4978-b11e-865c3cabbd6b
42 lines
718 B
C
42 lines
718 B
C
#ifdef HAVE_CONFIG_H
|
|
#include "config.h"
|
|
RCSID("$Id$");
|
|
#endif
|
|
|
|
#include "otp_locl.h"
|
|
|
|
int
|
|
otp_verify_user_1 (OtpContext *ctx, char *passwd)
|
|
{
|
|
OtpKey key1, key2;
|
|
|
|
if (otp_parse (key1, passwd, ctx->alg))
|
|
return -1;
|
|
memcpy (key2, key1, sizeof(key1));
|
|
ctx->alg->next (key2);
|
|
if (memcmp (ctx->key, key2, sizeof(key2)) == 0) {
|
|
--ctx->n;
|
|
memcpy (ctx->key, key1, sizeof(key1));
|
|
return 0;
|
|
} else
|
|
return -1;
|
|
}
|
|
|
|
int
|
|
otp_verify_user (OtpContext *ctx, char *passwd)
|
|
{
|
|
void *dbm;
|
|
int ret;
|
|
|
|
otp_verify_user_1 (ctx, passwd);
|
|
dbm = otp_db_open ();
|
|
if (dbm == NULL) {
|
|
free(ctx->user);
|
|
return -1;
|
|
}
|
|
ret = otp_put (dbm, ctx);
|
|
free(ctx->user);
|
|
otp_db_close (dbm);
|
|
return ret;
|
|
}
|