more shared code

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@1552 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Assar Westerlund
1997-04-06 01:31:53 +00:00
parent 21232c4e99
commit 7dee4d8b3b

View File

@@ -2183,12 +2183,13 @@ parse_words(unsigned wn[],
return 0;
}
int
otp_parse_stddict (OtpKey key, char *str)
static
otp_parse_internal (OtpKey key, char *str, OtpAlgorithm *alg,
int (*convert)(char *, void *))
{
unsigned wn[6];
if (parse_words (wn, str, get_stdword, NULL))
if (parse_words (wn, str, convert, alg))
return -1;
compress (key, wn);
if (otp_checksum (key) != (wn[5] & 0x03))
@@ -2196,17 +2197,16 @@ otp_parse_stddict (OtpKey key, char *str)
return 0;
}
int
otp_parse_stddict (OtpKey key, char *str)
{
return otp_parse_internal (key, str, NULL, get_stdword);
}
int
otp_parse_altdict (OtpKey key, char *str, OtpAlgorithm *alg)
{
unsigned wn[6];
if (parse_words (wn, str, get_altword, alg))
return -1;
compress (key, wn);
if (otp_checksum (key) != (wn[5] & 0x03))
return -1;
return 0;
return otp_parse_internal (key, str, alg, get_altword);
}
int