• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10.1/passwordserver_sasl-193/cyrus_sasl/plugins/

Lines Matching refs:text

157     context_t *text = (context_t *) context;
165 PARAMERROR( text->utils );
174 ret = _plug_buf_alloc(text->utils, &text->encode_buf,
175 &text->encode_buf_len,
185 tmpnum = htonl(text->pktnum_out++);
186 memcpy(text->send_integrity_key, &tmpnum, 4);
189 HMAC_Init_ex(&text->hmac_send_ctx, text->send_integrity_key,
195 HMAC_Update(&text->hmac_send_ctx, invec[i].iov_base, invec[i].iov_len);
197 if (text->secmask & PRIVACY_LAYER_FLAG) {
201 EVP_EncryptUpdate(&text->cipher_enc_ctx,
202 text->encode_buf + *outputlen, &enclen,
208 memcpy(text->encode_buf + *outputlen, invec[i].iov_base,
215 HMAC_Final(&text->hmac_send_ctx, hmac, &hmaclen);
217 if (text->secmask & PRIVACY_LAYER_FLAG) {
222 EVP_EncryptUpdate(&text->cipher_enc_ctx,
223 text->encode_buf + *outputlen, &enclen,
229 padlen = text->blk_siz - ((inputlen + hmaclen) % text->blk_siz) - 1;
230 EVP_EncryptUpdate(&text->cipher_enc_ctx,
231 text->encode_buf + *outputlen, &enclen,
232 text->padding, padlen);
234 EVP_EncryptUpdate(&text->cipher_enc_ctx,
235 text->encode_buf + *outputlen, &enclen,
240 EVP_EncryptFinal_ex(&text->cipher_enc_ctx,
241 text->encode_buf + *outputlen, &enclen);
246 memcpy(text->encode_buf + *outputlen, hmac, hmaclen);
253 memcpy(text->encode_buf, &tmpnum, 4);
255 *output = text->encode_buf;
267 context_t *text = (context_t *) context;
273 if (text->secmask & PRIVACY_LAYER_FLAG) {
277 ret = _plug_buf_alloc(text->utils, &(text->decode_pkt_buf),
278 &(text->decode_pkt_buf_len), inputlen);
282 ret = EVP_DecryptUpdate(&text->cipher_dec_ctx,
283 text->decode_pkt_buf, &declen,
286 EVP_DecryptFinal_ex(&text->cipher_dec_ctx, /* should be no output */
287 text->decode_pkt_buf + declen, &declen);
289 SETERROR(text->utils, "Error decrypting input");
292 input = text->decode_pkt_buf;
295 padlen = text->decode_pkt_buf[inputlen - 1] + 1;
303 tmpnum = htonl(text->pktnum_in++);
304 memcpy(text->recv_integrity_key, &tmpnum, 4);
307 HMAC(EVP_sha1(), text->recv_integrity_key, 4+SHA_DIGEST_LENGTH,
312 SETERROR(text->utils, "HMAC is incorrect\n");
327 context_t *text = (context_t *) context;
330 ret = _plug_decode(&text->decode_context, input, inputlen,
331 &text->decode_buf, &text->decode_buf_len, outputlen,
332 passdss_decode_packet, text);
334 *output = text->decode_buf;
725 void CalcLayerParams(context_t *text, char *K, unsigned Klen,
730 DOHASH(text->cs_encryption_iv, K, Klen, "A", 1, hash, hashlen);
731 DOHASH(text->sc_encryption_iv, K, Klen, "B", 1, hash, hashlen);
732 DOHASH(text->cs_encryption_key, K, Klen, "C", 1, hash, hashlen);
733 DOHASH(text->cs_encryption_key + hashlen, K, Klen, "", 0,
734 text->cs_encryption_key, hashlen);
735 DOHASH(text->sc_encryption_key, K, Klen, "D", 1, hash, hashlen);
736 DOHASH(text->sc_encryption_key + hashlen, K, Klen, "", 0,
737 text->sc_encryption_key, hashlen);
738 DOHASH(text->cs_integrity_key, K, Klen, "E", 1, hash, hashlen);
739 DOHASH(text->sc_integrity_key, K, Klen, "F", 1, hash, hashlen);
748 context_t *text = (context_t *) conn_context;
750 if (!text) return;
752 if (text->authid) utils->free(text->authid);
753 if (text->userid) utils->free(text->userid);
754 if (text->free_password) _plug_free_secret(utils, &(text->password));
756 if (text->dh) DH_free(text->dh);
758 HMAC_CTX_cleanup(&text->hmac_send_ctx);
759 HMAC_CTX_cleanup(&text->hmac_recv_ctx);
761 EVP_CIPHER_CTX_cleanup(&text->cipher_enc_ctx);
762 EVP_CIPHER_CTX_cleanup(&text->cipher_dec_ctx);
764 _plug_decode_free(&text->decode_context);
766 if (text->encode_buf) utils->free(text->encode_buf);
767 if (text->decode_buf) utils->free(text->decode_buf);
768 if (text->decode_pkt_buf) utils->free(text->decode_pkt_buf);
769 if (text->out_buf) utils->free(text->out_buf);
771 utils->free(text);
782 context_t *text;
785 text = sparams->utils->malloc(sizeof(context_t));
786 if (text == NULL) {
791 memset(text, 0, sizeof(context_t));
793 text->state = 1;
794 text->utils = sparams->utils;
795 text->cs_integrity_key = text->recv_integrity_key + 4;
796 text->sc_integrity_key = text->send_integrity_key + 4;
798 *conn_context = text;
804 passdss_server_mech_step1(context_t *text,
830 "%s%s%m", &text->userid, &text->authid, &X);
846 text->dh = DH_new();
847 BN_hex2bn(&text->dh->p, N);
848 BN_hex2bn(&text->dh->g, g);
849 DH_generate_key(text->dh);
852 K = text->utils->malloc(DH_size(text->dh) + 4);
860 Klen = DH_compute_key(K+4, X, text->dh);
875 text->secmask |= NO_LAYER_FLAG;
877 text->secmask |= INTEGRITY_LAYER_FLAG;
879 text->secmask |= PRIVACY_LAYER_FLAG;
900 result = MakeBuffer(text->utils, &text->out_buf, 0, &text->out_buf_len,
903 text->dh->pub_key, &text->secmask,
916 EVP_DigestUpdate(&mdctx, text->out_buf, *serveroutlen);
922 CalcLayerParams(text, K, Klen, hash, hashlen);
925 HMAC_CTX_init(&text->hmac_recv_ctx);
926 HMAC_Init_ex(&text->hmac_recv_ctx, text->cs_integrity_key,
929 HMAC_Update(&text->hmac_recv_ctx, clientin, clientinlen);
931 HMAC_Update(&text->hmac_recv_ctx, text->out_buf, *serveroutlen);
943 result = MakeBuffer(text->utils, &text->out_buf, *serveroutlen,
944 &text->out_buf_len, serveroutlen,
950 *serverout = text->out_buf;
952 text->state = 2;
957 if (K) text->utils->free(K);
965 passdss_server_mech_step2(context_t *text,
988 result = _plug_buf_alloc(text->utils, &text->decode_pkt_buf,
989 &text->decode_pkt_buf_len, clientinlen);
997 EVP_CIPHER_CTX_init(&text->cipher_dec_ctx);
998 EVP_DecryptInit_ex(&text->cipher_dec_ctx, EVP_des_ede3_cbc(), NULL,
999 text->cs_encryption_key, text->cs_encryption_iv);
1000 EVP_CIPHER_CTX_set_padding(&text->cipher_dec_ctx, 0);
1001 text->blk_siz = EVP_CIPHER_CTX_block_size(&text->cipher_dec_ctx);
1004 r = EVP_DecryptUpdate(&text->cipher_dec_ctx, text->decode_pkt_buf, &declen,
1007 r = EVP_DecryptFinal_ex(&text->cipher_dec_ctx, /* should be no output */
1008 text->decode_pkt_buf + declen, &declen);
1015 clientin = text->decode_pkt_buf;
1019 SHA_DIGEST_LENGTH, &cli_hmac, text->blk_siz - 1);
1029 HMAC_Update(&text->hmac_recv_ctx, clientin, 4);
1030 HMAC_Final(&text->hmac_recv_ctx, hmac, &hmaclen);
1043 text->authid, 0, SASL_CU_AUTHID, oparams);
1063 *text->userid ? text->userid : text->authid, 0,
1068 text->secmask &= *csecmask;
1069 if (text->secmask & PRIVACY_LAYER_FLAG) {
1071 } else if (text->secmask & INTEGRITY_LAYER_FLAG) {
1073 } else if (text->secmask & NO_LAYER_FLAG) {
1092 HMAC_CTX_init(&text->hmac_send_ctx);
1095 oparams->maxoutbuf -= text->blk_siz-1; /* padding */
1098 EVP_CIPHER_CTX_init(&text->cipher_enc_ctx);
1099 EVP_EncryptInit_ex(&text->cipher_enc_ctx, EVP_des_ede3_cbc(), NULL,
1100 text->sc_encryption_key, text->sc_encryption_iv);
1101 EVP_CIPHER_CTX_set_padding(&text->cipher_enc_ctx, 0);
1104 _plug_decode_init(&text->decode_context, text->utils,
1130 context_t *text = (context_t *) conn_context;
1139 "PASSDSS server step %d\n", text->state);
1144 switch (text->state) {
1147 return passdss_server_mech_step1(text, sparams, clientin, clientinlen,
1151 return passdss_server_mech_step2(text, sparams, clientin, clientinlen,
1156 "Invalid PASSDSS server step %d", text->state);
1214 context_t *text;
1217 text = params->utils->malloc(sizeof(context_t));
1218 if (text == NULL) {
1223 memset(text, 0, sizeof(context_t));
1225 text->state = 1;
1226 text->utils = params->utils;
1227 text->cs_integrity_key = text->send_integrity_key + 4;
1228 text->sc_integrity_key = text->recv_integrity_key + 4;
1230 *conn_context = text;
1236 passdss_client_mech_step1(context_t *text,
1281 if (text->password == NULL) {
1282 pass_result = _plug_get_password(params->utils, &text->password,
1283 &text->free_password, prompt_need);
1316 if (!text->password) {
1336 text->dh = DH_new();
1337 BN_hex2bn(&text->dh->p, N);
1338 BN_hex2bn(&text->dh->g, g);
1339 DH_generate_key(text->dh);
1349 result = MakeBuffer(text->utils, &text->out_buf, 0, &text->out_buf_len,
1352 (char *) oparams->authid, text->dh->pub_key);
1357 *clientout = text->out_buf;
1359 text->state = 2;
1368 passdss_client_mech_step2(context_t *text,
1420 K = text->utils->malloc(DH_size(text->dh) + 4);
1428 Klen = DH_compute_key(K+4, Y, text->dh);
1437 EVP_DigestUpdate(&mdctx, text->out_buf, text->out_buf_len);
1455 CalcLayerParams(text, K, Klen, hash, hashlen);
1458 EVP_CIPHER_CTX_init(&text->cipher_enc_ctx);
1459 EVP_EncryptInit_ex(&text->cipher_enc_ctx, EVP_des_ede3_cbc(), NULL,
1460 text->cs_encryption_key, text->cs_encryption_iv);
1461 EVP_CIPHER_CTX_set_padding(&text->cipher_enc_ctx, 0);
1462 text->blk_siz = EVP_CIPHER_CTX_block_size(&text->cipher_enc_ctx);
1474 text->secmask = PRIVACY_LAYER_FLAG;
1479 text->secmask =INTEGRITY_LAYER_FLAG;
1482 text->secmask = NO_LAYER_FLAG;
1493 HMAC_CTX_init(&text->hmac_send_ctx);
1494 HMAC_Init_ex(&text->hmac_send_ctx, text->cs_integrity_key,
1497 HMAC_Update(&text->hmac_send_ctx, text->out_buf, text->out_buf_len);
1499 HMAC_Update(&text->hmac_send_ctx, serverin, serverinlen - siglen - 4);
1510 result = MakeBuffer(text->utils, &text->out_buf, 0,
1511 &text->out_buf_len, clientoutlen, "%1o%3u%*s",
1512 &text->secmask,
1515 text->password->len, text->password->data);
1523 HMAC_Update(&text->hmac_send_ctx, text->out_buf, 4);
1524 HMAC_Final(&text->hmac_send_ctx, hash, &hashlen);
1527 result = MakeBuffer(text->utils, &text->out_buf, *clientoutlen,
1528 &text->out_buf_len, clientoutlen, "%*o%*o",
1529 hashlen, hash, text->blk_siz - 1, text->padding);
1536 result = _plug_buf_alloc(text->utils, &text->encode_buf,
1537 &text->encode_buf_len, *clientoutlen);
1545 r = EVP_EncryptUpdate(&text->cipher_enc_ctx, text->encode_buf,
1546 clientoutlen, text->out_buf,
1547 text->blk_siz * (*clientoutlen / text->blk_siz));
1549 r = EVP_EncryptFinal_ex(&text->cipher_enc_ctx, /* should be no output */
1550 text->encode_buf + *clientoutlen, &enclen);
1557 *clientout = text->encode_buf;
1568 HMAC_CTX_init(&text->hmac_recv_ctx);
1571 oparams->maxoutbuf -= text->blk_siz-1; /* padding */
1574 EVP_CIPHER_CTX_init(&text->cipher_dec_ctx);
1575 EVP_DecryptInit_ex(&text->cipher_dec_ctx, EVP_des_ede3_cbc(), NULL,
1576 text->sc_encryption_key, text->sc_encryption_iv);
1577 EVP_CIPHER_CTX_set_padding(&text->cipher_dec_ctx, 0);
1580 _plug_decode_init(&text->decode_context, text->utils,
1594 if (K) text->utils->free(K);
1610 context_t *text = (context_t *) conn_context;
1613 "PASSDSS client step %d\n", text->state);
1618 switch (text->state) {
1621 return passdss_client_mech_step1(text, params, serverin, serverinlen,
1626 return passdss_client_mech_step2(text, params, serverin, serverinlen,
1632 "Invalid PASSDSS client step %d\n", text->state);