2 * Copyright (c) 1997-2006 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the Institute nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
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
34 #include "krb5_locl.h"
35 #include "store-int.h"
37 __RCSID("$Heimdal: store.c 22071 2007-11-14 20:04:50Z lha $"
40 #define BYTEORDER_IS(SP, V) (((SP)->flags & KRB5_STORAGE_BYTEORDER_MASK) == (V))
41 #define BYTEORDER_IS_LE(SP) BYTEORDER_IS((SP), KRB5_STORAGE_BYTEORDER_LE)
42 #define BYTEORDER_IS_BE(SP) BYTEORDER_IS((SP), KRB5_STORAGE_BYTEORDER_BE)
43 #define BYTEORDER_IS_HOST(SP) (BYTEORDER_IS((SP), KRB5_STORAGE_BYTEORDER_HOST) || \
44 krb5_storage_is_flags((SP), KRB5_STORAGE_HOST_BYTEORDER))
46 void KRB5_LIB_FUNCTION
47 krb5_storage_set_flags(krb5_storage
*sp
, krb5_flags flags
)
52 void KRB5_LIB_FUNCTION
53 krb5_storage_clear_flags(krb5_storage
*sp
, krb5_flags flags
)
58 krb5_boolean KRB5_LIB_FUNCTION
59 krb5_storage_is_flags(krb5_storage
*sp
, krb5_flags flags
)
61 return (sp
->flags
& flags
) == flags
;
64 void KRB5_LIB_FUNCTION
65 krb5_storage_set_byteorder(krb5_storage
*sp
, krb5_flags byteorder
)
67 sp
->flags
&= ~KRB5_STORAGE_BYTEORDER_MASK
;
68 sp
->flags
|= byteorder
;
71 krb5_flags KRB5_LIB_FUNCTION
72 krb5_storage_get_byteorder(krb5_storage
*sp
, krb5_flags byteorder
)
74 return sp
->flags
& KRB5_STORAGE_BYTEORDER_MASK
;
77 off_t KRB5_LIB_FUNCTION
78 krb5_storage_seek(krb5_storage
*sp
, off_t offset
, int whence
)
80 return (*sp
->seek
)(sp
, offset
, whence
);
83 krb5_ssize_t KRB5_LIB_FUNCTION
84 krb5_storage_read(krb5_storage
*sp
, void *buf
, size_t len
)
86 return sp
->fetch(sp
, buf
, len
);
89 krb5_ssize_t KRB5_LIB_FUNCTION
90 krb5_storage_write(krb5_storage
*sp
, const void *buf
, size_t len
)
92 return sp
->store(sp
, buf
, len
);
95 void KRB5_LIB_FUNCTION
96 krb5_storage_set_eof_code(krb5_storage
*sp
, int code
)
101 krb5_ssize_t KRB5_LIB_FUNCTION
102 _krb5_put_int(void *buffer
, unsigned long value
, size_t size
)
104 unsigned char *p
= buffer
;
106 for (i
= size
- 1; i
>= 0; i
--) {
113 krb5_ssize_t KRB5_LIB_FUNCTION
114 _krb5_get_int(void *buffer
, unsigned long *value
, size_t size
)
116 unsigned char *p
= buffer
;
119 for (i
= 0; i
< size
; i
++)
125 krb5_error_code KRB5_LIB_FUNCTION
126 krb5_storage_free(krb5_storage
*sp
)
135 krb5_error_code KRB5_LIB_FUNCTION
136 krb5_storage_to_data(krb5_storage
*sp
, krb5_data
*data
)
142 pos
= sp
->seek(sp
, 0, SEEK_CUR
);
143 size
= (size_t)sp
->seek(sp
, 0, SEEK_END
);
144 ret
= krb5_data_alloc (data
, size
);
146 sp
->seek(sp
, pos
, SEEK_SET
);
150 sp
->seek(sp
, 0, SEEK_SET
);
151 sp
->fetch(sp
, data
->data
, data
->length
);
152 sp
->seek(sp
, pos
, SEEK_SET
);
157 static krb5_error_code
158 krb5_store_int(krb5_storage
*sp
,
167 _krb5_put_int(v
, value
, len
);
168 ret
= sp
->store(sp
, v
, len
);
170 return (ret
<0)?errno
:sp
->eof_code
;
174 krb5_error_code KRB5_LIB_FUNCTION
175 krb5_store_int32(krb5_storage
*sp
,
178 if(BYTEORDER_IS_HOST(sp
))
179 value
= htonl(value
);
180 else if(BYTEORDER_IS_LE(sp
))
181 value
= bswap32(value
);
182 return krb5_store_int(sp
, value
, 4);
185 krb5_error_code KRB5_LIB_FUNCTION
186 krb5_store_uint32(krb5_storage
*sp
,
189 return krb5_store_int32(sp
, (int32_t)value
);
192 static krb5_error_code
193 krb5_ret_int(krb5_storage
*sp
,
200 ret
= sp
->fetch(sp
, v
, len
);
202 return (ret
<0)?errno
:sp
->eof_code
;
203 _krb5_get_int(v
, &w
, len
);
208 krb5_error_code KRB5_LIB_FUNCTION
209 krb5_ret_int32(krb5_storage
*sp
,
212 krb5_error_code ret
= krb5_ret_int(sp
, value
, 4);
215 if(BYTEORDER_IS_HOST(sp
))
216 *value
= htonl(*value
);
217 else if(BYTEORDER_IS_LE(sp
))
218 *value
= bswap32(*value
);
222 krb5_error_code KRB5_LIB_FUNCTION
223 krb5_ret_uint32(krb5_storage
*sp
,
229 ret
= krb5_ret_int32(sp
, &v
);
231 *value
= (uint32_t)v
;
236 krb5_error_code KRB5_LIB_FUNCTION
237 krb5_store_int16(krb5_storage
*sp
,
240 if(BYTEORDER_IS_HOST(sp
))
241 value
= htons(value
);
242 else if(BYTEORDER_IS_LE(sp
))
243 value
= bswap16(value
);
244 return krb5_store_int(sp
, value
, 2);
247 krb5_error_code KRB5_LIB_FUNCTION
248 krb5_store_uint16(krb5_storage
*sp
,
251 return krb5_store_int16(sp
, (int16_t)value
);
254 krb5_error_code KRB5_LIB_FUNCTION
255 krb5_ret_int16(krb5_storage
*sp
,
260 ret
= krb5_ret_int(sp
, &v
, 2);
264 if(BYTEORDER_IS_HOST(sp
))
265 *value
= htons(*value
);
266 else if(BYTEORDER_IS_LE(sp
))
267 *value
= bswap16(*value
);
271 krb5_error_code KRB5_LIB_FUNCTION
272 krb5_ret_uint16(krb5_storage
*sp
,
278 ret
= krb5_ret_int16(sp
, &v
);
280 *value
= (uint16_t)v
;
285 krb5_error_code KRB5_LIB_FUNCTION
286 krb5_store_int8(krb5_storage
*sp
,
291 ret
= sp
->store(sp
, &value
, sizeof(value
));
292 if (ret
!= sizeof(value
))
293 return (ret
<0)?errno
:sp
->eof_code
;
297 krb5_error_code KRB5_LIB_FUNCTION
298 krb5_store_uint8(krb5_storage
*sp
,
301 return krb5_store_int8(sp
, (int8_t)value
);
304 krb5_error_code KRB5_LIB_FUNCTION
305 krb5_ret_int8(krb5_storage
*sp
,
310 ret
= sp
->fetch(sp
, value
, sizeof(*value
));
311 if (ret
!= sizeof(*value
))
312 return (ret
<0)?errno
:sp
->eof_code
;
316 krb5_error_code KRB5_LIB_FUNCTION
317 krb5_ret_uint8(krb5_storage
*sp
,
323 ret
= krb5_ret_int8(sp
, &v
);
330 krb5_error_code KRB5_LIB_FUNCTION
331 krb5_store_data(krb5_storage
*sp
,
335 ret
= krb5_store_int32(sp
, data
.length
);
338 ret
= sp
->store(sp
, data
.data
, data
.length
);
339 if(ret
!= data
.length
){
347 krb5_error_code KRB5_LIB_FUNCTION
348 krb5_ret_data(krb5_storage
*sp
,
354 ret
= krb5_ret_int32(sp
, &size
);
357 ret
= krb5_data_alloc (data
, size
);
361 ret
= sp
->fetch(sp
, data
->data
, size
);
363 return (ret
< 0)? errno
: sp
->eof_code
;
368 krb5_error_code KRB5_LIB_FUNCTION
369 krb5_store_string(krb5_storage
*sp
, const char *s
)
372 data
.length
= strlen(s
);
373 data
.data
= rk_UNCONST(s
);
374 return krb5_store_data(sp
, data
);
377 krb5_error_code KRB5_LIB_FUNCTION
378 krb5_ret_string(krb5_storage
*sp
,
383 ret
= krb5_ret_data(sp
, &data
);
386 *string
= realloc(data
.data
, data
.length
+ 1);
391 (*string
)[data
.length
] = 0;
395 krb5_error_code KRB5_LIB_FUNCTION
396 krb5_store_stringz(krb5_storage
*sp
, const char *s
)
398 size_t len
= strlen(s
) + 1;
401 ret
= sp
->store(sp
, s
, len
);
411 krb5_error_code KRB5_LIB_FUNCTION
412 krb5_ret_stringz(krb5_storage
*sp
,
420 while((ret
= sp
->fetch(sp
, &c
, 1)) == 1){
424 tmp
= realloc (s
, len
);
444 krb5_error_code KRB5_LIB_FUNCTION
445 krb5_store_stringnl(krb5_storage
*sp
, const char *s
)
447 size_t len
= strlen(s
);
450 ret
= sp
->store(sp
, s
, len
);
457 ret
= sp
->store(sp
, "\n", 1);
469 krb5_error_code KRB5_LIB_FUNCTION
470 krb5_ret_stringnl(krb5_storage
*sp
,
479 while((ret
= sp
->fetch(sp
, &c
, 1)) == 1){
486 if (expect_nl
&& c
!= '\n') {
488 return KRB5_BADMSGTYPE
;
492 tmp
= realloc (s
, len
);
515 krb5_error_code KRB5_LIB_FUNCTION
516 krb5_store_principal(krb5_storage
*sp
,
517 krb5_const_principal p
)
522 if(!krb5_storage_is_flags(sp
, KRB5_STORAGE_PRINCIPAL_NO_NAME_TYPE
)) {
523 ret
= krb5_store_int32(sp
, p
->name
.name_type
);
526 if(krb5_storage_is_flags(sp
, KRB5_STORAGE_PRINCIPAL_WRONG_NUM_COMPONENTS
))
527 ret
= krb5_store_int32(sp
, p
->name
.name_string
.len
+ 1);
529 ret
= krb5_store_int32(sp
, p
->name
.name_string
.len
);
532 ret
= krb5_store_string(sp
, p
->realm
);
534 for(i
= 0; i
< p
->name
.name_string
.len
; i
++){
535 ret
= krb5_store_string(sp
, p
->name
.name_string
.val
[i
]);
541 krb5_error_code KRB5_LIB_FUNCTION
542 krb5_ret_principal(krb5_storage
*sp
,
543 krb5_principal
*princ
)
551 p
= calloc(1, sizeof(*p
));
555 if(krb5_storage_is_flags(sp
, KRB5_STORAGE_PRINCIPAL_NO_NAME_TYPE
))
556 type
= KRB5_NT_UNKNOWN
;
557 else if((ret
= krb5_ret_int32(sp
, &type
))){
561 if((ret
= krb5_ret_int32(sp
, &ncomp
))){
565 if(krb5_storage_is_flags(sp
, KRB5_STORAGE_PRINCIPAL_WRONG_NUM_COMPONENTS
))
571 p
->name
.name_type
= type
;
572 p
->name
.name_string
.len
= ncomp
;
573 ret
= krb5_ret_string(sp
, &p
->realm
);
578 p
->name
.name_string
.val
= calloc(ncomp
, sizeof(*p
->name
.name_string
.val
));
579 if(p
->name
.name_string
.val
== NULL
&& ncomp
!= 0){
584 for(i
= 0; i
< ncomp
; i
++){
585 ret
= krb5_ret_string(sp
, &p
->name
.name_string
.val
[i
]);
588 free(p
->name
.name_string
.val
[i
--]);
598 krb5_error_code KRB5_LIB_FUNCTION
599 krb5_store_keyblock(krb5_storage
*sp
, krb5_keyblock p
)
602 ret
= krb5_store_int16(sp
, p
.keytype
);
605 if(krb5_storage_is_flags(sp
, KRB5_STORAGE_KEYBLOCK_KEYTYPE_TWICE
)){
606 /* this should really be enctype, but it is the same as
608 ret
= krb5_store_int16(sp
, p
.keytype
);
612 ret
= krb5_store_data(sp
, p
.keyvalue
);
616 krb5_error_code KRB5_LIB_FUNCTION
617 krb5_ret_keyblock(krb5_storage
*sp
, krb5_keyblock
*p
)
622 ret
= krb5_ret_int16(sp
, &tmp
);
626 if(krb5_storage_is_flags(sp
, KRB5_STORAGE_KEYBLOCK_KEYTYPE_TWICE
)){
627 ret
= krb5_ret_int16(sp
, &tmp
);
631 ret
= krb5_ret_data(sp
, &p
->keyvalue
);
635 krb5_error_code KRB5_LIB_FUNCTION
636 krb5_store_times(krb5_storage
*sp
, krb5_times times
)
639 ret
= krb5_store_int32(sp
, times
.authtime
);
641 ret
= krb5_store_int32(sp
, times
.starttime
);
643 ret
= krb5_store_int32(sp
, times
.endtime
);
645 ret
= krb5_store_int32(sp
, times
.renew_till
);
649 krb5_error_code KRB5_LIB_FUNCTION
650 krb5_ret_times(krb5_storage
*sp
, krb5_times
*times
)
654 ret
= krb5_ret_int32(sp
, &tmp
);
655 times
->authtime
= tmp
;
657 ret
= krb5_ret_int32(sp
, &tmp
);
658 times
->starttime
= tmp
;
660 ret
= krb5_ret_int32(sp
, &tmp
);
661 times
->endtime
= tmp
;
663 ret
= krb5_ret_int32(sp
, &tmp
);
664 times
->renew_till
= tmp
;
668 krb5_error_code KRB5_LIB_FUNCTION
669 krb5_store_address(krb5_storage
*sp
, krb5_address p
)
672 ret
= krb5_store_int16(sp
, p
.addr_type
);
674 ret
= krb5_store_data(sp
, p
.address
);
678 krb5_error_code KRB5_LIB_FUNCTION
679 krb5_ret_address(krb5_storage
*sp
, krb5_address
*adr
)
683 ret
= krb5_ret_int16(sp
, &t
);
686 ret
= krb5_ret_data(sp
, &adr
->address
);
690 krb5_error_code KRB5_LIB_FUNCTION
691 krb5_store_addrs(krb5_storage
*sp
, krb5_addresses p
)
695 ret
= krb5_store_int32(sp
, p
.len
);
697 for(i
= 0; i
<p
.len
; i
++){
698 ret
= krb5_store_address(sp
, p
.val
[i
]);
704 krb5_error_code KRB5_LIB_FUNCTION
705 krb5_ret_addrs(krb5_storage
*sp
, krb5_addresses
*adr
)
711 ret
= krb5_ret_int32(sp
, &tmp
);
714 ALLOC(adr
->val
, adr
->len
);
715 if (adr
->val
== NULL
&& adr
->len
!= 0)
717 for(i
= 0; i
< adr
->len
; i
++){
718 ret
= krb5_ret_address(sp
, &adr
->val
[i
]);
724 krb5_error_code KRB5_LIB_FUNCTION
725 krb5_store_authdata(krb5_storage
*sp
, krb5_authdata auth
)
729 ret
= krb5_store_int32(sp
, auth
.len
);
731 for(i
= 0; i
< auth
.len
; i
++){
732 ret
= krb5_store_int16(sp
, auth
.val
[i
].ad_type
);
734 ret
= krb5_store_data(sp
, auth
.val
[i
].ad_data
);
740 krb5_error_code KRB5_LIB_FUNCTION
741 krb5_ret_authdata(krb5_storage
*sp
, krb5_authdata
*auth
)
747 ret
= krb5_ret_int32(sp
, &tmp
);
749 ALLOC_SEQ(auth
, tmp
);
750 if (auth
->val
== NULL
&& tmp
!= 0)
752 for(i
= 0; i
< tmp
; i
++){
753 ret
= krb5_ret_int16(sp
, &tmp2
);
755 auth
->val
[i
].ad_type
= tmp2
;
756 ret
= krb5_ret_data(sp
, &auth
->val
[i
].ad_data
);
767 for (i
= 0; i
< 32; i
++) {
768 r
= r
<< 1 | (b
& 1);
779 krb5_error_code KRB5_LIB_FUNCTION
780 krb5_store_creds(krb5_storage
*sp
, krb5_creds
*creds
)
784 ret
= krb5_store_principal(sp
, creds
->client
);
787 ret
= krb5_store_principal(sp
, creds
->server
);
790 ret
= krb5_store_keyblock(sp
, creds
->session
);
793 ret
= krb5_store_times(sp
, creds
->times
);
796 ret
= krb5_store_int8(sp
, creds
->second_ticket
.length
!= 0); /* is_skey */
800 if(krb5_storage_is_flags(sp
, KRB5_STORAGE_CREDS_FLAGS_WRONG_BITORDER
))
801 ret
= krb5_store_int32(sp
, creds
->flags
.i
);
803 ret
= krb5_store_int32(sp
, bitswap32(TicketFlags2int(creds
->flags
.b
)));
807 ret
= krb5_store_addrs(sp
, creds
->addresses
);
810 ret
= krb5_store_authdata(sp
, creds
->authdata
);
813 ret
= krb5_store_data(sp
, creds
->ticket
);
816 ret
= krb5_store_data(sp
, creds
->second_ticket
);
820 krb5_error_code KRB5_LIB_FUNCTION
821 krb5_ret_creds(krb5_storage
*sp
, krb5_creds
*creds
)
827 memset(creds
, 0, sizeof(*creds
));
828 ret
= krb5_ret_principal (sp
, &creds
->client
);
829 if(ret
) goto cleanup
;
830 ret
= krb5_ret_principal (sp
, &creds
->server
);
831 if(ret
) goto cleanup
;
832 ret
= krb5_ret_keyblock (sp
, &creds
->session
);
833 if(ret
) goto cleanup
;
834 ret
= krb5_ret_times (sp
, &creds
->times
);
835 if(ret
) goto cleanup
;
836 ret
= krb5_ret_int8 (sp
, &dummy8
);
837 if(ret
) goto cleanup
;
838 ret
= krb5_ret_int32 (sp
, &dummy32
);
839 if(ret
) goto cleanup
;
841 * Runtime detect the what is the higher bits of the bitfield. If
842 * any of the higher bits are set in the input data, it's either a
843 * new ticket flag (and this code need to be removed), or it's a
844 * MIT cache (or new Heimdal cache), lets change it to our current
848 uint32_t mask
= 0xffff0000;
850 creds
->flags
.b
.anonymous
= 1;
851 if (creds
->flags
.i
& mask
)
854 dummy32
= bitswap32(dummy32
);
856 creds
->flags
.i
= dummy32
;
857 ret
= krb5_ret_addrs (sp
, &creds
->addresses
);
858 if(ret
) goto cleanup
;
859 ret
= krb5_ret_authdata (sp
, &creds
->authdata
);
860 if(ret
) goto cleanup
;
861 ret
= krb5_ret_data (sp
, &creds
->ticket
);
862 if(ret
) goto cleanup
;
863 ret
= krb5_ret_data (sp
, &creds
->second_ticket
);
867 krb5_free_cred_contents(context
, creds
); /* XXX */
873 #define SC_CLIENT_PRINCIPAL 0x0001
874 #define SC_SERVER_PRINCIPAL 0x0002
875 #define SC_SESSION_KEY 0x0004
876 #define SC_TICKET 0x0008
877 #define SC_SECOND_TICKET 0x0010
878 #define SC_AUTHDATA 0x0020
879 #define SC_ADDRESSES 0x0040
885 krb5_error_code KRB5_LIB_FUNCTION
886 krb5_store_creds_tag(krb5_storage
*sp
, krb5_creds
*creds
)
892 header
|= SC_CLIENT_PRINCIPAL
;
894 header
|= SC_SERVER_PRINCIPAL
;
895 if (creds
->session
.keytype
!= ETYPE_NULL
)
896 header
|= SC_SESSION_KEY
;
897 if (creds
->ticket
.data
)
899 if (creds
->second_ticket
.length
)
900 header
|= SC_SECOND_TICKET
;
901 if (creds
->authdata
.len
)
902 header
|= SC_AUTHDATA
;
903 if (creds
->addresses
.len
)
904 header
|= SC_ADDRESSES
;
906 ret
= krb5_store_int32(sp
, header
);
909 ret
= krb5_store_principal(sp
, creds
->client
);
915 ret
= krb5_store_principal(sp
, creds
->server
);
920 if (creds
->session
.keytype
!= ETYPE_NULL
) {
921 ret
= krb5_store_keyblock(sp
, creds
->session
);
926 ret
= krb5_store_times(sp
, creds
->times
);
929 ret
= krb5_store_int8(sp
, creds
->second_ticket
.length
!= 0); /* is_skey */
933 ret
= krb5_store_int32(sp
, bitswap32(TicketFlags2int(creds
->flags
.b
)));
937 if (creds
->addresses
.len
) {
938 ret
= krb5_store_addrs(sp
, creds
->addresses
);
943 if (creds
->authdata
.len
) {
944 ret
= krb5_store_authdata(sp
, creds
->authdata
);
949 if (creds
->ticket
.data
) {
950 ret
= krb5_store_data(sp
, creds
->ticket
);
955 if (creds
->second_ticket
.data
) {
956 ret
= krb5_store_data(sp
, creds
->second_ticket
);
964 krb5_error_code KRB5_LIB_FUNCTION
965 krb5_ret_creds_tag(krb5_storage
*sp
,
970 int32_t dummy32
, header
;
972 memset(creds
, 0, sizeof(*creds
));
974 ret
= krb5_ret_int32 (sp
, &header
);
975 if (ret
) goto cleanup
;
977 if (header
& SC_CLIENT_PRINCIPAL
) {
978 ret
= krb5_ret_principal (sp
, &creds
->client
);
979 if(ret
) goto cleanup
;
981 if (header
& SC_SERVER_PRINCIPAL
) {
982 ret
= krb5_ret_principal (sp
, &creds
->server
);
983 if(ret
) goto cleanup
;
985 if (header
& SC_SESSION_KEY
) {
986 ret
= krb5_ret_keyblock (sp
, &creds
->session
);
987 if(ret
) goto cleanup
;
989 ret
= krb5_ret_times (sp
, &creds
->times
);
990 if(ret
) goto cleanup
;
991 ret
= krb5_ret_int8 (sp
, &dummy8
);
992 if(ret
) goto cleanup
;
993 ret
= krb5_ret_int32 (sp
, &dummy32
);
994 if(ret
) goto cleanup
;
996 * Runtime detect the what is the higher bits of the bitfield. If
997 * any of the higher bits are set in the input data, it's either a
998 * new ticket flag (and this code need to be removed), or it's a
999 * MIT cache (or new Heimdal cache), lets change it to our current
1003 uint32_t mask
= 0xffff0000;
1005 creds
->flags
.b
.anonymous
= 1;
1006 if (creds
->flags
.i
& mask
)
1009 dummy32
= bitswap32(dummy32
);
1011 creds
->flags
.i
= dummy32
;
1012 if (header
& SC_ADDRESSES
) {
1013 ret
= krb5_ret_addrs (sp
, &creds
->addresses
);
1014 if(ret
) goto cleanup
;
1016 if (header
& SC_AUTHDATA
) {
1017 ret
= krb5_ret_authdata (sp
, &creds
->authdata
);
1018 if(ret
) goto cleanup
;
1020 if (header
& SC_TICKET
) {
1021 ret
= krb5_ret_data (sp
, &creds
->ticket
);
1022 if(ret
) goto cleanup
;
1024 if (header
& SC_SECOND_TICKET
) {
1025 ret
= krb5_ret_data (sp
, &creds
->second_ticket
);
1026 if(ret
) goto cleanup
;
1032 krb5_free_cred_contents(context
, creds
); /* XXX */