summaryrefslogtreecommitdiffstats
path: root/tinyHTTP/include/tinyhttp/auth
diff options
context:
space:
mode:
authorbossiel <bossiel@yahoo.fr>2011-08-10 22:59:15 +0000
committerbossiel <bossiel@yahoo.fr>2011-08-10 22:59:15 +0000
commit1ebf5a5fcda0c9154e22ed02404fd46525a7fd9f (patch)
tree4b6214a7142ab1035cb0e47444e88af38e712421 /tinyHTTP/include/tinyhttp/auth
downloaddoubango-1.0.zip
doubango-1.0.tar.gz
Move deprecated v1.0 from trunk to branches1.0
Diffstat (limited to 'tinyHTTP/include/tinyhttp/auth')
-rw-r--r--tinyHTTP/include/tinyhttp/auth/thttp_auth.h62
-rw-r--r--tinyHTTP/include/tinyhttp/auth/thttp_challenge.h76
2 files changed, 138 insertions, 0 deletions
diff --git a/tinyHTTP/include/tinyhttp/auth/thttp_auth.h b/tinyHTTP/include/tinyhttp/auth/thttp_auth.h
new file mode 100644
index 0000000..8e5119a
--- /dev/null
+++ b/tinyHTTP/include/tinyhttp/auth/thttp_auth.h
@@ -0,0 +1,62 @@
+/*
+* Copyright (C) 2009-2010 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* DOUBANGO is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with DOUBANGO.
+*
+*/
+/**@file thttp_auth.h
+ * @brief HTTP basic/digest authetication (RFC 2617) implementations.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango.org>
+ *
+ * @date Created: Sat Nov 8 16:54:58 2009 mdiop
+ */
+#ifndef TINYHTTP_THTTP_AUTH_H
+#define TINYHTTP_THTTP_AUTH_H
+
+#include "tinyhttp_config.h"
+
+#include "tsk_md5.h"
+#include "tsk_buffer.h"
+
+THTTP_BEGIN_DECLS
+
+typedef char nonce_count_t[9];
+#define THTTP_NCOUNT_2_STRING(nc_int32, nc_string) \
+ { \
+ tsk_size_t i = 7; \
+ do{ \
+ nc_string[7-i]= "0123456789abcdef"[(nc_int32 >> i*4) & 0xF]; \
+ } \
+ while(i--); \
+ nc_string[8] = '\0'; \
+ }
+
+TINYHTTP_API tsk_size_t thttp_auth_basic_response(const char* userid, const char* password, char** response);
+
+TINYHTTP_API int thttp_auth_digest_HA1(const char* username, const char* realm, const char* password, tsk_md5string_t* ha1);
+TINYHTTP_API int thttp_auth_digest_HA1sess(const char* username, const char* realm, const char* password, const char* nonce, const char* cnonce, tsk_md5string_t* ha1sess);
+
+TINYHTTP_API int thttp_auth_digest_HA2(const char* method, const char* url, const tsk_buffer_t* entity_body, const char* qop, tsk_md5string_t* ha2);
+
+TINYHTTP_API int thttp_auth_digest_response(const tsk_md5string_t *ha1, const char* nonce, const nonce_count_t noncecount, const char* cnonce,
+ const char* qop, const tsk_md5string_t* ha2, tsk_md5string_t* response);
+
+THTTP_END_DECLS
+
+#endif /* TINYHTTP_THTTP_H */
diff --git a/tinyHTTP/include/tinyhttp/auth/thttp_challenge.h b/tinyHTTP/include/tinyhttp/auth/thttp_challenge.h
new file mode 100644
index 0000000..409780e
--- /dev/null
+++ b/tinyHTTP/include/tinyhttp/auth/thttp_challenge.h
@@ -0,0 +1,76 @@
+/*
+* Copyright (C) 2009-2010 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* DOUBANGO is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with DOUBANGO.
+*
+*/
+
+/**@file thttp_challenge.h
+ * @brief HTTP authentication challenge.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango.org>
+ *
+ * @date Created: Sat Nov 8 16:54:58 2009 mdiop
+ */
+#ifndef TINYHTTP_AUTHENTICATION_CHALLENGE_H
+#define TINYHTTP_AUTHENTICATION_CHALLENGE_H
+
+#include "tinyhttp_config.h"
+
+#include "tinyhttp/thttp_message.h"
+#include "tinyhttp/headers/thttp_header.h"
+
+#include "tinyhttp/auth/thttp_auth.h"
+
+#include "tsk_object.h"
+#include "tsk_list.h"
+#include "tsk_md5.h"
+
+THTTP_BEGIN_DECLS
+
+typedef struct thttp_challenge_s
+{
+ TSK_DECLARE_OBJECT;
+
+ tsk_bool_t isproxy;
+
+ char* scheme;
+ char* realm;
+ char* nonce;
+ char* opaque;
+ char* algorithm;
+ const char* qop;
+
+ tsk_md5string_t cnonce;
+ unsigned nc;
+}
+thttp_challenge_t;
+
+typedef tsk_list_t thttp_challenges_L_t;
+
+int thttp_challenge_update(thttp_challenge_t *self, const char* scheme, const char* realm, const char* nonce, const char* opaque, const char* algorithm, const char* qop);
+thttp_header_t *thttp_challenge_create_header_authorization(thttp_challenge_t *self, const char* username, const char* password, const thttp_request_t *request);
+
+thttp_challenge_t* thttp_challenge_create(tsk_bool_t isproxy,const char* scheme, const char* realm, const char* nonce, const char* opaque, const char* algorithm, const char* qop);
+
+TINYHTTP_GEXTERN const tsk_object_def_t *thttp_challenge_def_t;
+
+THTTP_END_DECLS
+
+#endif /* TINYHTTP_AUTHENTICATION_CHALLENGE_H */
+
OpenPOWER on IntegriCloud