#include "auth-request.h"
-enum qop_option {
- QOP_AUTH = 0x01, /* authenticate */
- QOP_AUTH_INT = 0x02, /* + integrity protection, not supported yet */
- QOP_AUTH_CONF = 0x04, /* + encryption, not supported yet */
-
- QOP_COUNT = 3
-};
-
-struct digest_auth_request {
- struct auth_request auth_request;
-
- pool_t pool;
-
- /* requested: */
- char *nonce;
- enum qop_option qop;
-
- /* received: */
- char *username;
- char *cnonce;
- char *nonce_count;
- char *qop_value;
- char *digest_uri; /* may be NULL */
- char *authzid; /* may be NULL, authorization ID */
- unsigned char response[32];
- unsigned long maxbuf;
- bool nonce_found:1;
-
- /* final reply: */
- char *rspauth;
-};
+void mech_digest_test_set_nonce(struct auth_request *auth_request,
+ const char *nonce);
#endif
/* Linear whitespace */
#define IS_LWS(c) ((c) == ' ' || (c) == '\t')
+enum qop_option {
+ QOP_AUTH = 0x01, /* authenticate */
+ QOP_AUTH_INT = 0x02, /* + integrity protection, not supported yet */
+ QOP_AUTH_CONF = 0x04, /* + encryption, not supported yet */
+
+ QOP_COUNT = 3
+};
+
+struct digest_auth_request {
+ struct auth_request auth_request;
+
+ pool_t pool;
+
+ /* requested: */
+ char *nonce;
+ enum qop_option qop;
+
+ /* received: */
+ char *username;
+ char *cnonce;
+ char *nonce_count;
+ char *qop_value;
+ char *digest_uri; /* may be NULL */
+ char *authzid; /* may be NULL, authorization ID */
+ unsigned char response[32];
+ unsigned long maxbuf;
+ bool nonce_found:1;
+
+ /* final reply: */
+ char *rspauth;
+};
+
static const char *qop_names[] = { "auth", "auth-int", "auth-conf" };
static_assert_array_size(qop_names, QOP_COUNT);
mech_digest_md5_auth_continue,
mech_generic_auth_free
};
+
+void mech_digest_test_set_nonce(struct auth_request *auth_request,
+ const char *nonce)
+{
+ struct digest_auth_request *request =
+ container_of(auth_request, struct digest_auth_request,
+ auth_request);
+
+ i_assert(auth_request->mech == &mech_digest_md5);
+ request->nonce = p_strdup(request->pool, nonce);
+}
str_truncate(out, 0);
str_append(out, "testuser b913a602c7eda7a495b4e6e7334d3890");
} else if (request->mech == &mech_digest_md5) {
- struct digest_auth_request *digest_request =
- (struct digest_auth_request *) request;
- digest_request->nonce = "OA6MG9tEQGm2hh";
+ mech_digest_test_set_nonce(request, "OA6MG9tEQGm2hh");
}
auth_request_continue(request, out->data, out->used);
}