1/* generator.c: The opiegenerator() library function. 2 |
3%%% portions-copyright-cmetz-96 4Portions of this software are Copyright 1996-1997 by Craig Metz, All Rights |
5Reserved. The Inner Net License Version 2 applies to these portions of 6the software. 7You should have received a copy of the license with this software. If 8you didn't get a copy, you may request one from <license@inner.net>. 9 10 History: 11 |
12 Modified by cmetz for OPIE 2.31. Renamed "init" to "init-hex". 13 Removed active attack protection support. Fixed fairly 14 bug in how init response was computed (i.e., dead wrong). |
15 Modified by cmetz for OPIE 2.3. Use _opieparsechallenge(). ifdef 16 around string.h. Output hex responses by default, output 17 OTP re-init extended responses (same secret) if sequence 18 number falls below 10. 19 Modified by cmetz for OPIE 2.2. Use FUNCTION declaration et al. 20 Bug fixes. 21 Created at NRL for OPIE 2.2. 22*/ --- 20 unchanged lines hidden (view full) --- 43 buffer += 4; 44 45 if (_opieparsechallenge(buffer, &algorithm, &sequence, &seed)) 46 return 1; 47 48 if ((sequence < 2) || (sequence > 9999)) 49 return 1; 50 |
51 if (opiepasscheck(secret)) 52 return -2; 53 54 if (i = opiekeycrunch(algorithm, key, seed, secret)) 55 return i; 56 |
57 |
58 if (sequence < 10) { 59 char newseed[OPIE_SEED_MAX + 1]; |
60 char newkey[8]; |
61 char *c; 62 char buf[OPIE_SEED_MAX + 48 + 1]; 63 |
64 while (sequence-- != 0) 65 opiehash(key, algorithm); 66 |
67 if (opienewseed(strcpy(newseed, seed)) < 0) 68 return -1; 69 70 if (opiekeycrunch(algorithm, newkey, newseed, secret)) 71 return -1; 72 73 for (i = 0; i < 499; i++) 74 opiehash(newkey, algorithm); 75 |
76 strcpy(response, "init-hex:"); |
77 strcat(response, opiebtoh(buf, key)); 78 sprintf(buf, ":%s 499 %s:", algids[algorithm], newseed); 79 strcat(response, buf); 80 strcat(response, opiebtoh(buf, newkey)); |
81 } else { 82 while (sequence-- != 0) 83 opiehash(key, algorithm); |
84 |
85 opiebtoh(response, key); 86 } 87 88 return 0; 89} |