00001 /************************************************** 00002 CCS Authentication utility routines 00003 00004 Orion Sky Lawlor, olawlor@acm.org, 7/23/2001 00005 */ 00006 #ifndef __CCS_AUTH_H 00007 #define __CCS_AUTH_H 00008 00009 #ifdef __cplusplus 00010 extern "C" { 00011 #endif 00012 00013 /*A secret key, used to authenticate a client or server. 00014 This could be human-readable text, a random one-time pad, 00015 some shared common knowledge, or any combination. 00016 */ 00017 typedef struct { 00018 unsigned char data[16]; 00019 } CcsSec_secretKey; 00020 int CCS_AUTH_makeSecretKey(const char *str,CcsSec_secretKey *key); 00021 00022 00023 /*The output of a SHA-1 hash algorithm*/ 00024 typedef struct { 00025 unsigned char data[20]; 00026 } SHA1_hash_t; 00027 00028 void CCS_AUTH_hash(const CcsSec_secretKey *key,unsigned int salt, 00029 const CcsMessageHeader *hdrOrNull,SHA1_hash_t *out); 00030 int CCS_AUTH_differ(const CcsSec_secretKey *key,unsigned int salt, 00031 const CcsMessageHeader *hdrOrNull,SHA1_hash_t *given); 00032 00033 00034 /*Strong (but rather slow) random stream*/ 00035 typedef struct { 00036 unsigned char state[64]; /*Random number stream state*/ 00037 } CCS_RAND_state; 00038 00039 void CCS_RAND_new(CCS_RAND_state *s); 00040 unsigned int CCS_RAND_next(CCS_RAND_state *s); 00041 00042 #ifdef __cplusplus 00043 } 00044 #endif 00045 00046 #endif /* def(thisHeader) */ 00047