new files
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@885 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
41
lib/otp/otp_verify.c
Normal file
41
lib/otp/otp_verify.c
Normal file
@@ -0,0 +1,41 @@
|
||||
#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;
|
||||
}
|
Reference in New Issue
Block a user