Deleted Added
full compact
get_cred.c (102644) get_cred.c (103423)
1/*
2 * Copyright (c) 1997 - 2002 Kungliga Tekniska H�gskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 19 unchanged lines hidden (view full) ---

28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#include <krb5_locl.h>
35
1/*
2 * Copyright (c) 1997 - 2002 Kungliga Tekniska H�gskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 19 unchanged lines hidden (view full) ---

28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#include <krb5_locl.h>
35
36RCSID("$Id: get_cred.c,v 1.88 2002/03/10 23:11:29 assar Exp $");
36RCSID("$Id: get_cred.c,v 1.91 2002/09/04 21:12:46 joda Exp $");
37
38/*
39 * Take the `body' and encode it into `padata' using the credentials
40 * in `creds'.
41 */
42
43static krb5_error_code
44make_pa_tgs_req(krb5_context context,

--- 4 unchanged lines hidden (view full) ---

49 krb5_key_usage usage)
50{
51 u_char *buf;
52 size_t buf_size;
53 size_t len;
54 krb5_data in_data;
55 krb5_error_code ret;
56
37
38/*
39 * Take the `body' and encode it into `padata' using the credentials
40 * in `creds'.
41 */
42
43static krb5_error_code
44make_pa_tgs_req(krb5_context context,

--- 4 unchanged lines hidden (view full) ---

49 krb5_key_usage usage)
50{
51 u_char *buf;
52 size_t buf_size;
53 size_t len;
54 krb5_data in_data;
55 krb5_error_code ret;
56
57 buf_size = 1024;
58 buf = malloc (buf_size);
59 if (buf == NULL) {
60 krb5_set_error_string(context, "malloc: out of memory");
61 return ENOMEM;
62 }
57 ASN1_MALLOC_ENCODE(KDC_REQ_BODY, buf, buf_size, body, &len, ret);
58 if (ret)
59 goto out;
60 if(buf_size != len)
61 krb5_abortx(context, "internal error in ASN.1 encoder");
63
62
64 do {
65 ret = encode_KDC_REQ_BODY(buf + buf_size - 1, buf_size,
66 body, &len);
67 if (ret){
68 if (ret == ASN1_OVERFLOW) {
69 u_char *tmp;
70
71 buf_size *= 2;
72 tmp = realloc (buf, buf_size);
73 if (tmp == NULL) {
74 krb5_set_error_string(context, "malloc: out of memory");
75 ret = ENOMEM;
76 goto out;
77 }
78 buf = tmp;
79 } else {
80 goto out;
81 }
82 }
83 } while (ret == ASN1_OVERFLOW);
84
85 in_data.length = len;
63 in_data.length = len;
86 in_data.data = buf + buf_size - len;
64 in_data.data = buf;
87 ret = krb5_mk_req_internal(context, &ac, 0, &in_data, creds,
88 &padata->padata_value,
89 KRB5_KU_TGS_REQ_AUTH_CKSUM,
90 usage
91 /* KRB5_KU_TGS_REQ_AUTH */);
92out:
93 free (buf);
94 if(ret)

--- 13 unchanged lines hidden (view full) ---

108 krb5_keyblock *key)
109{
110 if(authdata->len) {
111 size_t len;
112 unsigned char *buf;
113 krb5_crypto crypto;
114 krb5_error_code ret;
115
65 ret = krb5_mk_req_internal(context, &ac, 0, &in_data, creds,
66 &padata->padata_value,
67 KRB5_KU_TGS_REQ_AUTH_CKSUM,
68 usage
69 /* KRB5_KU_TGS_REQ_AUTH */);
70out:
71 free (buf);
72 if(ret)

--- 13 unchanged lines hidden (view full) ---

86 krb5_keyblock *key)
87{
88 if(authdata->len) {
89 size_t len;
90 unsigned char *buf;
91 krb5_crypto crypto;
92 krb5_error_code ret;
93
116 len = length_AuthorizationData(authdata);
117 buf = malloc(len);
118 if (buf == NULL) {
119 krb5_set_error_string(context, "malloc: out of memory");
120 return ENOMEM;
121 }
122 ret = encode_AuthorizationData(buf + len - 1,
123 len, authdata, &len);
124 if (ret) {
125 free (buf);
94 ASN1_MALLOC_ENCODE(AuthorizationData, buf, len, authdata, &len, ret);
95 if (ret)
126 return ret;
96 return ret;
127 }
128
129 ALLOC(req_body->enc_authorization_data, 1);
130 if (req_body->enc_authorization_data == NULL) {
131 free (buf);
132 krb5_set_error_string(context, "malloc: out of memory");
133 return ENOMEM;
134 }
135 ret = krb5_crypto_init(context, key, 0, &crypto);

--- 32 unchanged lines hidden (view full) ---

168 Ticket *second_ticket,
169 krb5_creds *in_creds,
170 krb5_creds *krbtgt,
171 unsigned nonce,
172 krb5_keyblock **subkey,
173 TGS_REQ *t,
174 krb5_key_usage usage)
175{
97
98 ALLOC(req_body->enc_authorization_data, 1);
99 if (req_body->enc_authorization_data == NULL) {
100 free (buf);
101 krb5_set_error_string(context, "malloc: out of memory");
102 return ENOMEM;
103 }
104 ret = krb5_crypto_init(context, key, 0, &crypto);

--- 32 unchanged lines hidden (view full) ---

137 Ticket *second_ticket,
138 krb5_creds *in_creds,
139 krb5_creds *krbtgt,
140 unsigned nonce,
141 krb5_keyblock **subkey,
142 TGS_REQ *t,
143 krb5_key_usage usage)
144{
176 krb5_error_code ret;
145 krb5_error_code ret = 0;
177
178 memset(t, 0, sizeof(*t));
179 t->pvno = 5;
180 t->msg_type = krb_tgs_req;
181 if (in_creds->session.keytype) {
146
147 memset(t, 0, sizeof(*t));
148 t->pvno = 5;
149 t->msg_type = krb_tgs_req;
150 if (in_creds->session.keytype) {
182 ret = krb5_keytype_to_enctypes_default (context,
183 in_creds->session.keytype,
184 &t->req_body.etype.len,
185 &t->req_body.etype.val);
151 ALLOC_SEQ(&t->req_body.etype, 1);
152 if(t->req_body.etype.val == NULL) {
153 ret = ENOMEM;
154 krb5_set_error_string(context, "malloc: out of memory");
155 goto fail;
156 }
157 t->req_body.etype.val[0] = in_creds->session.keytype;
186 } else {
187 ret = krb5_init_etype(context,
188 &t->req_body.etype.len,
189 &t->req_body.etype.val,
190 NULL);
191 }
192 if (ret)
193 goto fail;

--- 232 unchanged lines hidden (view full) ---

426 &subkey,
427 &req,
428 usage);
429 if(flags.b.enc_tkt_in_skey)
430 free_Ticket(&second_ticket);
431 if (ret)
432 goto out;
433
158 } else {
159 ret = krb5_init_etype(context,
160 &t->req_body.etype.len,
161 &t->req_body.etype.val,
162 NULL);
163 }
164 if (ret)
165 goto fail;

--- 232 unchanged lines hidden (view full) ---

398 &subkey,
399 &req,
400 usage);
401 if(flags.b.enc_tkt_in_skey)
402 free_Ticket(&second_ticket);
403 if (ret)
404 goto out;
405
434 buf_size = 1024;
435 buf = malloc (buf_size);
436 if (buf == NULL) {
437 krb5_set_error_string(context, "malloc: out of memory");
438 ret = ENOMEM;
406 ASN1_MALLOC_ENCODE(TGS_REQ, buf, buf_size, &req, &enc.length, ret);
407 if (ret)
439 goto out;
408 goto out;
440 }
409 if(enc.length != buf_size)
410 krb5_abortx(context, "internal error in ASN.1 encoder");
441
411
442 do {
443 ret = encode_TGS_REQ (buf + buf_size - 1, buf_size,
444 &req, &enc.length);
445 if (ret) {
446 if (ret == ASN1_OVERFLOW) {
447 u_char *tmp;
448
449 buf_size *= 2;
450 tmp = realloc (buf, buf_size);
451 if (tmp == NULL) {
452 krb5_set_error_string(context, "malloc: out of memory");
453 ret = ENOMEM;
454 goto out;
455 }
456 buf = tmp;
457 } else {
458 goto out;
459 }
460 }
461 } while (ret == ASN1_OVERFLOW);
462
463 /* don't free addresses */
464 req.req_body.addresses = NULL;
465 free_TGS_REQ(&req);
466
467 enc.data = buf + buf_size - enc.length;
468 if (ret)
469 goto out;
470

--- 421 unchanged lines hidden ---
412 /* don't free addresses */
413 req.req_body.addresses = NULL;
414 free_TGS_REQ(&req);
415
416 enc.data = buf + buf_size - enc.length;
417 if (ret)
418 goto out;
419

--- 421 unchanged lines hidden ---