1 /* passwd.c: The opiepasswd() library function.
4 This software is Copyright 1996-2001 by Craig Metz, All Rights Reserved.
5 The Inner Net License Version 3 applies to this software.
6 You should have received a copy of the license with this software. If
7 you didn't get a copy, you may request one from <license@inner.net>.
11 Modified by cmetz for OPIE 2.32. Renamed mode to flags. Made flag
12 values symbolic constants. Added a flag for insecure override
14 Modified by cmetz for OPIE 2.31. Removed active attack protection
16 Modified by cmetz for OPIE 2.3. Split most of the function off
17 and turned this into a front-end for the new __opiewriterec().
18 Added code to compute the key from the secret. Use the opie_
19 prefix. Use new opieatob8() and opiebtoa8() return values.
20 Created by cmetz for OPIE 2.22.
26 int opiepasswd FUNCTION((old, flags, principal, n, seed, ks), struct opie *old AND int flags AND char *principal AND int n AND char *seed AND char *ks)
31 if ((flags & OPIEPASSWD_CONSOLE) && opieinsecure())
33 if (!(flags & OPIEPASSWD_FORCE))
34 #endif /* INSECURE_OVERRIDE */
37 memset(&opie, 0, sizeof(struct opie));
40 opie.opie_flags = old->opie_flags;
41 opie.opie_recstart = old->opie_recstart;
44 opie.opie_principal = principal;
46 opie.opie_seed = seed;
49 struct opie_otpkey key;
51 if (flags & OPIEPASSWD_CONSOLE) {
52 if (opiekeycrunch(MDX, &key, seed, ks))
56 if (!(opie.opie_val = opiebtoa8(opie.opie_buf, &key)))
59 if ((opieetob(&key, ks) != 1) && !opieatob8(&key, ks))
61 if (!(opie.opie_val = opiebtoa8(opie.opie_buf, &key)))
66 if (opielock(principal))
69 i = __opiewriterec(&opie);