Lines Matching defs:utils

91 static int uef_init(const sasl_utils_t *utils);
234 /* copy of utils from the params structures */
235 const sasl_utils_t *utils;
329 DigestCalcResponse(const sasl_utils_t * utils,
349 utils->MD5Init(&Md5Ctx);
352 utils->MD5Update(&Md5Ctx, pszMethod, strlen((char *) pszMethod));
354 utils->MD5Update(&Md5Ctx, (unsigned char *) COLON, 1);
356 /* utils->MD5Update(&Md5Ctx, (unsigned char *) "AUTHENTICATE:", 13); */
357 utils->MD5Update(&Md5Ctx, pszDigestUri, strlen((char *) pszDigestUri));
360 utils->MD5Update(&Md5Ctx, COLON, 1);
361 utils->MD5Update(&Md5Ctx, HEntity, HASHHEXLEN);
363 utils->MD5Final(HA2, &Md5Ctx);
367 utils->MD5Init(&Md5Ctx);
368 utils->MD5Update(&Md5Ctx, HA1, HASHHEXLEN);
369 utils->MD5Update(&Md5Ctx, COLON, 1);
370 utils->MD5Update(&Md5Ctx, pszNonce, strlen((char *) pszNonce));
371 utils->MD5Update(&Md5Ctx, COLON, 1);
375 utils->MD5Update(&Md5Ctx, (unsigned char *)ncvalue, strlen(ncvalue));
377 utils->MD5Update(&Md5Ctx, ncvalue, strlen(ncvalue));
379 utils->MD5Update(&Md5Ctx, COLON, 1);
380 utils->MD5Update(&Md5Ctx, pszCNonce, strlen((char *) pszCNonce));
381 utils->MD5Update(&Md5Ctx, COLON, 1);
382 utils->MD5Update(&Md5Ctx, pszQop, strlen((char *) pszQop));
383 utils->MD5Update(&Md5Ctx, COLON, 1);
385 utils->MD5Update(&Md5Ctx, HA2Hex, HASHHEXLEN);
386 utils->MD5Final(RespHash, &Md5Ctx);
412 void MD5_UTF8_8859_1(const sasl_utils_t * utils,
425 utils->MD5Update(ctx, base, len);
432 utils->MD5Update(ctx, base, scan - base);
436 utils->MD5Update(ctx, &cbuf, 1);
442 static void DigestCalcSecret(const sasl_utils_t * utils,
457 utils->MD5Init(&Md5Ctx);
461 MD5_UTF8_8859_1(utils, &Md5Ctx, In_8859_1,
464 utils->MD5Update(&Md5Ctx, COLON, 1);
468 utils->MD5Update(&Md5Ctx, pszRealm, strlen((char *) pszRealm));
471 utils->MD5Update(&Md5Ctx, COLON, 1);
475 MD5_UTF8_8859_1(utils, &Md5Ctx, In_8859_1,
478 utils->MD5Final(HA1, &Md5Ctx);
481 static unsigned char *create_nonce(const sasl_utils_t * utils)
486 char *ret = (char *) utils->malloc(NONCE_SIZE);
500 utils->rand(utils->rpool, (char *) ret, NONCE_SIZE);
503 utils->rand(utils->rpool, (char *) ret, NONCE_SIZE);
509 base64buf = (unsigned char *) utils->malloc(base64len + 1);
512 utils->log(utils->conn, SASL_LOG_ERR,
515 utils->seterror(utils->conn, 0, "Unable to allocate final buffer");
523 if (utils->encode64(ret, NONCE_SIZE,
525 utils->free(ret);
528 utils->free(ret);
533 static int add_to_challenge(const sasl_utils_t *utils,
543 ret = _plug_buf_alloc(utils, str, buflen,
833 c = (des_context_t *) text->utils->malloc(2 * sizeof(des_context_t));
960 c = (des_context_t *) text->utils->malloc(2 * sizeof(des_context_t));
987 if (text->cipher_enc_context) text->utils->free(text->cipher_enc_context);
1100 if(text->cipher_enc_context) text->utils->free(text->cipher_enc_context);
1101 if(text->cipher_dec_context) text->utils->free(text->cipher_dec_context);
1119 (cipher_context_t *) text->utils->malloc(sizeof(rc4_context_t));
1123 (cipher_context_t *) text->utils->malloc(sizeof(rc4_context_t));
1126 text->utils->free(text->cipher_enc_context);
1296 enc_context = text->utils->malloc(sizeof (uef_context_t));
1303 text->utils->free(enc_context);
1305 text->utils->log(text->utils->conn, SASL_LOG_DEBUG,
1314 text->utils->free(enc_context);
1317 text->utils->log(text->utils->conn, SASL_LOG_DEBUG,
1329 text->utils->log(text->utils->conn, SASL_LOG_DEBUG,
1335 dec_context = text->utils->malloc(sizeof(uef_context_t));
1343 text->utils->log(text->utils->conn, SASL_LOG_DEBUG,
1346 text->utils->free(dec_context);
1366 text->utils->log(text->utils->conn, SASL_LOG_DEBUG,
1370 text->utils->free(dec_context);
1379 text->utils->log(text->utils->conn, SASL_LOG_DEBUG,
1425 text->utils->log(text->utils->conn, SASL_LOG_DEBUG,
1432 text->utils->log(text->utils->conn, SASL_LOG_DEBUG,
1439 text->utils->log(text->utils->conn, SASL_LOG_DEBUG,
1443 text->utils->free(enc_context);
1449 text->utils->log(text->utils->conn, SASL_LOG_DEBUG,
1456 text->utils->log(text->utils->conn, SASL_LOG_DEBUG,
1464 text->utils->log(text->utils->conn, SASL_LOG_DEBUG,
1468 text->utils->free(dec_context);
1492 text->utils->log(text->utils->conn, SASL_LOG_DEBUG,
1504 text->utils->log(text->utils->conn, SASL_LOG_DEBUG,
1532 text->utils->log(text->utils->conn, SASL_LOG_DEBUG,
1543 text->utils->log(text->utils->conn, SASL_LOG_DEBUG,
1573 text->utils->log(text->utils->conn, SASL_LOG_DEBUG,
1580 text->utils->log(text->utils->conn, SASL_LOG_DEBUG,
1637 text->utils->log(text->utils->conn, SASL_LOG_DEBUG,
1668 const sasl_utils_t *utils,
1674 utils->MD5Init(&Md5Ctx);
1675 utils->MD5Update(&Md5Ctx, key, keylen);
1677 utils->MD5Update(&Md5Ctx, (const unsigned char *) SEALING_SERVER_CLIENT,
1680 utils->MD5Update(&Md5Ctx, (const unsigned char *) SEALING_CLIENT_SERVER,
1683 utils->MD5Final((unsigned char *) enckey, &Md5Ctx);
1685 utils->MD5Init(&Md5Ctx);
1686 utils->MD5Update(&Md5Ctx, key, keylen);
1688 utils->MD5Update(&Md5Ctx, (const unsigned char *)SEALING_SERVER_CLIENT,
1691 utils->MD5Update(&Md5Ctx, (const unsigned char *)SEALING_CLIENT_SERVER,
1694 utils->MD5Final((unsigned char *) deckey, &Md5Ctx);
1698 utils->MD5Init(&Md5Ctx);
1699 utils->MD5Update(&Md5Ctx, text->HA1, HASHLEN);
1701 utils->MD5Update(&Md5Ctx, (const unsigned char *)SIGNING_SERVER_CLIENT,
1704 utils->MD5Update(&Md5Ctx, (const unsigned char *)SIGNING_CLIENT_SERVER,
1707 utils->MD5Final(text->Ki_send, &Md5Ctx);
1710 utils->MD5Init(&Md5Ctx);
1711 utils->MD5Update(&Md5Ctx, text->HA1, HASHLEN);
1713 utils->MD5Update(&Md5Ctx, (const unsigned char *)SIGNING_SERVER_CLIENT,
1716 utils->MD5Update(&Md5Ctx, (const unsigned char *)SIGNING_CLIENT_SERVER,
1719 utils->MD5Final(text->Ki_receive, &Md5Ctx);
1745 PARAMERROR(text->utils);
1750 ret = _plug_iovec_to_buf(text->utils, invec, numiov, &text->enc_in_buf);
1761 ret = _plug_buf_alloc(text->utils, &(text->encode_buf),
1781 text->utils->hmac_md5((const unsigned char *) text->encode_buf,
1858 text->buffer=text->utils->malloc(text->size+5);
1860 text->buffer=text->utils->realloc(text->buffer,
1898 result = _plug_buf_alloc(text->utils, &text->decode_once_buf,
1927 text->utils->seterror(text->utils->conn, 0,
1930 text->utils->seterror(text->utils->conn, 0, "Wrong Version");
1938 result = _plug_buf_alloc(text->utils, &text->decode_tmp_buf,
1947 text->utils->hmac_md5((const unsigned char *) text->decode_tmp_buf,
1956 text->utils->log(text->utils->conn, SASL_LOG_ERR,
1960 text->utils->seterror(text->utils->conn, 0,
1973 text->utils->log(text->utils->conn, SASL_LOG_ERR,
1976 text->utils->seterror(text->utils->conn, 0,
1997 ret = _plug_decode(text->utils, context, input, inputlen,
2021 PARAMERROR( text->utils );
2026 ret = _plug_iovec_to_buf(text->utils, invec, numiov,
2040 ret = _plug_buf_alloc(text->utils, &(text->encode_buf),
2052 text->utils->hmac_md5((unsigned char *)text->encode_buf,
2056 text->utils->hmac_md5(text->encode_buf, inblob->curlen + 4,
2098 ret = _plug_buf_alloc(text->utils, &(text->MAC_buf),
2109 text->utils->hmac_md5((unsigned char *)text->MAC_buf, inputlen + 4,
2113 text->utils->hmac_md5(text->MAC_buf, inputlen + 4,
2144 text->utils->log(text->utils->conn, SASL_LOG_ERR,
2148 text->utils->seterror(text->utils->conn, 0, "MAC doesn't match");
2156 result = _plug_buf_alloc(text->utils, &text->decode_once_buf,
2209 text->buffer=text->utils->malloc(text->size+5);
2211 text->buffer=text->utils->realloc(text->buffer,text->size+5);
2258 ret = _plug_decode(text->utils, context, input, inputlen,
2268 digestmd5_common_mech_dispose(void *conn_context, const sasl_utils_t *utils)
2272 if (!text || !utils) return;
2274 if (text->authid) utils->free(text->authid);
2275 if (text->realm) utils->free(text->realm);
2276 if (text->nonce) utils->free(text->nonce);
2277 if (text->cnonce) utils->free(text->cnonce);
2282 if (text->response_value) utils->free(text->response_value);
2284 if (text->buffer) utils->free(text->buffer);
2285 if (text->encode_buf) utils->free(text->encode_buf);
2286 if (text->decode_buf) utils->free(text->decode_buf);
2287 if (text->decode_once_buf) utils->free(text->decode_once_buf);
2288 if (text->decode_tmp_buf) utils->free(text->decode_tmp_buf);
2289 if (text->out_buf) utils->free(text->out_buf);
2290 if (text->MAC_buf) utils->free(text->MAC_buf);
2293 if (text->enc_in_buf->data) utils->free(text->enc_in_buf->data);
2294 utils->free(text->enc_in_buf);
2297 utils->free(conn_context);
2302 const sasl_utils_t *utils)
2306 if (reauth->authid) utils->free(reauth->authid);
2307 if (reauth->realm) utils->free(reauth->realm);
2308 if (reauth->nonce) utils->free(reauth->nonce);
2309 if (reauth->cnonce) utils->free(reauth->cnonce);
2312 if (reauth->u.c.serverFQDN) utils->free(reauth->u.c.serverFQDN);
2319 digestmd5_common_mech_free(void *glob_context, const sasl_utils_t *utils)
2327 clear_reauth_entry(&reauth_cache->e[n], reauth_cache->i_am, utils);
2328 if (reauth_cache->e) utils->free(reauth_cache->e);
2330 if (reauth_cache->mutex) utils->mutex_free(reauth_cache->mutex);
2332 utils->free(reauth_cache);
2347 const sasl_utils_t * utils,
2357 utils->MD5Init(&Md5Ctx);
2358 utils->MD5Update(&Md5Ctx, HA1, HASHLEN);
2359 utils->MD5Update(&Md5Ctx, COLON, 1);
2360 utils->MD5Update(&Md5Ctx, pszNonce, strlen((char *) pszNonce));
2361 utils->MD5Update(&Md5Ctx, COLON, 1);
2362 utils->MD5Update(&Md5Ctx, pszCNonce, strlen((char *) pszCNonce));
2364 utils->MD5Update(&Md5Ctx, COLON, 1);
2365 utils->MD5Update(&Md5Ctx, authorization_id, strlen((char *) authorization_id));
2367 utils->MD5Final(HA1, &Md5Ctx);
2377 const sasl_utils_t * utils,
2396 utils,
2403 DigestCalcResponse(utils,
2416 result = utils->malloc(HASHHEXLEN + 1);
2427 DigestCalcResponse(utils,
2440 *response_value = utils->malloc(HASHHEXLEN + 1);
2460 params->utils->log(params->utils->conn, SASL_LOG_ERR,
2463 params->utils->seterror(params->utils->conn, 0,
2472 params->utils->log(params->utils->conn, SASL_LOG_ERR,
2475 params->utils->seterror(params->utils->conn, 0,
2544 text = sparams->utils->malloc(sizeof(server_context_t));
2577 sparams->utils->log(sparams->utils->conn, SASL_LOG_DEBUG,
2613 sparams->utils->log(sparams->utils->conn, SASL_LOG_ERR,
2638 nonce = create_nonce(sparams->utils);
2642 sparams->utils->log(sparams->utils->conn, SASL_LOG_ERR,
2645 SETERROR(sparams->utils, "internal erorr: failed creating a nonce");
2655 result = _plug_buf_alloc(sparams->utils, &(text->out_buf),
2659 sparams->utils->free(nonce);
2670 if (realm && add_to_challenge(sparams->utils,
2675 sparams->utils->log(sparams->utils->conn, SASL_LOG_ERR,
2677 sparams->utils->free(nonce);
2679 SETERROR(sparams->utils, "internal error: add_to_challenge failed");
2692 if (add_to_challenge(sparams->utils,
2697 sparams->utils->log(sparams->utils->conn, SASL_LOG_ERR,
2699 sparams->utils->free(nonce);
2701 SETERROR(sparams->utils, "internal error: add_to_challenge 3 failed");
2712 if (add_to_challenge(sparams->utils,
2717 sparams->utils->log(sparams->utils->conn, SASL_LOG_ERR,
2719 sparams->utils->free(nonce);
2721 SETERROR(sparams->utils,
2730 add_to_challenge(sparams->utils,
2734 sparams->utils->free(nonce);
2735 sparams->utils->log(sparams->utils->conn, SASL_LOG_ERR,
2739 SETERROR(sparams->utils, "internal error: add_to_challenge failed");
2754 if (add_to_challenge(sparams->utils,
2759 sparams->utils->log(sparams->utils->conn, SASL_LOG_ERR,
2762 SETERROR(sparams->utils,
2770 if (add_to_challenge(sparams->utils,
2775 sparams->utils->log(sparams->utils->conn, SASL_LOG_ERR,
2777 sparams->utils->free(nonce);
2779 SETERROR(sparams->utils, "internal error: add_to_challenge 6 failed");
2796 if (add_to_challenge(sparams->utils,
2801 sparams->utils->log(sparams->utils->conn, SASL_LOG_ERR,
2803 sparams->utils->free(nonce);
2805 SETERROR(sparams->utils, "internal error: add_to_challenge 7 failed");
2815 sparams->utils->free(nonce);
2816 sparams->utils->log(sparams->utils->conn, SASL_LOG_ERR,
2819 SETERROR(sparams->utils,
2826 _plug_strdup(sparams->utils, realm, &text->realm, NULL);
2884 sparams->utils->log(sparams->utils->conn, SASL_LOG_DEBUG,
2887 in = sparams->utils->malloc(clientinlen + 1);
2915 _plug_strdup(sparams->utils, value, &username, NULL);
2917 _plug_strdup(sparams->utils, value, &authorization_id, NULL);
2919 _plug_strdup(sparams->utils, value, (char **) &cnonce, NULL);
2923 sparams->utils->log(sparams->utils->conn, SASL_LOG_ERR,
2926 SETERROR(sparams->utils,
2935 sparams->utils->log(sparams->utils->conn, SASL_LOG_ERR,
2938 SETERROR(sparams->utils,
2944 _plug_strdup(sparams->utils, value, &realm, NULL);
2946 _plug_strdup(sparams->utils, value, (char **) &nonce, NULL);
2948 _plug_strdup(sparams->utils, value, &qop, NULL);
2956 _plug_strdup(sparams->utils, value, &digesturi, NULL);
2966 sparams->utils->log(sparams->utils->conn, SASL_LOG_ERR,
2969 SETERROR(sparams->utils,
2978 _plug_strdup(sparams->utils, value, &response, NULL);
2980 _plug_strdup(sparams->utils, value, &cipher, NULL);
2986 sparams->utils->log(sparams->utils->conn, SASL_LOG_ERR,
2989 SETERROR(sparams->utils,
2996 sparams->utils->log(sparams->utils->conn, SASL_LOG_ERR,
2999 SETERROR(sparams->utils, "invalid maxbuf parameter");
3006 sparams->utils->log(sparams->utils->conn, SASL_LOG_ERR,
3009 SETERROR(sparams->utils,
3018 sparams->utils->log(sparams->utils->conn, SASL_LOG_ERR,
3021 SETERROR(sparams->utils, "client doesn't support UTF-8");
3026 _plug_strdup(sparams->utils, value, &charset, NULL);
3028 sparams->utils->log(sparams->utils->conn, SASL_LOG_DEBUG,
3055 sparams->utils->log(sparams->utils->conn, SASL_LOG_ERR,
3058 SETERROR(sparams->utils, "required parameters missing");
3068 if (sparams->utils->mutex_lock(text->reauth->mutex) == SASL_OK) { /* LOCK */
3072 _plug_strdup(sparams->utils, text->reauth->e[val].realm,
3075 _plug_strdup(sparams->utils, (char *)text->reauth->e[val].nonce,
3078 _plug_strdup(sparams->utils, text->reauth->e[val].nonce,
3083 _plug_strdup(sparams->utils, (char *)text->reauth->e[val].cnonce,
3086 _plug_strdup(sparams->utils, text->reauth->e[val].cnonce,
3091 sparams->utils->mutex_unlock(text->reauth->mutex); /* UNLOCK */
3107 sparams->utils->log(sparams->utils->conn, SASL_LOG_ERR,
3111 SETERROR(sparams->utils,
3119 sparams->utils->log(sparams->utils->conn, SASL_LOG_ERR,
3123 SETERROR(sparams->utils,
3131 sparams->utils->log(sparams->utils->conn, SASL_LOG_ERR,
3134 SETERROR(sparams->utils,
3142 sparams->utils->log(sparams->utils->conn, SASL_LOG_ERR,
3146 SETERROR(sparams->utils,
3153 result = sparams->utils->prop_request(sparams->propctx, password_request);
3156 sparams->utils->log(sparams->utils->conn, SASL_LOG_ERR,
3159 SETERROR(sparams->utils, "unable to resquest user password");
3166 result = sparams->canon_user(sparams->utils->conn,
3170 sparams->utils->log(sparams->utils->conn, SASL_LOG_ERR,
3173 SETERROR(sparams->utils, "unable canonify user and get auxprops");
3179 result = sparams->canon_user(sparams->utils->conn,
3182 result = sparams->canon_user(sparams->utils->conn,
3189 sparams->utils->log(sparams->utils->conn, SASL_LOG_ERR,
3192 SETERROR(sparams->utils, "unable authorization ID");
3197 result = sparams->utils->prop_getnames(sparams->propctx, password_request,
3204 sparams->utils->seterror(sparams->utils->conn, 0,
3207 sparams->utils->seterror(sparams->utils->conn, 0,
3218 sparams->utils->seterror(sparams->utils->conn,0,
3221 sparams->utils->seterror(sparams->utils->conn,0,
3228 sec = sparams->utils->malloc(sizeof(sasl_secret_t) + len);
3231 sparams->utils->log(sparams->utils->conn, SASL_LOG_ERR,
3234 SETERROR(sparams->utils, "unable to allocate secret");
3259 DigestCalcSecret(sparams->utils, (unsigned char *)username,
3263 DigestCalcSecret(sparams->utils, username,
3277 _plug_free_secret(sparams->utils, &sec);
3283 sparams->utils->log(sparams->utils->conn, SASL_LOG_ERR,
3286 sparams->utils->seterror(sparams->utils->conn, 0,
3299 _plug_strdup(sparams->utils, "auth", &qop, NULL);
3333 sparams->utils->log(sparams->utils->conn, SASL_LOG_WARN,
3336 SETERROR(sparams->utils, "client requested invalid cipher");
3357 sparams->utils->log(sparams->utils->conn, SASL_LOG_ERR,
3360 SETERROR(sparams->utils,
3368 sparams->utils,
3380 SETERROR(sparams->utils, "internal error: unable to create response");
3389 SETERROR(sparams->utils,
3392 SETERROR(sparams->utils,
3404 SETERROR(sparams->utils, gettext("server nonce expired"));
3406 SETERROR(sparams->utils, "server nonce expired");
3445 text->utils = sparams->utils;
3455 create_layer_keys(text, sparams->utils,text->HA1,n,enckey,deckey);
3463 sparams->utils->log(sparams->utils->conn, SASL_LOG_ERR,
3471 sparams->utils->seterror(sparams->utils->conn, 0,
3497 result = _plug_buf_alloc(sparams->utils, &(text->out_buf),
3519 sparams->utils->mutex_lock(text->reauth->mutex) == SASL_OK) { /* LOCK */
3527 clear_reauth_entry(&text->reauth->e[val], SERVER, sparams->utils);
3535 clear_reauth_entry(&text->reauth->e[val], SERVER, sparams->utils);
3545 clear_reauth_entry(&text->reauth->e[val], SERVER, sparams->utils);
3551 sparams->utils->mutex_unlock(text->reauth->mutex); /* UNLOCK */
3555 if (in_start) sparams->utils->free (in_start);
3558 sparams->utils->free (username);
3561 sparams->utils->free (authorization_id);
3564 sparams->utils->free (realm);
3566 sparams->utils->free (nonce);
3568 sparams->utils->free (cnonce);
3570 sparams->utils->free (response);
3572 sparams->utils->free (cipher);
3574 sparams->utils->free(serverresponse);
3576 sparams->utils->free (charset);
3578 sparams->utils->free (digesturi);
3580 sparams->utils->free (qop);
3582 _plug_free_secret(sparams->utils, &sec);
3636 sparams->utils->log(sparams->utils->conn, SASL_LOG_WARN,
3639 sparams->utils->log(NULL, SASL_LOG_WARN,
3660 sparams->utils->log(sparams->utils->conn, SASL_LOG_ERR,
3663 sparams->utils->log(NULL, SASL_LOG_ERR,
3675 digestmd5_server_mech_dispose(void *conn_context, const sasl_utils_t *utils)
3679 if (!stext || !utils) return;
3681 digestmd5_common_mech_dispose(conn_context, utils);
3716 int digestmd5_server_plug_init(sasl_utils_t *utils,
3733 if ((ret = uef_init(utils)) != SASL_OK)
3738 reauth_cache = utils->malloc(sizeof(reauth_cache_t));
3745 utils->getopt(utils->getopt_context, "DIGEST-MD5", "reauth_timeout",
3758 reauth_cache->mutex = utils->mutex_alloc();
3764 reauth_cache->e = utils->malloc(reauth_cache->size *
3817 const sasl_utils_t * utils,
3829 DigestCalcSecret(utils,
3837 utils->MD5Init(&Md5Ctx);
3838 utils->MD5Update(&Md5Ctx, HA1, HASHLEN);
3839 utils->MD5Update(&Md5Ctx, COLON, 1);
3840 utils->MD5Update(&Md5Ctx, pszNonce, strlen((char *) pszNonce));
3841 utils->MD5Update(&Md5Ctx, COLON, 1);
3842 utils->MD5Update(&Md5Ctx, pszCNonce, strlen((char *) pszCNonce));
3844 utils->MD5Update(&Md5Ctx, COLON, 1);
3845 utils->MD5Update(&Md5Ctx, pszAuthorization_id,
3848 utils->MD5Final(HA1, &Md5Ctx);
3860 const sasl_utils_t * utils,
3879 PARAMERROR( utils );
3894 utils,
3903 DigestCalcResponse(utils,
3916 result = utils->malloc(HASHHEXLEN + 1);
3925 DigestCalcResponse(utils,
3940 utils->free(*response_value);
3942 *response_value = utils->malloc(HASHHEXLEN + 1);
3997 digesturi = params->utils->malloc(strlen(params->service) + 1 +
4016 params->utils,
4045 result =_plug_buf_alloc(params->utils, &(text->out_buf),
4052 if (add_to_challenge(params->utils,
4060 if (add_to_challenge(params->utils,
4072 if (add_to_challenge(params->utils,
4078 if (add_to_challenge(params->utils,
4085 if (add_to_challenge(params->utils,
4091 if (add_to_challenge(params->utils,
4098 if (add_to_challenge(params->utils,
4110 if (add_to_challenge(params->utils,
4115 params->utils->log(params->utils->conn, SASL_LOG_ERR,
4118 SETERROR(params->utils,
4126 if (add_to_challenge(params->utils,
4134 if (add_to_challenge(params->utils,
4140 if (add_to_challenge(params->utils,
4179 text->utils = params->utils;
4192 create_layer_keys(text, params->utils, text->HA1, nbits,
4201 params->utils->log(params->utils->conn, SASL_LOG_ERR,
4215 if (digesturi) params->utils->free(digesturi);
4216 if (response) params->utils->free(response);
4244 params->utils->log(params->utils->conn, SASL_LOG_ERR,
4247 params->utils->seterror(params->utils->conn, 0,
4253 in_start = in = params->utils->malloc(serverinlen + 1);
4262 text->cnonce = create_nonce(params->utils);
4265 params->utils->log(params->utils->conn, SASL_LOG_ERR,
4268 params->utils->seterror(params->utils->conn, 0,
4284 params->utils->log(params->utils->conn, SASL_LOG_ERR,
4287 params->utils->seterror(params->utils->conn, 0, "Parse error");
4297 realms = params->utils->malloc(sizeof(char *) * (nrealm + 1));
4299 realms = params->utils->realloc(realms,
4307 _plug_strdup(params->utils, value, &realms[nrealm-1], NULL);
4310 _plug_strdup(params->utils, value, (char **) &text->nonce,
4327 params->utils->log(params->utils->conn, SASL_LOG_DEBUG,
4338 params->utils->seterror(params->utils->conn, 0,
4341 params->utils->seterror(params->utils->conn, 0,
4367 params->utils->log(params->utils->conn, SASL_LOG_DEBUG,
4377 _plug_free_secret(params->utils, &ctext->password);
4392 params->utils->log(params->utils->conn, SASL_LOG_ERR,
4396 params->utils->seterror(params->utils->conn, 0,
4403 params->utils->log(params->utils->conn, SASL_LOG_ERR,
4406 params->utils->seterror(params->utils->conn, 0,
4414 params->utils->log(params->utils->conn, SASL_LOG_ERR,
4418 params->utils->seterror(params->utils->conn, 0,
4428 params->utils->log(params->utils->conn, SASL_LOG_ERR,
4431 params->utils->seterror(params->utils->conn, 0,
4444 params->utils->log(params->utils->conn, SASL_LOG_ERR,
4447 params->utils->seterror(params->utils->conn, 0,
4458 params->utils->log(params->utils->conn, SASL_LOG_ERR,
4461 params->utils->seterror(params->utils->conn, 0,
4468 params->utils->log(params->utils->conn, SASL_LOG_DEBUG,
4476 params->utils->log(params->utils->conn, SASL_LOG_ERR,
4479 params->utils->seterror(params->utils->conn, 0,
4489 params->utils->log(params->utils->conn, SASL_LOG_ERR,
4492 params->utils->seterror(params->utils->conn, 0,
4548 params->utils->seterror(params->utils->conn, 0,
4551 params->utils->seterror(params->utils->conn, 0,
4576 params->utils->seterror(params->utils->conn, 0,
4579 params->utils->seterror(params->utils->conn, 0,
4587 params->utils->seterror(params->utils->conn, 0,
4590 params->utils->seterror(params->utils->conn, 0,
4602 if (in_start) params->utils->free(in_start);
4609 params->utils->free(realms[lup]);
4611 params->utils->free(realms);
4634 auth_result = _plug_get_authid(params->utils, &authid, prompt_need);
4643 user_result = _plug_get_userid(params->utils, &userid, prompt_need);
4652 pass_result = _plug_get_password(params->utils, &ctext->password,
4668 realm_result = _plug_get_realm(params->utils,
4687 params->utils->free(*prompt_need);
4697 realm_chal = params->utils->malloc(3+strlen(params->serverFQDN));
4708 _plug_make_prompts(params->utils, &ctext->h, prompt_need,
4710 convert_prompt(params->utils, &ctext->h,
4715 convert_prompt(params->utils, &ctext->h,
4720 convert_prompt(params->utils, &ctext->h,
4726 convert_prompt(params->utils, &ctext->h,
4730 _plug_make_prompts(params->utils, prompt_need,
4753 result = params->canon_user(params->utils->conn, authid, 0,
4758 result = params->canon_user(params->utils->conn,
4762 result = params->canon_user(params->utils->conn,
4770 _plug_strdup(params->utils, realm, (char **) &text->realm, NULL);
4784 text = params->utils->malloc(sizeof(client_context_t));
4812 params->utils->log(params->utils->conn, SASL_LOG_DEBUG,
4820 if (params->utils->mutex_lock(text->reauth->mutex) == SASL_OK) { /* LOCK */
4827 if (text->realm) params->utils->free(text->realm);
4828 if (text->nonce) params->utils->free(text->nonce);
4829 if (text->cnonce) params->utils->free(text->cnonce);
4832 _plug_strdup(params->utils, text->reauth->e[val].realm,
4835 _plug_strdup(params->utils, (char *)text->reauth->e[val].nonce,
4838 _plug_strdup(params->utils, text->reauth->e[val].nonce,
4843 _plug_strdup(params->utils, (char *)text->reauth->e[val].cnonce,
4846 _plug_strdup(params->utils, text->reauth->e[val].cnonce,
4853 params->utils->mutex_unlock(text->reauth->mutex); /* UNLOCK */
4893 params->utils->log(params->utils->conn, SASL_LOG_DEBUG,
4911 params->utils->free(realms);
4941 params->utils->free(realms[lup]);
4943 params->utils->free(realms);
4964 params->utils->log(params->utils->conn, SASL_LOG_DEBUG,
4968 in_start = in = params->utils->malloc(serverinlen + 1);
4981 params->utils->log(params->utils->conn, SASL_LOG_ERR,
4984 params->utils->seterror(params->utils->conn, 0,
4994 params->utils->seterror(params->utils->conn, 0,
4997 params->utils->seterror(params->utils->conn, 0,
5009 params->utils->log(params->utils->conn, SASL_LOG_DEBUG,
5015 params->utils->free(in_start);
5017 if (params->utils->mutex_lock(text->reauth->mutex) == SASL_OK) { /* LOCK */
5023 clear_reauth_entry(&text->reauth->e[val], CLIENT, params->utils);
5024 _plug_strdup(params->utils, oparams->authid,
5030 _plug_strdup(params->utils, params->serverFQDN,
5045 clear_reauth_entry(&text->reauth->e[val], CLIENT, params->utils);
5051 params->utils->mutex_unlock(text->reauth->mutex); /* UNLOCK */
5084 if (params->utils->mutex_lock(text->reauth->mutex) == SASL_OK) { /* LOCK */
5088 params->utils->mutex_unlock(text->reauth->mutex); /* UNLOCK */
5120 if (params->utils->mutex_lock(text->reauth->mutex) == SASL_OK) { /* LOCK */
5121 clear_reauth_entry(&text->reauth->e[val], CLIENT, params->utils);
5123 params->utils->mutex_unlock(text->reauth->mutex); /* UNLOCK */
5126 if (text->realm) params->utils->free(text->realm);
5127 if (text->nonce) params->utils->free(text->nonce);
5128 if (text->cnonce) params->utils->free(text->cnonce);
5146 params->utils->log(params->utils->conn, SASL_LOG_ERR,
5149 params->utils->log(NULL, SASL_LOG_ERR,
5159 digestmd5_client_mech_dispose(void *conn_context, const sasl_utils_t *utils)
5163 if (!ctext || !utils) return;
5166 convert_prompt(utils, &ctext->h, NULL);
5169 if (ctext->free_password) _plug_free_secret(utils, &ctext->password);
5171 digestmd5_common_mech_dispose(conn_context, utils);
5205 int digestmd5_client_plug_init(sasl_utils_t *utils,
5220 if ((ret = uef_init(utils)) != SASL_OK)
5225 reauth_cache = utils->malloc(sizeof(reauth_cache_t));
5232 reauth_cache->mutex = utils->mutex_alloc();
5238 reauth_cache->e = utils->malloc(reauth_cache->size *
5274 getSlotID(const sasl_utils_t *utils, CK_MECHANISM_TYPE mech_type,
5288 utils->log(utils->conn, SASL_LOG_DEBUG,
5294 pSlotList = utils->calloc(sizeof (CK_SLOT_ID), ulSlotCount);
5301 utils->log(utils->conn, SASL_LOG_DEBUG,
5312 utils->log(utils->conn, SASL_LOG_DEBUG,
5316 utils->free(pSlotList);
5320 utils->calloc(sizeof (CK_MECHANISM_TYPE), ulMechTypeCount);
5322 utils->free(pSlotList);
5328 utils->log(utils->conn, SASL_LOG_DEBUG,
5332 utils->free(pMechTypeList);
5333 utils->free(pSlotList);
5341 utils->free(pMechTypeList);
5346 utils->free(pSlotList);
5355 uef_init(const sasl_utils_t *utils)
5372 utils->log(utils->conn, SASL_LOG_DEBUG,
5378 got_rc4 = getSlotID(utils, CKM_RC4, &rc4_slot_id) == SASL_OK;
5380 utils->log(utils->conn, SASL_LOG_WARN, "Could not get rc4");
5382 got_des = getSlotID(utils, CKM_DES_CBC, &des_slot_id) == SASL_OK;
5384 utils->log(utils->conn, SASL_LOG_WARN, "Could not get des");
5386 got_3des = getSlotID(utils, CKM_DES3_CBC, &des3_slot_id) == SASL_OK;
5388 utils->log(utils->conn, SASL_LOG_WARN, "Could not get 3des");