summaryrefslogtreecommitdiffstats
path: root/src/include
diff options
context:
space:
mode:
authorMichael Brown2006-11-21 14:26:59 +0100
committerMichael Brown2006-11-21 14:26:59 +0100
commitc5428303e4d71856daf61fc27ae19aeca09cc834 (patch)
treee69327bec2619d9a608967071e68eaaba5ee6891 /src/include
parentMade it temporarily possible to call MD5 routines directly from external (diff)
downloadipxe-c5428303e4d71856daf61fc27ae19aeca09cc834.tar.gz
ipxe-c5428303e4d71856daf61fc27ae19aeca09cc834.tar.xz
ipxe-c5428303e4d71856daf61fc27ae19aeca09cc834.zip
Added generic CHAP layer, independent of iSCSI
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gpxe/chap.h51
-rw-r--r--src/include/gpxe/md5.h21
2 files changed, 53 insertions, 19 deletions
diff --git a/src/include/gpxe/chap.h b/src/include/gpxe/chap.h
new file mode 100644
index 000000000..c85d92f82
--- /dev/null
+++ b/src/include/gpxe/chap.h
@@ -0,0 +1,51 @@
+#ifndef _GPXE_CHAP_H
+#define _GPXE_CHAP_H
+
+/** @file
+ *
+ * CHAP protocol
+ *
+ */
+
+#include <stdint.h>
+#include <gpxe/md5.h>
+
+struct digest_algorithm;
+
+/** A CHAP challenge/response */
+struct chap_challenge {
+ /** Digest algorithm used for the response */
+ struct digest_algorithm *digest;
+ /** Context used by the digest algorithm */
+ uint8_t *digest_context;
+ /** CHAP response */
+ uint8_t *response;
+ /** Length of CHAP response */
+ size_t response_len;
+};
+
+extern int chap_init ( struct chap_challenge *chap,
+ struct digest_algorithm *digest );
+extern void chap_update ( struct chap_challenge *chap, const void *data,
+ size_t len );
+extern void chap_respond ( struct chap_challenge *chap );
+extern void chap_finish ( struct chap_challenge *chap );
+
+/**
+ * Add identifier data to the CHAP challenge
+ *
+ * @v chap CHAP challenge/response
+ * @v identifier CHAP identifier
+ *
+ * The CHAP identifier is the first byte of the CHAP challenge. This
+ * function is a notational convenience for calling chap_update() for
+ * the identifier byte.
+ */
+static inline void chap_set_identifier ( struct chap_challenge *chap,
+ unsigned int identifier ) {
+ uint8_t ident_byte = identifier;
+
+ chap_update ( chap, &ident_byte, sizeof ( ident_byte ) );
+}
+
+#endif /* _GPXE_CHAP_H */
diff --git a/src/include/gpxe/md5.h b/src/include/gpxe/md5.h
index 5ae370fee..56120ca13 100644
--- a/src/include/gpxe/md5.h
+++ b/src/include/gpxe/md5.h
@@ -1,25 +1,8 @@
#ifndef _GPXE_MD5_H
#define _GPXE_MD5_H
-#include <stdint.h>
+struct digest_algorithm;
-#define MD5_DIGEST_SIZE 16
-#define MD5_BLOCK_WORDS 16
-#define MD5_HASH_WORDS 4
-
-struct md5_context {
- u32 hash[MD5_HASH_WORDS];
- u32 block[MD5_BLOCK_WORDS];
- u64 byte_count;
-};
-
-struct md5_hash {
- u8 hash[MD5_DIGEST_SIZE];
-};
-
-extern void md5_init ( struct md5_context *context );
-extern void md5_update ( struct md5_context *context, const void *data,
- size_t len );
-extern void md5_finish ( struct md5_context *context, struct md5_hash *hash );
+extern struct digest_algorithm md5_algorithm;
#endif /* _GPXE_MD5_H */