summaryrefslogtreecommitdiff
path: root/daemon/digest.h
diff options
context:
space:
mode:
Diffstat (limited to 'daemon/digest.h')
-rw-r--r--daemon/digest.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/daemon/digest.h b/daemon/digest.h
new file mode 100644
index 0000000..6bd7acc
--- /dev/null
+++ b/daemon/digest.h
@@ -0,0 +1,57 @@
+
+#ifndef __DIGEST_H__
+#define __DIGEST_H__
+
+#include "md5.h"
+
+#define DIGEST_NONCE_LEN sizeof(time_t) + sizeof(unsigned int) + MD5_LEN
+#define DIGEST_SECRET_LEN 16
+
+/* Parsed Digest response from the client */
+typedef struct digest_header
+{
+ const char* scheme;
+ const char* realm;
+ const char* username;
+ const char* nonce;
+ const char* uri;
+ const char* method;
+ const char* digest;
+ const char* algorithm;
+ const char* cnonce;
+ const char* opaque;
+ const char* qop;
+ const char* nc;
+}
+digest_header_t;
+
+/* Kept by the server for validating the client */
+typedef struct digest_record
+{
+ unsigned char nonce[DIGEST_NONCE_LEN];
+ unsigned char userhash[MD5_LEN];
+ unsigned char ha1[MD5_LEN];
+ unsigned int nc;
+}
+digest_record_t;
+
+digest_record_t* digest_makerec(unsigned char* nonce, const char* user);
+
+int ha_digestparse(char* header, ha_buffer_t* buf, digest_header_t* rec,
+ unsigned char* nonce);
+
+int ha_digestnonce(time_t* tm, unsigned char* nonce);
+
+int ha_digestcheck(const char* realm, const char* method, const char* uri,
+ ha_buffer_t* buf, digest_header_t* header, digest_record_t* rec);
+
+const char* digest_respond(ha_buffer_t* buf, digest_header_t* dg,
+ digest_record_t* rec, unsigned char* next);
+
+const char* digest_challenge(ha_buffer_t* buf, unsigned char* nonce,
+ const char* realm, const char* domains, int stale);
+
+void digest_makeha1(unsigned char* digest, const char* user,
+ const char* realm, const char* password);
+
+#endif /* __DIGEST_H__ */