1 /* $NetBSD: skey.h,v 1.10 2016/01/22 23:25:51 dholland Exp $ */ 2 3 /* 4 * S/KEY v1.1b (skey.h) 5 * 6 * Authors: 7 * Neil M. Haller <nmh@thumper.bellcore.com> 8 * Philip R. Karn <karn@chicago.qualcomm.com> 9 * John S. Walden <jsw@thumper.bellcore.com> 10 * 11 * Modifications: 12 * Scott Chasin <chasin@crimelab.com> 13 * Todd C. Miller <Todd.Miller@courtesan.com> 14 * 15 * Main client header 16 */ 17 18 #include <stdio.h> 19 20 /* Server-side data structure for reading keys file during login */ 21 struct skey { 22 FILE *keyfile; 23 char buf[256]; 24 char *logname; 25 int n; 26 char *seed; 27 char *val; 28 long recstart; /* needed so reread of buffer is efficient */ 29 }; 30 31 /* Client-side structure for scanning data stream for challenge */ 32 struct mc { 33 char buf[256]; 34 int skip; 35 int cnt; 36 }; 37 38 /* Maximum sequence number we allow */ 39 #ifndef SKEY_MAX_SEQ 40 #define SKEY_MAX_SEQ 10000 41 #endif 42 43 /* Minimum secret password length (rfc2289) */ 44 #ifndef SKEY_MIN_PW_LEN 45 #define SKEY_MIN_PW_LEN 10 46 #endif 47 48 /* Max secret password length (rfc2289 says 63 but allows more) */ 49 #ifndef SKEY_MAX_PW_LEN 50 #define SKEY_MAX_PW_LEN 255 51 #endif 52 53 /* Max length of an S/Key seed (rfc2289) */ 54 #ifndef SKEY_MAX_SEED_LEN 55 #define SKEY_MAX_SEED_LEN 16 56 #endif 57 58 /* Max length of S/Key challenge (otp-???? 9999 seed) */ 59 #ifndef SKEY_MAX_CHALLENGE 60 #define SKEY_MAX_CHALLENGE (11 + SKEY_MAX_HASHNAME_LEN + SKEY_MAX_SEED_LEN) 61 #endif 62 63 /* Max length of hash algorithm name (md4/md5/sha1/rmd160) */ 64 #define SKEY_MAX_HASHNAME_LEN 6 65 66 /* Size of a binary key (not NULL-terminated) */ 67 #define SKEY_BINKEY_SIZE 8 68 69 /* Location of random file for bogus challenges */ 70 #define _SKEY_RAND_FILE_PATH_ "/var/db/host.random" 71 72 /* Prototypes */ 73 void f(char *); 74 int keycrunch(char *, const char *, const char *); 75 char *btoe(char *, const char *); 76 char *put8(char *, const char *); 77 int etob(char *, const char *); 78 void rip(char *); 79 int skeychallenge(struct skey *, const char *, char *, size_t); 80 int skeylookup(struct skey *, const char *); 81 int skeyverify(struct skey *, char *); 82 void sevenbit(char *); 83 void backspace(char *); 84 const char *skipspace(const char *); 85 char *readpass(char *, int); 86 char *readskey(char *, int); 87 int skey_authenticate(const char *); 88 int skey_passcheck(const char *, char *); 89 const char *skey_keyinfo(const char *); 90 int skey_haskey(const char *); 91 int getskeyprompt(struct skey *, char *, char *); 92 int atob8(char *, const char *); 93 int btoa8(char *, const char *); 94 int htoi(int); 95 const char *skey_get_algorithm(void); 96 const char *skey_set_algorithm(const char *); 97 int skeygetnext(struct skey *); 98 int skeyzero(struct skey *, char *); 99