Lines Matching +full:data +full:- +full:out
2 * Copyright (c) 2006 - 2008 Kungliga Tekniska Högskolan
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
52 #include "krb5-types.h"
53 #include "crypto-headers.h"
62 * protocol, both version 1 and 2. The GSS-API mech that uses this
71 * Heimdal to implement and GSS-API mechanism. There is also support
115 goto out; \
175 if (p->data) in heim_ntlm_free_buf()
176 free(p->data); in heim_ntlm_free_buf()
177 p->data = NULL; in heim_ntlm_free_buf()
178 p->length = 0; in heim_ntlm_free_buf()
192 buf->length = len * 2; in ascii2ucs2le()
193 buf->data = malloc(buf->length); in ascii2ucs2le()
194 if (buf->data == NULL && len != 0) { in ascii2ucs2le()
199 p = buf->data; in ascii2ucs2le()
222 CHECK(krb5_ret_uint16(sp, &buf->length), 0); in ret_sec_buffer()
223 CHECK(krb5_ret_uint16(sp, &buf->allocated), 0); in ret_sec_buffer()
224 CHECK(krb5_ret_uint32(sp, &buf->offset), 0); in ret_sec_buffer()
225 out: in ret_sec_buffer()
233 CHECK(krb5_store_uint16(sp, buf->length), 0); in store_sec_buffer()
234 CHECK(krb5_store_uint16(sp, buf->allocated), 0); in store_sec_buffer()
235 CHECK(krb5_store_uint32(sp, buf->offset), 0); in store_sec_buffer()
236 out: in store_sec_buffer()
283 out: in ret_string()
293 CHECK(krb5_storage_seek(sp, desc->offset, SEEK_SET), desc->offset); in ret_sec_string()
294 CHECK(ret_string(sp, ucs2, desc->length, s), 0); in ret_sec_string()
295 out: in ret_sec_string()
310 buf.data = rk_UNCONST(s); in put_string()
314 CHECK(krb5_storage_write(sp, buf.data, buf.length), buf.length); in put_string()
318 out: in put_string()
331 buf->data = malloc(desc->length); in ret_buf()
332 buf->length = desc->length; in ret_buf()
333 CHECK(krb5_storage_seek(sp, desc->offset, SEEK_SET), desc->offset); in ret_buf()
334 CHECK(krb5_storage_read(sp, buf->data, buf->length), buf->length); in ret_buf()
336 out: in ret_buf()
344 CHECK(krb5_storage_write(sp, buf->data, buf->length), buf->length); in put_buf()
346 out: in put_buf()
361 free(ti->servername); in heim_ntlm_free_targetinfo()
362 free(ti->domainname); in heim_ntlm_free_targetinfo()
363 free(ti->dnsdomainname); in heim_ntlm_free_targetinfo()
364 free(ti->dnsservername); in heim_ntlm_free_targetinfo()
365 free(ti->dnstreename); in heim_ntlm_free_targetinfo()
370 encode_ti_string(krb5_storage *out, uint16_t type, int ucs2, char *s) in encode_ti_string() argument
373 CHECK(krb5_store_uint16(out, type), 0); in encode_ti_string()
374 CHECK(krb5_store_uint16(out, len_string(ucs2, s)), 0); in encode_ti_string()
375 CHECK(put_string(out, ucs2, s), 0); in encode_ti_string()
376 out: in encode_ti_string()
385 * @param data is the return buffer with the encoded message, should be
397 struct ntlm_buf *data) in heim_ntlm_encode_targetinfo() argument
400 krb5_storage *out; in heim_ntlm_encode_targetinfo() local
402 data->data = NULL; in heim_ntlm_encode_targetinfo()
403 data->length = 0; in heim_ntlm_encode_targetinfo()
405 out = krb5_storage_emem(); in heim_ntlm_encode_targetinfo()
406 if (out == NULL) in heim_ntlm_encode_targetinfo()
409 krb5_storage_set_byteorder(out, KRB5_STORAGE_BYTEORDER_LE); in heim_ntlm_encode_targetinfo()
411 if (ti->servername) in heim_ntlm_encode_targetinfo()
412 CHECK(encode_ti_string(out, 1, ucs2, ti->servername), 0); in heim_ntlm_encode_targetinfo()
413 if (ti->domainname) in heim_ntlm_encode_targetinfo()
414 CHECK(encode_ti_string(out, 2, ucs2, ti->domainname), 0); in heim_ntlm_encode_targetinfo()
415 if (ti->dnsservername) in heim_ntlm_encode_targetinfo()
416 CHECK(encode_ti_string(out, 3, ucs2, ti->dnsservername), 0); in heim_ntlm_encode_targetinfo()
417 if (ti->dnsdomainname) in heim_ntlm_encode_targetinfo()
418 CHECK(encode_ti_string(out, 4, ucs2, ti->dnsdomainname), 0); in heim_ntlm_encode_targetinfo()
419 if (ti->dnstreename) in heim_ntlm_encode_targetinfo()
420 CHECK(encode_ti_string(out, 5, ucs2, ti->dnstreename), 0); in heim_ntlm_encode_targetinfo()
421 if (ti->avflags) { in heim_ntlm_encode_targetinfo()
422 CHECK(krb5_store_uint16(out, 6), 0); in heim_ntlm_encode_targetinfo()
423 CHECK(krb5_store_uint16(out, 4), 0); in heim_ntlm_encode_targetinfo()
424 CHECK(krb5_store_uint32(out, ti->avflags), 0); in heim_ntlm_encode_targetinfo()
428 CHECK(krb5_store_int16(out, 0), 0); in heim_ntlm_encode_targetinfo()
429 CHECK(krb5_store_int16(out, 0), 0); in heim_ntlm_encode_targetinfo()
433 ret = krb5_storage_to_data(out, &d); in heim_ntlm_encode_targetinfo()
434 data->data = d.data; in heim_ntlm_encode_targetinfo()
435 data->length = d.length; in heim_ntlm_encode_targetinfo()
437 out: in heim_ntlm_encode_targetinfo()
438 krb5_storage_free(out); in heim_ntlm_encode_targetinfo()
445 * @param data input data buffer with the encode NTLM targetinfo message
456 heim_ntlm_decode_targetinfo(const struct ntlm_buf *data, in heim_ntlm_decode_targetinfo() argument
466 if (data->length == 0) in heim_ntlm_decode_targetinfo()
469 in = krb5_storage_from_readonly_mem(data->data, data->length); in heim_ntlm_decode_targetinfo()
483 CHECK(ret_string(in, ucs2, len, &ti->servername), 0); in heim_ntlm_decode_targetinfo()
486 CHECK(ret_string(in, ucs2, len, &ti->domainname), 0); in heim_ntlm_decode_targetinfo()
489 CHECK(ret_string(in, ucs2, len, &ti->dnsservername), 0); in heim_ntlm_decode_targetinfo()
492 CHECK(ret_string(in, ucs2, len, &ti->dnsdomainname), 0); in heim_ntlm_decode_targetinfo()
495 CHECK(ret_string(in, ucs2, len, &ti->dnstreename), 0); in heim_ntlm_decode_targetinfo()
498 CHECK(krb5_ret_uint32(in, &ti->avflags), 0); in heim_ntlm_decode_targetinfo()
505 out: in heim_ntlm_decode_targetinfo()
514 * @param data message to be freed
520 heim_ntlm_free_type1(struct ntlm_type1 *data) in heim_ntlm_free_type1() argument
522 if (data->domain) in heim_ntlm_free_type1()
523 free(data->domain); in heim_ntlm_free_type1()
524 if (data->hostname) in heim_ntlm_free_type1()
525 free(data->hostname); in heim_ntlm_free_type1()
526 memset(data, 0, sizeof(*data)); in heim_ntlm_free_type1()
530 heim_ntlm_decode_type1(const struct ntlm_buf *buf, struct ntlm_type1 *data) in heim_ntlm_decode_type1() argument
538 memset(data, 0, sizeof(*data)); in heim_ntlm_decode_type1()
540 in = krb5_storage_from_readonly_mem(buf->data, buf->length); in heim_ntlm_decode_type1()
543 goto out; in heim_ntlm_decode_type1()
551 CHECK(krb5_ret_uint32(in, &data->flags), 0); in heim_ntlm_decode_type1()
552 if (data->flags & NTLM_OEM_SUPPLIED_DOMAIN) in heim_ntlm_decode_type1()
554 if (data->flags & NTLM_OEM_SUPPLIED_WORKSTATION) in heim_ntlm_decode_type1()
558 CHECK(krb5_ret_uint32(in, &data->os[0]), 0); in heim_ntlm_decode_type1()
559 CHECK(krb5_ret_uint32(in, &data->os[1]), 0); in heim_ntlm_decode_type1()
562 if (data->flags & NTLM_OEM_SUPPLIED_DOMAIN) in heim_ntlm_decode_type1()
563 CHECK(ret_sec_string(in, 0, &domain, &data->domain), 0); in heim_ntlm_decode_type1()
564 if (data->flags & NTLM_OEM_SUPPLIED_WORKSTATION) in heim_ntlm_decode_type1()
565 CHECK(ret_sec_string(in, 0, &hostname, &data->hostname), 0); in heim_ntlm_decode_type1()
567 out: in heim_ntlm_decode_type1()
571 heim_ntlm_free_type1(data); in heim_ntlm_decode_type1()
580 * @param data is the return buffer with the encoded message, should be
590 heim_ntlm_encode_type1(const struct ntlm_type1 *type1, struct ntlm_buf *data) in heim_ntlm_encode_type1() argument
594 krb5_storage *out; in heim_ntlm_encode_type1() local
597 flags = type1->flags; in heim_ntlm_encode_type1()
600 if (type1->domain) { in heim_ntlm_encode_type1()
604 if (type1->hostname) { in heim_ntlm_encode_type1()
608 if (type1->os[0]) in heim_ntlm_encode_type1()
612 if (type1->domain) { in heim_ntlm_encode_type1()
613 domain.length = len_string(0, type1->domain); in heim_ntlm_encode_type1()
621 if (type1->hostname) { in heim_ntlm_encode_type1()
622 hostname.length = len_string(0, type1->hostname); in heim_ntlm_encode_type1()
629 out = krb5_storage_emem(); in heim_ntlm_encode_type1()
630 if (out == NULL) in heim_ntlm_encode_type1()
633 krb5_storage_set_byteorder(out, KRB5_STORAGE_BYTEORDER_LE); in heim_ntlm_encode_type1()
634 CHECK(krb5_storage_write(out, ntlmsigature, sizeof(ntlmsigature)), in heim_ntlm_encode_type1()
636 CHECK(krb5_store_uint32(out, 1), 0); in heim_ntlm_encode_type1()
637 CHECK(krb5_store_uint32(out, flags), 0); in heim_ntlm_encode_type1()
639 CHECK(store_sec_buffer(out, &domain), 0); in heim_ntlm_encode_type1()
640 CHECK(store_sec_buffer(out, &hostname), 0); in heim_ntlm_encode_type1()
642 CHECK(krb5_store_uint32(out, type1->os[0]), 0); in heim_ntlm_encode_type1()
643 CHECK(krb5_store_uint32(out, type1->os[1]), 0); in heim_ntlm_encode_type1()
645 if (type1->domain) in heim_ntlm_encode_type1()
646 CHECK(put_string(out, 0, type1->domain), 0); in heim_ntlm_encode_type1()
647 if (type1->hostname) in heim_ntlm_encode_type1()
648 CHECK(put_string(out, 0, type1->hostname), 0); in heim_ntlm_encode_type1()
652 ret = krb5_storage_to_data(out, &d); in heim_ntlm_encode_type1()
653 data->data = d.data; in heim_ntlm_encode_type1()
654 data->length = d.length; in heim_ntlm_encode_type1()
656 out: in heim_ntlm_encode_type1()
657 krb5_storage_free(out); in heim_ntlm_encode_type1()
665 * @param data message to be freed
671 heim_ntlm_free_type2(struct ntlm_type2 *data) in heim_ntlm_free_type2() argument
673 if (data->targetname) in heim_ntlm_free_type2()
674 free(data->targetname); in heim_ntlm_free_type2()
675 heim_ntlm_free_buf(&data->targetinfo); in heim_ntlm_free_type2()
676 memset(data, 0, sizeof(*data)); in heim_ntlm_free_type2()
691 in = krb5_storage_from_readonly_mem(buf->data, buf->length); in heim_ntlm_decode_type2()
694 goto out; in heim_ntlm_decode_type2()
704 CHECK(krb5_ret_uint32(in, &type2->flags), 0); in heim_ntlm_decode_type2()
705 if (type2->flags & NTLM_NEG_UNICODE) in heim_ntlm_decode_type2()
707 CHECK(krb5_storage_read(in, type2->challenge, sizeof(type2->challenge)), in heim_ntlm_decode_type2()
708 sizeof(type2->challenge)); in heim_ntlm_decode_type2()
713 if (type2->flags & NTLM_NEG_VERSION) { in heim_ntlm_decode_type2()
714 CHECK(krb5_ret_uint32(in, &type2->os[0]), 0); in heim_ntlm_decode_type2()
715 CHECK(krb5_ret_uint32(in, &type2->os[1]), 0); in heim_ntlm_decode_type2()
718 CHECK(ret_sec_string(in, ucs2, &targetname, &type2->targetname), 0); in heim_ntlm_decode_type2()
719 CHECK(ret_buf(in, &targetinfo, &type2->targetinfo), 0); in heim_ntlm_decode_type2()
722 out: in heim_ntlm_decode_type2()
735 * @param data is the return buffer with the encoded message, should be
745 heim_ntlm_encode_type2(const struct ntlm_type2 *type2, struct ntlm_buf *data) in heim_ntlm_encode_type2() argument
749 krb5_storage *out = NULL; in heim_ntlm_encode_type2() local
755 if (type2->flags & NTLM_NEG_VERSION) in heim_ntlm_encode_type2()
758 if (type2->flags & NTLM_NEG_UNICODE) in heim_ntlm_encode_type2()
762 targetname.length = len_string(ucs2, type2->targetname); in heim_ntlm_encode_type2()
766 targetinfo.length = type2->targetinfo.length; in heim_ntlm_encode_type2()
767 targetinfo.allocated = type2->targetinfo.length; in heim_ntlm_encode_type2()
769 out = krb5_storage_emem(); in heim_ntlm_encode_type2()
770 if (out == NULL) in heim_ntlm_encode_type2()
773 krb5_storage_set_byteorder(out, KRB5_STORAGE_BYTEORDER_LE); in heim_ntlm_encode_type2()
774 CHECK(krb5_storage_write(out, ntlmsigature, sizeof(ntlmsigature)), in heim_ntlm_encode_type2()
776 CHECK(krb5_store_uint32(out, 2), 0); in heim_ntlm_encode_type2()
777 CHECK(store_sec_buffer(out, &targetname), 0); in heim_ntlm_encode_type2()
778 CHECK(krb5_store_uint32(out, type2->flags), 0); in heim_ntlm_encode_type2()
779 CHECK(krb5_storage_write(out, type2->challenge, sizeof(type2->challenge)), in heim_ntlm_encode_type2()
780 sizeof(type2->challenge)); in heim_ntlm_encode_type2()
781 CHECK(krb5_store_uint32(out, 0), 0); /* context */ in heim_ntlm_encode_type2()
782 CHECK(krb5_store_uint32(out, 0), 0); in heim_ntlm_encode_type2()
783 CHECK(store_sec_buffer(out, &targetinfo), 0); in heim_ntlm_encode_type2()
785 if (type2->flags & NTLM_NEG_VERSION) { in heim_ntlm_encode_type2()
786 CHECK(krb5_store_uint32(out, type2->os[0]), 0); in heim_ntlm_encode_type2()
787 CHECK(krb5_store_uint32(out, type2->os[1]), 0); in heim_ntlm_encode_type2()
789 CHECK(put_string(out, ucs2, type2->targetname), 0); in heim_ntlm_encode_type2()
790 CHECK(krb5_storage_write(out, type2->targetinfo.data, in heim_ntlm_encode_type2()
791 type2->targetinfo.length), in heim_ntlm_encode_type2()
792 type2->targetinfo.length); in heim_ntlm_encode_type2()
796 ret = krb5_storage_to_data(out, &d); in heim_ntlm_encode_type2()
797 data->data = d.data; in heim_ntlm_encode_type2()
798 data->length = d.length; in heim_ntlm_encode_type2()
801 out: in heim_ntlm_encode_type2()
802 krb5_storage_free(out); in heim_ntlm_encode_type2()
810 * @param data message to be freed
816 heim_ntlm_free_type3(struct ntlm_type3 *data) in heim_ntlm_free_type3() argument
818 heim_ntlm_free_buf(&data->lm); in heim_ntlm_free_type3()
819 heim_ntlm_free_buf(&data->ntlm); in heim_ntlm_free_type3()
820 if (data->targetname) in heim_ntlm_free_type3()
821 free(data->targetname); in heim_ntlm_free_type3()
822 if (data->username) in heim_ntlm_free_type3()
823 free(data->username); in heim_ntlm_free_type3()
824 if (data->ws) in heim_ntlm_free_type3()
825 free(data->ws); in heim_ntlm_free_type3()
826 heim_ntlm_free_buf(&data->sessionkey); in heim_ntlm_free_type3()
827 memset(data, 0, sizeof(*data)); in heim_ntlm_free_type3()
849 in = krb5_storage_from_readonly_mem(buf->data, buf->length); in heim_ntlm_decode_type3()
852 goto out; in heim_ntlm_decode_type3()
879 CHECK(krb5_ret_uint32(in, &type3->flags), 0); in heim_ntlm_decode_type3()
882 CHECK(krb5_ret_uint32(in, &type3->os[0]), 0); in heim_ntlm_decode_type3()
883 CHECK(krb5_ret_uint32(in, &type3->os[1]), 0); in heim_ntlm_decode_type3()
885 CHECK(ret_buf(in, &lm, &type3->lm), 0); in heim_ntlm_decode_type3()
886 CHECK(ret_buf(in, &ntlm, &type3->ntlm), 0); in heim_ntlm_decode_type3()
887 CHECK(ret_sec_string(in, ucs2, &target, &type3->targetname), 0); in heim_ntlm_decode_type3()
888 CHECK(ret_sec_string(in, ucs2, &username, &type3->username), 0); in heim_ntlm_decode_type3()
889 CHECK(ret_sec_string(in, ucs2, &ws, &type3->ws), 0); in heim_ntlm_decode_type3()
891 CHECK(ret_buf(in, &sessionkey, &type3->sessionkey), 0); in heim_ntlm_decode_type3()
893 out: in heim_ntlm_decode_type3()
906 * @param data is the return buffer with the encoded message, should be
916 heim_ntlm_encode_type3(const struct ntlm_type3 *type3, struct ntlm_buf *data) in heim_ntlm_encode_type3() argument
920 krb5_storage *out = NULL; in heim_ntlm_encode_type3() local
936 if (type3->os[0]) { in heim_ntlm_encode_type3()
940 if (type3->flags & NTLM_NEG_UNICODE) in heim_ntlm_encode_type3()
944 target.length = len_string(ucs2, type3->targetname); in heim_ntlm_encode_type3()
948 username.length = len_string(ucs2, type3->username); in heim_ntlm_encode_type3()
952 ws.length = len_string(ucs2, type3->ws); in heim_ntlm_encode_type3()
956 lm.length = type3->lm.length; in heim_ntlm_encode_type3()
957 lm.allocated = type3->lm.length; in heim_ntlm_encode_type3()
960 ntlm.length = type3->ntlm.length; in heim_ntlm_encode_type3()
964 sessionkey.length = type3->sessionkey.length; in heim_ntlm_encode_type3()
965 sessionkey.allocated = type3->sessionkey.length; in heim_ntlm_encode_type3()
967 out = krb5_storage_emem(); in heim_ntlm_encode_type3()
968 if (out == NULL) in heim_ntlm_encode_type3()
971 krb5_storage_set_byteorder(out, KRB5_STORAGE_BYTEORDER_LE); in heim_ntlm_encode_type3()
972 CHECK(krb5_storage_write(out, ntlmsigature, sizeof(ntlmsigature)), in heim_ntlm_encode_type3()
974 CHECK(krb5_store_uint32(out, 3), 0); in heim_ntlm_encode_type3()
976 CHECK(store_sec_buffer(out, &lm), 0); in heim_ntlm_encode_type3()
977 CHECK(store_sec_buffer(out, &ntlm), 0); in heim_ntlm_encode_type3()
978 CHECK(store_sec_buffer(out, &target), 0); in heim_ntlm_encode_type3()
979 CHECK(store_sec_buffer(out, &username), 0); in heim_ntlm_encode_type3()
980 CHECK(store_sec_buffer(out, &ws), 0); in heim_ntlm_encode_type3()
981 CHECK(store_sec_buffer(out, &sessionkey), 0); in heim_ntlm_encode_type3()
982 CHECK(krb5_store_uint32(out, type3->flags), 0); in heim_ntlm_encode_type3()
985 CHECK(krb5_store_uint32(out, 0), 0); /* os0 */ in heim_ntlm_encode_type3()
986 CHECK(krb5_store_uint32(out, 0), 0); /* os1 */ in heim_ntlm_encode_type3()
989 CHECK(put_string(out, ucs2, type3->targetname), 0); in heim_ntlm_encode_type3()
990 CHECK(put_string(out, ucs2, type3->username), 0); in heim_ntlm_encode_type3()
991 CHECK(put_string(out, ucs2, type3->ws), 0); in heim_ntlm_encode_type3()
992 CHECK(put_buf(out, &type3->lm), 0); in heim_ntlm_encode_type3()
993 CHECK(put_buf(out, &type3->ntlm), 0); in heim_ntlm_encode_type3()
994 CHECK(put_buf(out, &type3->sessionkey), 0); in heim_ntlm_encode_type3()
998 ret = krb5_storage_to_data(out, &d); in heim_ntlm_encode_type3()
999 data->data = d.data; in heim_ntlm_encode_type3()
1000 data->length = d.length; in heim_ntlm_encode_type3()
1003 out: in heim_ntlm_encode_type3()
1004 krb5_storage_free(out); in heim_ntlm_encode_type3()
1061 key->data = malloc(MD5_DIGEST_LENGTH); in heim_ntlm_nt_key()
1062 if (key->data == NULL) in heim_ntlm_nt_key()
1064 key->length = MD5_DIGEST_LENGTH; in heim_ntlm_nt_key()
1080 EVP_DigestUpdate(m, buf.data, buf.length); in heim_ntlm_nt_key()
1081 EVP_DigestFinal_ex(m, key->data, NULL); in heim_ntlm_nt_key()
1114 memset(&res[MD4_DIGEST_LENGTH], 0, sizeof(res) - MD4_DIGEST_LENGTH); in heim_ntlm_calculate_ntlm1()
1116 answer->data = malloc(24); in heim_ntlm_calculate_ntlm1()
1117 if (answer->data == NULL) in heim_ntlm_calculate_ntlm1()
1119 answer->length = 24; in heim_ntlm_calculate_ntlm1()
1121 ret = splitandenc(&res[0], challenge, ((unsigned char *)answer->data) + 0); in heim_ntlm_calculate_ntlm1()
1123 goto out; in heim_ntlm_calculate_ntlm1()
1124 ret = splitandenc(&res[7], challenge, ((unsigned char *)answer->data) + 8); in heim_ntlm_calculate_ntlm1()
1126 goto out; in heim_ntlm_calculate_ntlm1()
1127 ret = splitandenc(&res[14], challenge, ((unsigned char *)answer->data) + 16); in heim_ntlm_calculate_ntlm1()
1129 goto out; in heim_ntlm_calculate_ntlm1()
1133 out: in heim_ntlm_calculate_ntlm1()
1144 session->length = MD4_DIGEST_LENGTH; in heim_ntlm_v1_base_session()
1145 session->data = malloc(session->length); in heim_ntlm_v1_base_session()
1146 if (session->data == NULL) { in heim_ntlm_v1_base_session()
1147 session->length = 0; in heim_ntlm_v1_base_session()
1158 EVP_DigestFinal_ex(m, session->data, NULL); in heim_ntlm_v1_base_session()
1172 if (ntlmResponse->length <= 16) in heim_ntlm_v2_base_session()
1175 session->data = malloc(16); in heim_ntlm_v2_base_session()
1176 if (session->data == NULL) in heim_ntlm_v2_base_session()
1178 session->length = 16; in heim_ntlm_v2_base_session()
1187 HMAC_Update(c, ntlmResponse->data, 16); in heim_ntlm_v2_base_session()
1188 HMAC_Final(c, session->data, &hmaclen); in heim_ntlm_v2_base_session()
1203 session->length = MD4_DIGEST_LENGTH; in heim_ntlm_keyex_wrap()
1204 session->data = malloc(session->length); in heim_ntlm_keyex_wrap()
1205 if (session->data == NULL) { in heim_ntlm_keyex_wrap()
1206 session->length = 0; in heim_ntlm_keyex_wrap()
1209 encryptedSession->length = MD4_DIGEST_LENGTH; in heim_ntlm_keyex_wrap()
1210 encryptedSession->data = malloc(encryptedSession->length); in heim_ntlm_keyex_wrap()
1211 if (encryptedSession->data == NULL) { in heim_ntlm_keyex_wrap()
1213 encryptedSession->length = 0; in heim_ntlm_keyex_wrap()
1224 ret = EVP_CipherInit_ex(c, EVP_rc4(), NULL, base_session->data, NULL, 1); in heim_ntlm_keyex_wrap()
1232 if (RAND_bytes(session->data, session->length) != 1) { in heim_ntlm_keyex_wrap()
1239 EVP_Cipher(c, encryptedSession->data, session->data, encryptedSession->length); in heim_ntlm_keyex_wrap()
1339 if (baseKey->length != MD4_DIGEST_LENGTH) in heim_ntlm_keyex_unwrap()
1342 session->length = MD4_DIGEST_LENGTH; in heim_ntlm_keyex_unwrap()
1343 session->data = malloc(session->length); in heim_ntlm_keyex_unwrap()
1344 if (session->data == NULL) { in heim_ntlm_keyex_unwrap()
1345 session->length = 0; in heim_ntlm_keyex_unwrap()
1354 if (EVP_CipherInit_ex(c, EVP_rc4(), NULL, baseKey->data, NULL, 0) != 1) { in heim_ntlm_keyex_unwrap()
1360 EVP_Cipher(c, session->data, encryptedSession->data, session->length); in heim_ntlm_keyex_unwrap()
1397 /* uppercase username and turn it into ucs2-le */ in heim_ntlm_ntlmv2_key()
1400 goto out; in heim_ntlm_ntlmv2_key()
1401 HMAC_Update(c, buf.data, buf.length); in heim_ntlm_ntlmv2_key()
1402 free(buf.data); in heim_ntlm_ntlmv2_key()
1403 /* uppercase target and turn into ucs2-le */ in heim_ntlm_ntlmv2_key()
1406 goto out; in heim_ntlm_ntlmv2_key()
1407 HMAC_Update(c, buf.data, buf.length); in heim_ntlm_ntlmv2_key()
1408 free(buf.data); in heim_ntlm_ntlmv2_key()
1411 out: in heim_ntlm_ntlmv2_key()
1434 t = ((t - (uint64_t)NTTIME_EPOCH) / (uint64_t)10000000); in nt2unixtime()
1475 answer->data = malloc(24); in heim_ntlm_calculate_lm2()
1476 if (answer->data == NULL) in heim_ntlm_calculate_lm2()
1478 answer->length = 24; in heim_ntlm_calculate_lm2()
1481 serverchallenge, answer->data); in heim_ntlm_calculate_lm2()
1485 memcpy(((uint8_t *)answer->data) + 16, clientchallenge, 8); in heim_ntlm_calculate_lm2()
1519 krb5_data data; in heim_ntlm_calculate_ntlm2() local
1551 CHECK(krb5_storage_write(sp, infotarget->data, infotarget->length), in heim_ntlm_calculate_ntlm2()
1552 infotarget->length); in heim_ntlm_calculate_ntlm2()
1555 CHECK(krb5_storage_to_data(sp, &data), 0); in heim_ntlm_calculate_ntlm2()
1559 … code = heim_ntlm_derive_ntlm2_sess(ntlmv2, data.data, data.length, serverchallenge, ntlmv2answer); in heim_ntlm_calculate_ntlm2()
1561 krb5_data_free(&data); in heim_ntlm_calculate_ntlm2()
1567 krb5_data_free(&data); in heim_ntlm_calculate_ntlm2()
1572 CHECK(krb5_storage_write(sp, data.data, data.length), data.length); in heim_ntlm_calculate_ntlm2()
1573 krb5_data_free(&data); in heim_ntlm_calculate_ntlm2()
1575 CHECK(krb5_storage_to_data(sp, &data), 0); in heim_ntlm_calculate_ntlm2()
1579 answer->data = data.data; in heim_ntlm_calculate_ntlm2()
1580 answer->length = data.length; in heim_ntlm_calculate_ntlm2()
1583 out: in heim_ntlm_calculate_ntlm2()
1630 infotarget->length = 0; in heim_ntlm_verify_ntlm2()
1631 infotarget->data = NULL; in heim_ntlm_verify_ntlm2()
1633 if (answer->length < 16) in heim_ntlm_verify_ntlm2()
1645 sp = krb5_storage_from_readonly_mem(answer->data, answer->length); in heim_ntlm_verify_ntlm2()
1664 if (abs((int)(authtime - now)) > authtimediff) { in heim_ntlm_verify_ntlm2()
1666 goto out; in heim_ntlm_verify_ntlm2()
1675 infotarget->length = answer->length - krb5_storage_seek(sp, 0, SEEK_CUR); in heim_ntlm_verify_ntlm2()
1676 infotarget->data = malloc(infotarget->length); in heim_ntlm_verify_ntlm2()
1677 if (infotarget->data == NULL) { in heim_ntlm_verify_ntlm2()
1679 goto out; in heim_ntlm_verify_ntlm2()
1681 CHECK(krb5_storage_read(sp, infotarget->data, infotarget->length), in heim_ntlm_verify_ntlm2()
1682 infotarget->length); in heim_ntlm_verify_ntlm2()
1687 if (answer->length < 16) { in heim_ntlm_verify_ntlm2()
1689 goto out; in heim_ntlm_verify_ntlm2()
1693 ((unsigned char *)answer->data) + 16, answer->length - 16, in heim_ntlm_verify_ntlm2()
1697 goto out; in heim_ntlm_verify_ntlm2()
1705 out: in heim_ntlm_verify_ntlm2()
1745 lm->data = malloc(24); in heim_ntlm_calculate_ntlm2_sess()
1746 if (lm->data == NULL) { in heim_ntlm_calculate_ntlm2_sess()
1749 lm->length = 24; in heim_ntlm_calculate_ntlm2_sess()
1751 ntlm->data = malloc(24); in heim_ntlm_calculate_ntlm2_sess()
1752 if (ntlm->data == NULL) { in heim_ntlm_calculate_ntlm2_sess()
1753 free(lm->data); in heim_ntlm_calculate_ntlm2_sess()
1754 lm->data = NULL; in heim_ntlm_calculate_ntlm2_sess()
1757 ntlm->length = 24; in heim_ntlm_calculate_ntlm2_sess()
1760 memset(lm->data, 0, 24); in heim_ntlm_calculate_ntlm2_sess()
1761 memcpy(lm->data, clnt_nonce, 8); in heim_ntlm_calculate_ntlm2_sess()
1766 resp = ntlm->data; in heim_ntlm_calculate_ntlm2_sess()
1769 goto out; in heim_ntlm_calculate_ntlm2_sess()
1772 goto out; in heim_ntlm_calculate_ntlm2_sess()
1775 goto out; in heim_ntlm_calculate_ntlm2_sess()
1779 out: in heim_ntlm_calculate_ntlm2_sess()