static void auth_client_finish_handshake(struct auth_client_connection *conn)
{
- const char *mechanisms;
+ const char *mechanisms, *mechanisms_cbind = "";
string_t *str;
if (conn->token_auth) {
mech_dovecot_token.mech_name, "\tprivate\n", NULL);
} else {
mechanisms = str_c(conn->auth->reg->handshake);
+ if (conn->conn.minor_version >= 3) {
+ mechanisms_cbind =
+ str_c(conn->auth->reg->handshake_cbind);
+ }
}
str = t_str_new(128);
- str_printfa(str, "%sSPID\t%s\nCUID\t%u\nCOOKIE\t",
- mechanisms, my_pid, conn->connect_uid);
+ str_printfa(str, "%s%sSPID\t%s\nCUID\t%u\nCOOKIE\t",
+ mechanisms, mechanisms_cbind, my_pid, conn->connect_uid);
binary_to_hex_append(str, conn->cookie, sizeof(conn->cookie));
str_append(str, "\nDONE\n");
const struct mech_module *mech)
{
struct mech_module_list *list;
+ string_t *handshake;
list = p_new(reg->pool, struct mech_module_list, 1);
list->module = *mech;
- str_printfa(reg->handshake, "MECH\t%s", mech->mech_name);
+ if ((mech->flags & MECH_SEC_CHANNEL_BINDING) != 0)
+ handshake = reg->handshake_cbind;
+ else
+ handshake = reg->handshake;
+
+ str_printfa(handshake, "MECH\t%s", mech->mech_name);
if ((mech->flags & MECH_SEC_PRIVATE) != 0)
- str_append(reg->handshake, "\tprivate");
+ str_append(handshake, "\tprivate");
if ((mech->flags & MECH_SEC_ANONYMOUS) != 0)
- str_append(reg->handshake, "\tanonymous");
+ str_append(handshake, "\tanonymous");
if ((mech->flags & MECH_SEC_PLAINTEXT) != 0)
- str_append(reg->handshake, "\tplaintext");
+ str_append(handshake, "\tplaintext");
if ((mech->flags & MECH_SEC_DICTIONARY) != 0)
- str_append(reg->handshake, "\tdictionary");
+ str_append(handshake, "\tdictionary");
if ((mech->flags & MECH_SEC_ACTIVE) != 0)
- str_append(reg->handshake, "\tactive");
+ str_append(handshake, "\tactive");
if ((mech->flags & MECH_SEC_FORWARD_SECRECY) != 0)
- str_append(reg->handshake, "\tforward-secrecy");
+ str_append(handshake, "\tforward-secrecy");
if ((mech->flags & MECH_SEC_MUTUAL_AUTH) != 0)
- str_append(reg->handshake, "\tmutual-auth");
+ str_append(handshake, "\tmutual-auth");
if ((mech->flags & MECH_SEC_CHANNEL_BINDING) != 0)
- str_append(reg->handshake, "\tchannel-binding");
- str_append_c(reg->handshake, '\n');
+ str_append(handshake, "\tchannel-binding");
+ str_append_c(handshake, '\n');
list->next = reg->modules;
reg->modules = list;
reg->pool = pool;
reg->set = set;
reg->handshake = str_new(pool, 512);
+ reg->handshake_cbind = str_new(pool, 256);
if (!array_is_created(&set->mechanisms) ||
array_is_empty(&set->mechanisms))