xref: /freebsd/crypto/krb5/src/tests/asn.1/ktest_equal.c (revision 7f2fe78b9dd5f51c821d771b63d2e096f6fd49e9)
1*7f2fe78bSCy Schubert /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2*7f2fe78bSCy Schubert /* tests/asn.1/ktest_equal.c */
3*7f2fe78bSCy Schubert /*
4*7f2fe78bSCy Schubert  * Copyright (C) 1994 by the Massachusetts Institute of Technology.
5*7f2fe78bSCy Schubert  * All rights reserved.
6*7f2fe78bSCy Schubert  *
7*7f2fe78bSCy Schubert  * Export of this software from the United States of America may
8*7f2fe78bSCy Schubert  *   require a specific license from the United States Government.
9*7f2fe78bSCy Schubert  *   It is the responsibility of any person or organization contemplating
10*7f2fe78bSCy Schubert  *   export to obtain such a license before exporting.
11*7f2fe78bSCy Schubert  *
12*7f2fe78bSCy Schubert  * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
13*7f2fe78bSCy Schubert  * distribute this software and its documentation for any purpose and
14*7f2fe78bSCy Schubert  * without fee is hereby granted, provided that the above copyright
15*7f2fe78bSCy Schubert  * notice appear in all copies and that both that copyright notice and
16*7f2fe78bSCy Schubert  * this permission notice appear in supporting documentation, and that
17*7f2fe78bSCy Schubert  * the name of M.I.T. not be used in advertising or publicity pertaining
18*7f2fe78bSCy Schubert  * to distribution of the software without specific, written prior
19*7f2fe78bSCy Schubert  * permission.  Furthermore if you modify this software you must label
20*7f2fe78bSCy Schubert  * your software as modified software and not distribute it in such a
21*7f2fe78bSCy Schubert  * fashion that it might be confused with the original M.I.T. software.
22*7f2fe78bSCy Schubert  * M.I.T. makes no representations about the suitability of
23*7f2fe78bSCy Schubert  * this software for any purpose.  It is provided "as is" without express
24*7f2fe78bSCy Schubert  * or implied warranty.
25*7f2fe78bSCy Schubert  */
26*7f2fe78bSCy Schubert 
27*7f2fe78bSCy Schubert #include <stdlib.h>
28*7f2fe78bSCy Schubert #include <stdio.h>
29*7f2fe78bSCy Schubert #include "ktest_equal.h"
30*7f2fe78bSCy Schubert 
31*7f2fe78bSCy Schubert #define FALSE 0
32*7f2fe78bSCy Schubert #define TRUE 1
33*7f2fe78bSCy Schubert 
34*7f2fe78bSCy Schubert #define struct_equal(field,comparator)          \
35*7f2fe78bSCy Schubert     comparator(&(ref->field),&(var->field))
36*7f2fe78bSCy Schubert 
37*7f2fe78bSCy Schubert #define ptr_equal(field,comparator)             \
38*7f2fe78bSCy Schubert     comparator(ref->field,var->field)
39*7f2fe78bSCy Schubert 
40*7f2fe78bSCy Schubert #define scalar_equal(field)                     \
41*7f2fe78bSCy Schubert     ((ref->field) == (var->field))
42*7f2fe78bSCy Schubert 
43*7f2fe78bSCy Schubert #define len_equal(length,field,comparator)              \
44*7f2fe78bSCy Schubert     ((ref->length == var->length) &&                    \
45*7f2fe78bSCy Schubert      comparator(ref->length,ref->field,var->field))
46*7f2fe78bSCy Schubert 
47*7f2fe78bSCy Schubert int
ktest_equal_authenticator(krb5_authenticator * ref,krb5_authenticator * var)48*7f2fe78bSCy Schubert ktest_equal_authenticator(krb5_authenticator *ref, krb5_authenticator *var)
49*7f2fe78bSCy Schubert {
50*7f2fe78bSCy Schubert     int p = TRUE;
51*7f2fe78bSCy Schubert 
52*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
53*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
54*7f2fe78bSCy Schubert     p = p && ptr_equal(client,ktest_equal_principal_data);
55*7f2fe78bSCy Schubert     p = p && ptr_equal(checksum,ktest_equal_checksum);
56*7f2fe78bSCy Schubert     p = p && scalar_equal(cusec);
57*7f2fe78bSCy Schubert     p = p && scalar_equal(ctime);
58*7f2fe78bSCy Schubert     p = p && ptr_equal(subkey,ktest_equal_keyblock);
59*7f2fe78bSCy Schubert     p = p && scalar_equal(seq_number);
60*7f2fe78bSCy Schubert     p = p && ptr_equal(authorization_data,ktest_equal_authorization_data);
61*7f2fe78bSCy Schubert     return p;
62*7f2fe78bSCy Schubert }
63*7f2fe78bSCy Schubert 
64*7f2fe78bSCy Schubert int
ktest_equal_principal_data(krb5_principal_data * ref,krb5_principal_data * var)65*7f2fe78bSCy Schubert ktest_equal_principal_data(krb5_principal_data *ref, krb5_principal_data *var)
66*7f2fe78bSCy Schubert {
67*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
68*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
69*7f2fe78bSCy Schubert     return(struct_equal(realm,ktest_equal_data) &&
70*7f2fe78bSCy Schubert            len_equal(length,data,ktest_equal_array_of_data) &&
71*7f2fe78bSCy Schubert            scalar_equal(type));
72*7f2fe78bSCy Schubert }
73*7f2fe78bSCy Schubert 
74*7f2fe78bSCy Schubert int
ktest_equal_authdata(krb5_authdata * ref,krb5_authdata * var)75*7f2fe78bSCy Schubert ktest_equal_authdata(krb5_authdata *ref, krb5_authdata *var)
76*7f2fe78bSCy Schubert {
77*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
78*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
79*7f2fe78bSCy Schubert     return(scalar_equal(ad_type) &&
80*7f2fe78bSCy Schubert            len_equal(length,contents,ktest_equal_array_of_octet));
81*7f2fe78bSCy Schubert }
82*7f2fe78bSCy Schubert 
83*7f2fe78bSCy Schubert int
ktest_equal_checksum(krb5_checksum * ref,krb5_checksum * var)84*7f2fe78bSCy Schubert ktest_equal_checksum(krb5_checksum *ref, krb5_checksum *var)
85*7f2fe78bSCy Schubert {
86*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
87*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
88*7f2fe78bSCy Schubert     return(scalar_equal(checksum_type) && len_equal(length,contents,ktest_equal_array_of_octet));
89*7f2fe78bSCy Schubert }
90*7f2fe78bSCy Schubert 
91*7f2fe78bSCy Schubert int
ktest_equal_keyblock(krb5_keyblock * ref,krb5_keyblock * var)92*7f2fe78bSCy Schubert ktest_equal_keyblock(krb5_keyblock *ref, krb5_keyblock *var)
93*7f2fe78bSCy Schubert {
94*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
95*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
96*7f2fe78bSCy Schubert     return(scalar_equal(enctype) && len_equal(length,contents,ktest_equal_array_of_octet));
97*7f2fe78bSCy Schubert }
98*7f2fe78bSCy Schubert 
99*7f2fe78bSCy Schubert int
ktest_equal_data(krb5_data * ref,krb5_data * var)100*7f2fe78bSCy Schubert ktest_equal_data(krb5_data *ref, krb5_data *var)
101*7f2fe78bSCy Schubert {
102*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
103*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
104*7f2fe78bSCy Schubert     return(len_equal(length,data,ktest_equal_array_of_char));
105*7f2fe78bSCy Schubert }
106*7f2fe78bSCy Schubert 
107*7f2fe78bSCy Schubert int
ktest_equal_ticket(krb5_ticket * ref,krb5_ticket * var)108*7f2fe78bSCy Schubert ktest_equal_ticket(krb5_ticket *ref, krb5_ticket *var)
109*7f2fe78bSCy Schubert {
110*7f2fe78bSCy Schubert     int p = TRUE;
111*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
112*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
113*7f2fe78bSCy Schubert     p = p && ptr_equal(server,ktest_equal_principal_data);
114*7f2fe78bSCy Schubert     p = p && struct_equal(enc_part,ktest_equal_enc_data);
115*7f2fe78bSCy Schubert     /* enc_part2 is irrelevant, as far as the ASN.1 code is concerned */
116*7f2fe78bSCy Schubert     return p;
117*7f2fe78bSCy Schubert }
118*7f2fe78bSCy Schubert 
119*7f2fe78bSCy Schubert int
ktest_equal_enc_data(krb5_enc_data * ref,krb5_enc_data * var)120*7f2fe78bSCy Schubert ktest_equal_enc_data(krb5_enc_data *ref, krb5_enc_data *var)
121*7f2fe78bSCy Schubert {
122*7f2fe78bSCy Schubert     int p = TRUE;
123*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
124*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
125*7f2fe78bSCy Schubert     p = p && scalar_equal(enctype);
126*7f2fe78bSCy Schubert     p = p && scalar_equal(kvno);
127*7f2fe78bSCy Schubert     p = p && struct_equal(ciphertext,ktest_equal_data);
128*7f2fe78bSCy Schubert     return p;
129*7f2fe78bSCy Schubert }
130*7f2fe78bSCy Schubert 
131*7f2fe78bSCy Schubert int
ktest_equal_encryption_key(krb5_keyblock * ref,krb5_keyblock * var)132*7f2fe78bSCy Schubert ktest_equal_encryption_key(krb5_keyblock *ref, krb5_keyblock *var)
133*7f2fe78bSCy Schubert {
134*7f2fe78bSCy Schubert     int p = TRUE;
135*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
136*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
137*7f2fe78bSCy Schubert     p = p && scalar_equal(enctype);
138*7f2fe78bSCy Schubert     p = p && len_equal(length,contents,ktest_equal_array_of_octet);
139*7f2fe78bSCy Schubert     return p;
140*7f2fe78bSCy Schubert }
141*7f2fe78bSCy Schubert 
142*7f2fe78bSCy Schubert int
ktest_equal_enc_tkt_part(krb5_enc_tkt_part * ref,krb5_enc_tkt_part * var)143*7f2fe78bSCy Schubert ktest_equal_enc_tkt_part(krb5_enc_tkt_part *ref, krb5_enc_tkt_part *var)
144*7f2fe78bSCy Schubert {
145*7f2fe78bSCy Schubert     int p = TRUE;
146*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
147*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
148*7f2fe78bSCy Schubert     p = p && scalar_equal(flags);
149*7f2fe78bSCy Schubert     p = p && ptr_equal(session,ktest_equal_encryption_key);
150*7f2fe78bSCy Schubert     p = p && ptr_equal(client,ktest_equal_principal_data);
151*7f2fe78bSCy Schubert     p = p && struct_equal(transited,ktest_equal_transited);
152*7f2fe78bSCy Schubert     p = p && struct_equal(times,ktest_equal_ticket_times);
153*7f2fe78bSCy Schubert     p = p && ptr_equal(caddrs,ktest_equal_addresses);
154*7f2fe78bSCy Schubert     p = p && ptr_equal(authorization_data,ktest_equal_authorization_data);
155*7f2fe78bSCy Schubert     return p;
156*7f2fe78bSCy Schubert }
157*7f2fe78bSCy Schubert 
158*7f2fe78bSCy Schubert int
ktest_equal_transited(krb5_transited * ref,krb5_transited * var)159*7f2fe78bSCy Schubert ktest_equal_transited(krb5_transited *ref, krb5_transited *var)
160*7f2fe78bSCy Schubert {
161*7f2fe78bSCy Schubert     int p = TRUE;
162*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
163*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
164*7f2fe78bSCy Schubert     p = p && scalar_equal(tr_type);
165*7f2fe78bSCy Schubert     p = p && struct_equal(tr_contents,ktest_equal_data);
166*7f2fe78bSCy Schubert     return p;
167*7f2fe78bSCy Schubert }
168*7f2fe78bSCy Schubert 
169*7f2fe78bSCy Schubert int
ktest_equal_ticket_times(krb5_ticket_times * ref,krb5_ticket_times * var)170*7f2fe78bSCy Schubert ktest_equal_ticket_times(krb5_ticket_times *ref, krb5_ticket_times *var)
171*7f2fe78bSCy Schubert {
172*7f2fe78bSCy Schubert     int p = TRUE;
173*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
174*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
175*7f2fe78bSCy Schubert     p = p && scalar_equal(authtime);
176*7f2fe78bSCy Schubert     p = p && scalar_equal(starttime);
177*7f2fe78bSCy Schubert     p = p && scalar_equal(endtime);
178*7f2fe78bSCy Schubert     p = p && scalar_equal(renew_till);
179*7f2fe78bSCy Schubert     return p;
180*7f2fe78bSCy Schubert }
181*7f2fe78bSCy Schubert 
182*7f2fe78bSCy Schubert int
ktest_equal_address(krb5_address * ref,krb5_address * var)183*7f2fe78bSCy Schubert ktest_equal_address(krb5_address *ref, krb5_address *var)
184*7f2fe78bSCy Schubert {
185*7f2fe78bSCy Schubert     int p = TRUE;
186*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
187*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
188*7f2fe78bSCy Schubert     p = p && scalar_equal(addrtype);
189*7f2fe78bSCy Schubert     p = p && len_equal(length,contents,ktest_equal_array_of_octet);
190*7f2fe78bSCy Schubert     return p;
191*7f2fe78bSCy Schubert }
192*7f2fe78bSCy Schubert 
193*7f2fe78bSCy Schubert int
ktest_equal_enc_kdc_rep_part(krb5_enc_kdc_rep_part * ref,krb5_enc_kdc_rep_part * var)194*7f2fe78bSCy Schubert ktest_equal_enc_kdc_rep_part(krb5_enc_kdc_rep_part *ref,
195*7f2fe78bSCy Schubert                              krb5_enc_kdc_rep_part *var)
196*7f2fe78bSCy Schubert {
197*7f2fe78bSCy Schubert     int p = TRUE;
198*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
199*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
200*7f2fe78bSCy Schubert     p = p && ptr_equal(session,ktest_equal_keyblock);
201*7f2fe78bSCy Schubert     p = p && ptr_equal(last_req,ktest_equal_last_req);
202*7f2fe78bSCy Schubert     p = p && scalar_equal(nonce);
203*7f2fe78bSCy Schubert     p = p && scalar_equal(key_exp);
204*7f2fe78bSCy Schubert     p = p && scalar_equal(flags);
205*7f2fe78bSCy Schubert     p = p && struct_equal(times,ktest_equal_ticket_times);
206*7f2fe78bSCy Schubert     p = p && ptr_equal(server,ktest_equal_principal_data);
207*7f2fe78bSCy Schubert     p = p && ptr_equal(caddrs,ktest_equal_addresses);
208*7f2fe78bSCy Schubert     return p;
209*7f2fe78bSCy Schubert }
210*7f2fe78bSCy Schubert 
211*7f2fe78bSCy Schubert int
ktest_equal_priv(krb5_priv * ref,krb5_priv * var)212*7f2fe78bSCy Schubert ktest_equal_priv(krb5_priv *ref, krb5_priv *var)
213*7f2fe78bSCy Schubert {
214*7f2fe78bSCy Schubert     int p = TRUE;
215*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
216*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
217*7f2fe78bSCy Schubert     p = p && struct_equal(enc_part,ktest_equal_enc_data);
218*7f2fe78bSCy Schubert     return p;
219*7f2fe78bSCy Schubert }
220*7f2fe78bSCy Schubert 
221*7f2fe78bSCy Schubert int
ktest_equal_cred(krb5_cred * ref,krb5_cred * var)222*7f2fe78bSCy Schubert ktest_equal_cred(krb5_cred *ref, krb5_cred *var)
223*7f2fe78bSCy Schubert {
224*7f2fe78bSCy Schubert     int p = TRUE;
225*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
226*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
227*7f2fe78bSCy Schubert     p = p && ptr_equal(tickets,ktest_equal_sequence_of_ticket);
228*7f2fe78bSCy Schubert     p = p && struct_equal(enc_part,ktest_equal_enc_data);
229*7f2fe78bSCy Schubert     return p;
230*7f2fe78bSCy Schubert }
231*7f2fe78bSCy Schubert 
232*7f2fe78bSCy Schubert int
ktest_equal_error(krb5_error * ref,krb5_error * var)233*7f2fe78bSCy Schubert ktest_equal_error(krb5_error *ref, krb5_error *var)
234*7f2fe78bSCy Schubert {
235*7f2fe78bSCy Schubert     int p = TRUE;
236*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
237*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
238*7f2fe78bSCy Schubert     p = p && scalar_equal(ctime);
239*7f2fe78bSCy Schubert     p = p && scalar_equal(cusec);
240*7f2fe78bSCy Schubert     p = p && scalar_equal(susec);
241*7f2fe78bSCy Schubert     p = p && scalar_equal(stime);
242*7f2fe78bSCy Schubert     p = p && scalar_equal(error);
243*7f2fe78bSCy Schubert     p = p && ptr_equal(client,ktest_equal_principal_data);
244*7f2fe78bSCy Schubert     p = p && ptr_equal(server,ktest_equal_principal_data);
245*7f2fe78bSCy Schubert     p = p && struct_equal(text,ktest_equal_data);
246*7f2fe78bSCy Schubert     p = p && struct_equal(e_data,ktest_equal_data);
247*7f2fe78bSCy Schubert     return p;
248*7f2fe78bSCy Schubert }
249*7f2fe78bSCy Schubert 
250*7f2fe78bSCy Schubert int
ktest_equal_ap_req(krb5_ap_req * ref,krb5_ap_req * var)251*7f2fe78bSCy Schubert ktest_equal_ap_req(krb5_ap_req *ref, krb5_ap_req *var)
252*7f2fe78bSCy Schubert {
253*7f2fe78bSCy Schubert     int p = TRUE;
254*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
255*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
256*7f2fe78bSCy Schubert     p = p && scalar_equal(ap_options);
257*7f2fe78bSCy Schubert     p = p && ptr_equal(ticket,ktest_equal_ticket);
258*7f2fe78bSCy Schubert     p = p && struct_equal(authenticator,ktest_equal_enc_data);
259*7f2fe78bSCy Schubert     return p;
260*7f2fe78bSCy Schubert }
261*7f2fe78bSCy Schubert 
262*7f2fe78bSCy Schubert int
ktest_equal_ap_rep(krb5_ap_rep * ref,krb5_ap_rep * var)263*7f2fe78bSCy Schubert ktest_equal_ap_rep(krb5_ap_rep *ref, krb5_ap_rep *var)
264*7f2fe78bSCy Schubert {
265*7f2fe78bSCy Schubert     int p = TRUE;
266*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
267*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
268*7f2fe78bSCy Schubert     p = p && struct_equal(enc_part,ktest_equal_enc_data);
269*7f2fe78bSCy Schubert     return p;
270*7f2fe78bSCy Schubert }
271*7f2fe78bSCy Schubert 
272*7f2fe78bSCy Schubert int
ktest_equal_ap_rep_enc_part(krb5_ap_rep_enc_part * ref,krb5_ap_rep_enc_part * var)273*7f2fe78bSCy Schubert ktest_equal_ap_rep_enc_part(krb5_ap_rep_enc_part *ref,
274*7f2fe78bSCy Schubert                             krb5_ap_rep_enc_part *var)
275*7f2fe78bSCy Schubert {
276*7f2fe78bSCy Schubert     int p = TRUE;
277*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
278*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
279*7f2fe78bSCy Schubert     p = p && scalar_equal(ctime);
280*7f2fe78bSCy Schubert     p = p && scalar_equal(cusec);
281*7f2fe78bSCy Schubert     p = p && ptr_equal(subkey,ktest_equal_encryption_key);
282*7f2fe78bSCy Schubert     p = p && scalar_equal(seq_number);
283*7f2fe78bSCy Schubert     return p;
284*7f2fe78bSCy Schubert }
285*7f2fe78bSCy Schubert 
286*7f2fe78bSCy Schubert int
ktest_equal_safe(krb5_safe * ref,krb5_safe * var)287*7f2fe78bSCy Schubert ktest_equal_safe(krb5_safe *ref, krb5_safe *var)
288*7f2fe78bSCy Schubert {
289*7f2fe78bSCy Schubert     int p = TRUE;
290*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
291*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
292*7f2fe78bSCy Schubert     p = p && struct_equal(user_data,ktest_equal_data);
293*7f2fe78bSCy Schubert     p = p && scalar_equal(timestamp);
294*7f2fe78bSCy Schubert     p = p && scalar_equal(usec);
295*7f2fe78bSCy Schubert     p = p && scalar_equal(seq_number);
296*7f2fe78bSCy Schubert     p = p && ptr_equal(s_address,ktest_equal_address);
297*7f2fe78bSCy Schubert     p = p && ptr_equal(r_address,ktest_equal_address);
298*7f2fe78bSCy Schubert     p = p && ptr_equal(checksum,ktest_equal_checksum);
299*7f2fe78bSCy Schubert     return p;
300*7f2fe78bSCy Schubert }
301*7f2fe78bSCy Schubert 
302*7f2fe78bSCy Schubert 
303*7f2fe78bSCy Schubert int
ktest_equal_enc_cred_part(krb5_cred_enc_part * ref,krb5_cred_enc_part * var)304*7f2fe78bSCy Schubert ktest_equal_enc_cred_part(krb5_cred_enc_part *ref, krb5_cred_enc_part *var)
305*7f2fe78bSCy Schubert {
306*7f2fe78bSCy Schubert     int p = TRUE;
307*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
308*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
309*7f2fe78bSCy Schubert     p = p && scalar_equal(nonce);
310*7f2fe78bSCy Schubert     p = p && scalar_equal(timestamp);
311*7f2fe78bSCy Schubert     p = p && scalar_equal(usec);
312*7f2fe78bSCy Schubert     p = p && ptr_equal(s_address,ktest_equal_address);
313*7f2fe78bSCy Schubert     p = p && ptr_equal(r_address,ktest_equal_address);
314*7f2fe78bSCy Schubert     p = p && ptr_equal(ticket_info,ktest_equal_sequence_of_cred_info);
315*7f2fe78bSCy Schubert     return p;
316*7f2fe78bSCy Schubert }
317*7f2fe78bSCy Schubert 
318*7f2fe78bSCy Schubert int
ktest_equal_enc_priv_part(krb5_priv_enc_part * ref,krb5_priv_enc_part * var)319*7f2fe78bSCy Schubert ktest_equal_enc_priv_part(krb5_priv_enc_part *ref, krb5_priv_enc_part *var)
320*7f2fe78bSCy Schubert {
321*7f2fe78bSCy Schubert     int p = TRUE;
322*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
323*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
324*7f2fe78bSCy Schubert     p = p && struct_equal(user_data,ktest_equal_data);
325*7f2fe78bSCy Schubert     p = p && scalar_equal(timestamp);
326*7f2fe78bSCy Schubert     p = p && scalar_equal(usec);
327*7f2fe78bSCy Schubert     p = p && scalar_equal(seq_number);
328*7f2fe78bSCy Schubert     p = p && ptr_equal(s_address,ktest_equal_address);
329*7f2fe78bSCy Schubert     p = p && ptr_equal(r_address,ktest_equal_address);
330*7f2fe78bSCy Schubert     return p;
331*7f2fe78bSCy Schubert }
332*7f2fe78bSCy Schubert 
333*7f2fe78bSCy Schubert int
ktest_equal_as_rep(krb5_kdc_rep * ref,krb5_kdc_rep * var)334*7f2fe78bSCy Schubert ktest_equal_as_rep(krb5_kdc_rep *ref, krb5_kdc_rep *var)
335*7f2fe78bSCy Schubert {
336*7f2fe78bSCy Schubert     int p = TRUE;
337*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
338*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
339*7f2fe78bSCy Schubert     p = p && scalar_equal(msg_type);
340*7f2fe78bSCy Schubert     p = p && ptr_equal(padata,ktest_equal_sequence_of_pa_data);
341*7f2fe78bSCy Schubert     p = p && ptr_equal(client,ktest_equal_principal_data);
342*7f2fe78bSCy Schubert     p = p && ptr_equal(ticket,ktest_equal_ticket);
343*7f2fe78bSCy Schubert     p = p && struct_equal(enc_part,ktest_equal_enc_data);
344*7f2fe78bSCy Schubert     p = p && ptr_equal(enc_part2,ktest_equal_enc_kdc_rep_part);
345*7f2fe78bSCy Schubert     return p;
346*7f2fe78bSCy Schubert }
347*7f2fe78bSCy Schubert 
348*7f2fe78bSCy Schubert int
ktest_equal_tgs_rep(krb5_kdc_rep * ref,krb5_kdc_rep * var)349*7f2fe78bSCy Schubert ktest_equal_tgs_rep(krb5_kdc_rep *ref, krb5_kdc_rep *var)
350*7f2fe78bSCy Schubert {
351*7f2fe78bSCy Schubert     return ktest_equal_as_rep(ref,var);
352*7f2fe78bSCy Schubert }
353*7f2fe78bSCy Schubert 
354*7f2fe78bSCy Schubert int
ktest_equal_as_req(krb5_kdc_req * ref,krb5_kdc_req * var)355*7f2fe78bSCy Schubert ktest_equal_as_req(krb5_kdc_req *ref, krb5_kdc_req *var)
356*7f2fe78bSCy Schubert {
357*7f2fe78bSCy Schubert     int p = TRUE;
358*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
359*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
360*7f2fe78bSCy Schubert     p = p && scalar_equal(msg_type);
361*7f2fe78bSCy Schubert     p = p && ptr_equal(padata,ktest_equal_sequence_of_pa_data);
362*7f2fe78bSCy Schubert     p = p && scalar_equal(kdc_options);
363*7f2fe78bSCy Schubert     p = p && ptr_equal(client,ktest_equal_principal_data);
364*7f2fe78bSCy Schubert     p = p && ptr_equal(server,ktest_equal_principal_data);
365*7f2fe78bSCy Schubert     p = p && scalar_equal(from);
366*7f2fe78bSCy Schubert     p = p && scalar_equal(till);
367*7f2fe78bSCy Schubert     p = p && scalar_equal(rtime);
368*7f2fe78bSCy Schubert     p = p && scalar_equal(nonce);
369*7f2fe78bSCy Schubert     p = p && len_equal(nktypes,ktype,ktest_equal_array_of_enctype);
370*7f2fe78bSCy Schubert     p = p && ptr_equal(addresses,ktest_equal_addresses);
371*7f2fe78bSCy Schubert     p = p && struct_equal(authorization_data,ktest_equal_enc_data);
372*7f2fe78bSCy Schubert /* This field isn't actually in the ASN.1 encoding. */
373*7f2fe78bSCy Schubert /* p = p && ptr_equal(unenc_authdata,ktest_equal_authorization_data); */
374*7f2fe78bSCy Schubert     return p;
375*7f2fe78bSCy Schubert }
376*7f2fe78bSCy Schubert 
377*7f2fe78bSCy Schubert int
ktest_equal_tgs_req(krb5_kdc_req * ref,krb5_kdc_req * var)378*7f2fe78bSCy Schubert ktest_equal_tgs_req(krb5_kdc_req *ref, krb5_kdc_req *var)
379*7f2fe78bSCy Schubert {
380*7f2fe78bSCy Schubert     return ktest_equal_as_req(ref,var);
381*7f2fe78bSCy Schubert }
382*7f2fe78bSCy Schubert 
383*7f2fe78bSCy Schubert int
ktest_equal_kdc_req_body(krb5_kdc_req * ref,krb5_kdc_req * var)384*7f2fe78bSCy Schubert ktest_equal_kdc_req_body(krb5_kdc_req *ref, krb5_kdc_req *var)
385*7f2fe78bSCy Schubert {
386*7f2fe78bSCy Schubert     int p = TRUE;
387*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
388*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
389*7f2fe78bSCy Schubert     p = p && scalar_equal(kdc_options);
390*7f2fe78bSCy Schubert     p = p && ptr_equal(client,ktest_equal_principal_data);
391*7f2fe78bSCy Schubert     p = p && ptr_equal(server,ktest_equal_principal_data);
392*7f2fe78bSCy Schubert     p = p && scalar_equal(from);
393*7f2fe78bSCy Schubert     p = p && scalar_equal(till);
394*7f2fe78bSCy Schubert     p = p && scalar_equal(rtime);
395*7f2fe78bSCy Schubert     p = p && scalar_equal(nonce);
396*7f2fe78bSCy Schubert     p = p && len_equal(nktypes,ktype,ktest_equal_array_of_enctype);
397*7f2fe78bSCy Schubert     p = p && ptr_equal(addresses,ktest_equal_addresses);
398*7f2fe78bSCy Schubert     p = p && struct_equal(authorization_data,ktest_equal_enc_data);
399*7f2fe78bSCy Schubert     /* This isn't part of the ASN.1 encoding. */
400*7f2fe78bSCy Schubert     /* p = p && ptr_equal(unenc_authdata,ktest_equal_authorization_data); */
401*7f2fe78bSCy Schubert     return p;
402*7f2fe78bSCy Schubert }
403*7f2fe78bSCy Schubert 
404*7f2fe78bSCy Schubert int
ktest_equal_last_req_entry(krb5_last_req_entry * ref,krb5_last_req_entry * var)405*7f2fe78bSCy Schubert ktest_equal_last_req_entry(krb5_last_req_entry *ref, krb5_last_req_entry *var)
406*7f2fe78bSCy Schubert {
407*7f2fe78bSCy Schubert     int p = TRUE;
408*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
409*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
410*7f2fe78bSCy Schubert     p = p && scalar_equal(lr_type);
411*7f2fe78bSCy Schubert     p = p && scalar_equal(value);
412*7f2fe78bSCy Schubert     return p;
413*7f2fe78bSCy Schubert }
414*7f2fe78bSCy Schubert 
415*7f2fe78bSCy Schubert int
ktest_equal_pa_data(krb5_pa_data * ref,krb5_pa_data * var)416*7f2fe78bSCy Schubert ktest_equal_pa_data(krb5_pa_data *ref, krb5_pa_data *var)
417*7f2fe78bSCy Schubert {
418*7f2fe78bSCy Schubert     int p = TRUE;
419*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
420*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
421*7f2fe78bSCy Schubert     p = p && scalar_equal(pa_type);
422*7f2fe78bSCy Schubert     p = p && len_equal(length,contents,ktest_equal_array_of_octet);
423*7f2fe78bSCy Schubert     return p;
424*7f2fe78bSCy Schubert }
425*7f2fe78bSCy Schubert 
426*7f2fe78bSCy Schubert int
ktest_equal_cred_info(krb5_cred_info * ref,krb5_cred_info * var)427*7f2fe78bSCy Schubert ktest_equal_cred_info(krb5_cred_info *ref, krb5_cred_info *var)
428*7f2fe78bSCy Schubert {
429*7f2fe78bSCy Schubert     int p = TRUE;
430*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
431*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
432*7f2fe78bSCy Schubert     p = p && ptr_equal(session,ktest_equal_keyblock);
433*7f2fe78bSCy Schubert     p = p && ptr_equal(client,ktest_equal_principal_data);
434*7f2fe78bSCy Schubert     p = p && ptr_equal(server,ktest_equal_principal_data);
435*7f2fe78bSCy Schubert     p = p && scalar_equal(flags);
436*7f2fe78bSCy Schubert     p = p && struct_equal(times,ktest_equal_ticket_times);
437*7f2fe78bSCy Schubert     p = p && ptr_equal(caddrs,ktest_equal_addresses);
438*7f2fe78bSCy Schubert 
439*7f2fe78bSCy Schubert     return p;
440*7f2fe78bSCy Schubert }
441*7f2fe78bSCy Schubert 
442*7f2fe78bSCy Schubert int
ktest_equal_krb5_etype_info_entry(krb5_etype_info_entry * ref,krb5_etype_info_entry * var)443*7f2fe78bSCy Schubert ktest_equal_krb5_etype_info_entry(krb5_etype_info_entry *ref,
444*7f2fe78bSCy Schubert                                   krb5_etype_info_entry *var)
445*7f2fe78bSCy Schubert {
446*7f2fe78bSCy Schubert     if (ref->etype != var->etype)
447*7f2fe78bSCy Schubert         return FALSE;
448*7f2fe78bSCy Schubert     if (ref->length != var->length)
449*7f2fe78bSCy Schubert         return FALSE;
450*7f2fe78bSCy Schubert     if (ref->length > 0 && ref->length != KRB5_ETYPE_NO_SALT)
451*7f2fe78bSCy Schubert         if (memcmp(ref->salt, var->salt, ref->length) != 0)
452*7f2fe78bSCy Schubert             return FALSE;
453*7f2fe78bSCy Schubert     return TRUE;
454*7f2fe78bSCy Schubert }
455*7f2fe78bSCy Schubert 
456*7f2fe78bSCy Schubert int
ktest_equal_krb5_pa_enc_ts(krb5_pa_enc_ts * ref,krb5_pa_enc_ts * var)457*7f2fe78bSCy Schubert ktest_equal_krb5_pa_enc_ts(krb5_pa_enc_ts *ref, krb5_pa_enc_ts *var)
458*7f2fe78bSCy Schubert {
459*7f2fe78bSCy Schubert     int p = TRUE;
460*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
461*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
462*7f2fe78bSCy Schubert     p = p && scalar_equal(patimestamp);
463*7f2fe78bSCy Schubert     p = p && scalar_equal(pausec);
464*7f2fe78bSCy Schubert     return p;
465*7f2fe78bSCy Schubert }
466*7f2fe78bSCy Schubert 
467*7f2fe78bSCy Schubert #define equal_str(f) struct_equal(f,ktest_equal_data)
468*7f2fe78bSCy Schubert 
469*7f2fe78bSCy Schubert int
ktest_equal_sam_challenge_2_body(krb5_sam_challenge_2_body * ref,krb5_sam_challenge_2_body * var)470*7f2fe78bSCy Schubert ktest_equal_sam_challenge_2_body(krb5_sam_challenge_2_body *ref,
471*7f2fe78bSCy Schubert                                  krb5_sam_challenge_2_body *var)
472*7f2fe78bSCy Schubert {
473*7f2fe78bSCy Schubert     int p = TRUE;
474*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
475*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
476*7f2fe78bSCy Schubert     p = p && scalar_equal(sam_type);
477*7f2fe78bSCy Schubert     p = p && scalar_equal(sam_flags);
478*7f2fe78bSCy Schubert     p = p && equal_str(sam_type_name);
479*7f2fe78bSCy Schubert     p = p && equal_str(sam_track_id);
480*7f2fe78bSCy Schubert     p = p && equal_str(sam_challenge_label);
481*7f2fe78bSCy Schubert     p = p && equal_str(sam_challenge);
482*7f2fe78bSCy Schubert     p = p && equal_str(sam_response_prompt);
483*7f2fe78bSCy Schubert     p = p && equal_str(sam_pk_for_sad);
484*7f2fe78bSCy Schubert     p = p && scalar_equal(sam_nonce);
485*7f2fe78bSCy Schubert     p = p && scalar_equal(sam_etype);
486*7f2fe78bSCy Schubert     return p;
487*7f2fe78bSCy Schubert }
488*7f2fe78bSCy Schubert 
489*7f2fe78bSCy Schubert int
ktest_equal_sam_challenge_2(krb5_sam_challenge_2 * ref,krb5_sam_challenge_2 * var)490*7f2fe78bSCy Schubert ktest_equal_sam_challenge_2(krb5_sam_challenge_2 *ref,
491*7f2fe78bSCy Schubert                             krb5_sam_challenge_2 *var)
492*7f2fe78bSCy Schubert {
493*7f2fe78bSCy Schubert     int p = TRUE;
494*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
495*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
496*7f2fe78bSCy Schubert     p = p && equal_str(sam_challenge_2_body);
497*7f2fe78bSCy Schubert     p = p && ptr_equal(sam_cksum,ktest_equal_sequence_of_checksum);
498*7f2fe78bSCy Schubert     return p;
499*7f2fe78bSCy Schubert }
500*7f2fe78bSCy Schubert 
501*7f2fe78bSCy Schubert int
ktest_equal_pa_for_user(krb5_pa_for_user * ref,krb5_pa_for_user * var)502*7f2fe78bSCy Schubert ktest_equal_pa_for_user(krb5_pa_for_user *ref, krb5_pa_for_user *var)
503*7f2fe78bSCy Schubert {
504*7f2fe78bSCy Schubert     int p = TRUE;
505*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
506*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
507*7f2fe78bSCy Schubert     p = p && ptr_equal(user, ktest_equal_principal_data);
508*7f2fe78bSCy Schubert     p = p && struct_equal(cksum, ktest_equal_checksum);
509*7f2fe78bSCy Schubert     p = p && equal_str(auth_package);
510*7f2fe78bSCy Schubert     return p;
511*7f2fe78bSCy Schubert }
512*7f2fe78bSCy Schubert 
513*7f2fe78bSCy Schubert int
ktest_equal_pa_s4u_x509_user(krb5_pa_s4u_x509_user * ref,krb5_pa_s4u_x509_user * var)514*7f2fe78bSCy Schubert ktest_equal_pa_s4u_x509_user(krb5_pa_s4u_x509_user *ref,
515*7f2fe78bSCy Schubert                              krb5_pa_s4u_x509_user *var)
516*7f2fe78bSCy Schubert {
517*7f2fe78bSCy Schubert     int p = TRUE;
518*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
519*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
520*7f2fe78bSCy Schubert     p = p && scalar_equal(user_id.nonce);
521*7f2fe78bSCy Schubert     p = p && ptr_equal(user_id.user,ktest_equal_principal_data);
522*7f2fe78bSCy Schubert     p = p && struct_equal(user_id.subject_cert,ktest_equal_data);
523*7f2fe78bSCy Schubert     p = p && scalar_equal(user_id.options);
524*7f2fe78bSCy Schubert     p = p && struct_equal(cksum,ktest_equal_checksum);
525*7f2fe78bSCy Schubert     return p;
526*7f2fe78bSCy Schubert }
527*7f2fe78bSCy Schubert 
528*7f2fe78bSCy Schubert int
ktest_equal_ad_kdcissued(krb5_ad_kdcissued * ref,krb5_ad_kdcissued * var)529*7f2fe78bSCy Schubert ktest_equal_ad_kdcissued(krb5_ad_kdcissued *ref, krb5_ad_kdcissued *var)
530*7f2fe78bSCy Schubert {
531*7f2fe78bSCy Schubert     int p = TRUE;
532*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
533*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
534*7f2fe78bSCy Schubert     p = p && struct_equal(ad_checksum,ktest_equal_checksum);
535*7f2fe78bSCy Schubert     p = p && ptr_equal(i_principal,ktest_equal_principal_data);
536*7f2fe78bSCy Schubert     p = p && ptr_equal(elements,ktest_equal_authorization_data);
537*7f2fe78bSCy Schubert     return p;
538*7f2fe78bSCy Schubert }
539*7f2fe78bSCy Schubert 
540*7f2fe78bSCy Schubert int
ktest_equal_iakerb_header(krb5_iakerb_header * ref,krb5_iakerb_header * var)541*7f2fe78bSCy Schubert ktest_equal_iakerb_header(krb5_iakerb_header *ref, krb5_iakerb_header *var)
542*7f2fe78bSCy Schubert {
543*7f2fe78bSCy Schubert     int p = TRUE;
544*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
545*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
546*7f2fe78bSCy Schubert     p = p && struct_equal(target_realm,ktest_equal_data);
547*7f2fe78bSCy Schubert     p = p && ptr_equal(cookie,ktest_equal_data);
548*7f2fe78bSCy Schubert     return p;
549*7f2fe78bSCy Schubert }
550*7f2fe78bSCy Schubert 
551*7f2fe78bSCy Schubert int
ktest_equal_iakerb_finished(krb5_iakerb_finished * ref,krb5_iakerb_finished * var)552*7f2fe78bSCy Schubert ktest_equal_iakerb_finished(krb5_iakerb_finished *ref,
553*7f2fe78bSCy Schubert                             krb5_iakerb_finished *var)
554*7f2fe78bSCy Schubert {
555*7f2fe78bSCy Schubert     int p = TRUE;
556*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
557*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
558*7f2fe78bSCy Schubert     p = p && struct_equal(checksum,ktest_equal_checksum);
559*7f2fe78bSCy Schubert     return p;
560*7f2fe78bSCy Schubert }
561*7f2fe78bSCy Schubert 
562*7f2fe78bSCy Schubert static int
ktest_equal_fast_finished(krb5_fast_finished * ref,krb5_fast_finished * var)563*7f2fe78bSCy Schubert ktest_equal_fast_finished(krb5_fast_finished *ref, krb5_fast_finished *var)
564*7f2fe78bSCy Schubert {
565*7f2fe78bSCy Schubert     int p = TRUE;
566*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
567*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
568*7f2fe78bSCy Schubert     p = p && scalar_equal(timestamp);
569*7f2fe78bSCy Schubert     p = p && scalar_equal(usec);
570*7f2fe78bSCy Schubert     p = p && ptr_equal(client, ktest_equal_principal_data);
571*7f2fe78bSCy Schubert     p = p && struct_equal(ticket_checksum, ktest_equal_checksum);
572*7f2fe78bSCy Schubert     return p;
573*7f2fe78bSCy Schubert }
574*7f2fe78bSCy Schubert 
575*7f2fe78bSCy Schubert int
ktest_equal_fast_response(krb5_fast_response * ref,krb5_fast_response * var)576*7f2fe78bSCy Schubert ktest_equal_fast_response(krb5_fast_response *ref, krb5_fast_response *var)
577*7f2fe78bSCy Schubert {
578*7f2fe78bSCy Schubert     int p = TRUE;
579*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
580*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
581*7f2fe78bSCy Schubert     p = p && ptr_equal(padata, ktest_equal_sequence_of_pa_data);
582*7f2fe78bSCy Schubert     p = p && ptr_equal(strengthen_key, ktest_equal_keyblock);
583*7f2fe78bSCy Schubert     p = p && ptr_equal(finished, ktest_equal_fast_finished);
584*7f2fe78bSCy Schubert     p = p && scalar_equal(nonce);
585*7f2fe78bSCy Schubert     return p;
586*7f2fe78bSCy Schubert }
587*7f2fe78bSCy Schubert 
588*7f2fe78bSCy Schubert static int
ktest_equal_algorithm_identifier(krb5_algorithm_identifier * ref,krb5_algorithm_identifier * var)589*7f2fe78bSCy Schubert ktest_equal_algorithm_identifier(krb5_algorithm_identifier *ref,
590*7f2fe78bSCy Schubert                                  krb5_algorithm_identifier *var)
591*7f2fe78bSCy Schubert {
592*7f2fe78bSCy Schubert     int p = TRUE;
593*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
594*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
595*7f2fe78bSCy Schubert     p = p && equal_str(algorithm);
596*7f2fe78bSCy Schubert     p = p && equal_str(parameters);
597*7f2fe78bSCy Schubert     return p;
598*7f2fe78bSCy Schubert }
599*7f2fe78bSCy Schubert 
600*7f2fe78bSCy Schubert int
ktest_equal_otp_tokeninfo(krb5_otp_tokeninfo * ref,krb5_otp_tokeninfo * var)601*7f2fe78bSCy Schubert ktest_equal_otp_tokeninfo(krb5_otp_tokeninfo *ref, krb5_otp_tokeninfo *var)
602*7f2fe78bSCy Schubert {
603*7f2fe78bSCy Schubert     int p = TRUE;
604*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
605*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
606*7f2fe78bSCy Schubert     p = p && scalar_equal(flags);
607*7f2fe78bSCy Schubert     p = p && equal_str(vendor);
608*7f2fe78bSCy Schubert     p = p && equal_str(challenge);
609*7f2fe78bSCy Schubert     p = p && scalar_equal(length);
610*7f2fe78bSCy Schubert     p = p && scalar_equal(format);
611*7f2fe78bSCy Schubert     p = p && equal_str(token_id);
612*7f2fe78bSCy Schubert     p = p && equal_str(alg_id);
613*7f2fe78bSCy Schubert     p = p && ptr_equal(supported_hash_alg,
614*7f2fe78bSCy Schubert                        ktest_equal_sequence_of_algorithm_identifier);
615*7f2fe78bSCy Schubert     p = p && scalar_equal(iteration_count);
616*7f2fe78bSCy Schubert     return p;
617*7f2fe78bSCy Schubert }
618*7f2fe78bSCy Schubert 
619*7f2fe78bSCy Schubert int
ktest_equal_pa_otp_challenge(krb5_pa_otp_challenge * ref,krb5_pa_otp_challenge * var)620*7f2fe78bSCy Schubert ktest_equal_pa_otp_challenge(krb5_pa_otp_challenge *ref,
621*7f2fe78bSCy Schubert                              krb5_pa_otp_challenge *var)
622*7f2fe78bSCy Schubert {
623*7f2fe78bSCy Schubert     int p = TRUE;
624*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
625*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
626*7f2fe78bSCy Schubert     p = p && equal_str(nonce);
627*7f2fe78bSCy Schubert     p = p && equal_str(service);
628*7f2fe78bSCy Schubert     p = p && ptr_equal(tokeninfo, ktest_equal_sequence_of_otp_tokeninfo);
629*7f2fe78bSCy Schubert     p = p && equal_str(salt);
630*7f2fe78bSCy Schubert     p = p && equal_str(s2kparams);
631*7f2fe78bSCy Schubert     return p;
632*7f2fe78bSCy Schubert }
633*7f2fe78bSCy Schubert 
634*7f2fe78bSCy Schubert int
ktest_equal_pa_otp_req(krb5_pa_otp_req * ref,krb5_pa_otp_req * var)635*7f2fe78bSCy Schubert ktest_equal_pa_otp_req(krb5_pa_otp_req *ref, krb5_pa_otp_req *var)
636*7f2fe78bSCy Schubert {
637*7f2fe78bSCy Schubert     int p = TRUE;
638*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
639*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
640*7f2fe78bSCy Schubert     p = p && scalar_equal(flags);
641*7f2fe78bSCy Schubert     p = p && equal_str(nonce);
642*7f2fe78bSCy Schubert     p = p && struct_equal(enc_data, ktest_equal_enc_data);
643*7f2fe78bSCy Schubert     p = p && ptr_equal(hash_alg, ktest_equal_algorithm_identifier);
644*7f2fe78bSCy Schubert     p = p && scalar_equal(iteration_count);
645*7f2fe78bSCy Schubert     p = p && equal_str(otp_value);
646*7f2fe78bSCy Schubert     p = p && equal_str(pin);
647*7f2fe78bSCy Schubert     p = p && equal_str(challenge);
648*7f2fe78bSCy Schubert     p = p && scalar_equal(time);
649*7f2fe78bSCy Schubert     p = p && equal_str(counter);
650*7f2fe78bSCy Schubert     p = p && scalar_equal(format);
651*7f2fe78bSCy Schubert     p = p && equal_str(token_id);
652*7f2fe78bSCy Schubert     p = p && equal_str(alg_id);
653*7f2fe78bSCy Schubert     p = p && equal_str(vendor);
654*7f2fe78bSCy Schubert     return p;
655*7f2fe78bSCy Schubert }
656*7f2fe78bSCy Schubert 
657*7f2fe78bSCy Schubert #ifdef ENABLE_LDAP
658*7f2fe78bSCy Schubert static int
equal_key_data(krb5_key_data * ref,krb5_key_data * var)659*7f2fe78bSCy Schubert equal_key_data(krb5_key_data *ref, krb5_key_data *var)
660*7f2fe78bSCy Schubert {
661*7f2fe78bSCy Schubert     int p = TRUE;
662*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
663*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
664*7f2fe78bSCy Schubert     p = p && scalar_equal(key_data_type[0]);
665*7f2fe78bSCy Schubert     p = p && scalar_equal(key_data_type[1]);
666*7f2fe78bSCy Schubert     p = p && len_equal(key_data_length[0],key_data_contents[0],
667*7f2fe78bSCy Schubert                    ktest_equal_array_of_octet);
668*7f2fe78bSCy Schubert     p = p && len_equal(key_data_length[1],key_data_contents[1],
669*7f2fe78bSCy Schubert                    ktest_equal_array_of_octet);
670*7f2fe78bSCy Schubert     return p;
671*7f2fe78bSCy Schubert }
672*7f2fe78bSCy Schubert 
673*7f2fe78bSCy Schubert static int
equal_key_data_array(int n,krb5_key_data * ref,krb5_key_data * val)674*7f2fe78bSCy Schubert equal_key_data_array(int n, krb5_key_data *ref, krb5_key_data *val)
675*7f2fe78bSCy Schubert {
676*7f2fe78bSCy Schubert     int i, p = TRUE;
677*7f2fe78bSCy Schubert     for (i = 0; i < n; i++) {
678*7f2fe78bSCy Schubert         p = p && equal_key_data(ref+i, val+i);
679*7f2fe78bSCy Schubert     }
680*7f2fe78bSCy Schubert     return p;
681*7f2fe78bSCy Schubert }
682*7f2fe78bSCy Schubert 
683*7f2fe78bSCy Schubert int
ktest_equal_ldap_sequence_of_keys(ldap_seqof_key_data * ref,ldap_seqof_key_data * var)684*7f2fe78bSCy Schubert ktest_equal_ldap_sequence_of_keys(ldap_seqof_key_data *ref,
685*7f2fe78bSCy Schubert                                   ldap_seqof_key_data *var)
686*7f2fe78bSCy Schubert {
687*7f2fe78bSCy Schubert     int p = TRUE;
688*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
689*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
690*7f2fe78bSCy Schubert     p = p && scalar_equal(mkvno);
691*7f2fe78bSCy Schubert     p = p && scalar_equal(kvno);
692*7f2fe78bSCy Schubert     p = p && len_equal(n_key_data,key_data,equal_key_data_array);
693*7f2fe78bSCy Schubert     return p;
694*7f2fe78bSCy Schubert }
695*7f2fe78bSCy Schubert #endif
696*7f2fe78bSCy Schubert 
697*7f2fe78bSCy Schubert /**** arrays ****************************************************************/
698*7f2fe78bSCy Schubert 
699*7f2fe78bSCy Schubert int
ktest_equal_array_of_data(int length,krb5_data * ref,krb5_data * var)700*7f2fe78bSCy Schubert ktest_equal_array_of_data(int length, krb5_data *ref, krb5_data *var)
701*7f2fe78bSCy Schubert {
702*7f2fe78bSCy Schubert     int i,p = TRUE;
703*7f2fe78bSCy Schubert 
704*7f2fe78bSCy Schubert     if (length == 0 || ref == var) return TRUE;
705*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
706*7f2fe78bSCy Schubert     for (i=0; i<(length); i++) {
707*7f2fe78bSCy Schubert         p = p && ktest_equal_data(&(ref[i]),&(var[i]));
708*7f2fe78bSCy Schubert     }
709*7f2fe78bSCy Schubert     return p;
710*7f2fe78bSCy Schubert }
711*7f2fe78bSCy Schubert 
712*7f2fe78bSCy Schubert int
ktest_equal_array_of_octet(unsigned int length,krb5_octet * ref,krb5_octet * var)713*7f2fe78bSCy Schubert ktest_equal_array_of_octet(unsigned int length, krb5_octet *ref,
714*7f2fe78bSCy Schubert                            krb5_octet *var)
715*7f2fe78bSCy Schubert {
716*7f2fe78bSCy Schubert     unsigned int i, p = TRUE;
717*7f2fe78bSCy Schubert 
718*7f2fe78bSCy Schubert     if (length == 0 || ref == var) return TRUE;
719*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
720*7f2fe78bSCy Schubert     for (i=0; i<length; i++)
721*7f2fe78bSCy Schubert         p = p && (ref[i] == var[i]);
722*7f2fe78bSCy Schubert     return p;
723*7f2fe78bSCy Schubert }
724*7f2fe78bSCy Schubert 
725*7f2fe78bSCy Schubert int
ktest_equal_array_of_char(unsigned int length,char * ref,char * var)726*7f2fe78bSCy Schubert ktest_equal_array_of_char(unsigned int length, char *ref, char *var)
727*7f2fe78bSCy Schubert {
728*7f2fe78bSCy Schubert     unsigned int i, p = TRUE;
729*7f2fe78bSCy Schubert 
730*7f2fe78bSCy Schubert     if (length == 0 || ref == var) return TRUE;
731*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
732*7f2fe78bSCy Schubert     for (i=0; i<length; i++)
733*7f2fe78bSCy Schubert         p = p && (ref[i] == var[i]);
734*7f2fe78bSCy Schubert     return p;
735*7f2fe78bSCy Schubert }
736*7f2fe78bSCy Schubert 
737*7f2fe78bSCy Schubert int
ktest_equal_array_of_enctype(int length,krb5_enctype * ref,krb5_enctype * var)738*7f2fe78bSCy Schubert ktest_equal_array_of_enctype(int length, krb5_enctype *ref, krb5_enctype *var)
739*7f2fe78bSCy Schubert {
740*7f2fe78bSCy Schubert     int i, p = TRUE;
741*7f2fe78bSCy Schubert 
742*7f2fe78bSCy Schubert     if (length == 0 || ref == var) return TRUE;
743*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
744*7f2fe78bSCy Schubert     for (i=0; i<length; i++)
745*7f2fe78bSCy Schubert         p = p && (ref[i] == var[i]);
746*7f2fe78bSCy Schubert     return p;
747*7f2fe78bSCy Schubert }
748*7f2fe78bSCy Schubert 
749*7f2fe78bSCy Schubert #define array_compare(comparator)                       \
750*7f2fe78bSCy Schubert     int i,p = TRUE;                                       \
751*7f2fe78bSCy Schubert     if (ref == var) return TRUE;                          \
752*7f2fe78bSCy Schubert     if (!ref || !ref[0])                                \
753*7f2fe78bSCy Schubert         return (!var || !var[0]);                       \
754*7f2fe78bSCy Schubert     if (!var || !var[0]) return FALSE;                  \
755*7f2fe78bSCy Schubert     for (i=0; ref[i] != NULL && var[i] != NULL; i++)    \
756*7f2fe78bSCy Schubert         p = p && comparator(ref[i],var[i]);             \
757*7f2fe78bSCy Schubert     if (ref[i] == NULL && var[i] == NULL) return p;     \
758*7f2fe78bSCy Schubert     else return FALSE
759*7f2fe78bSCy Schubert 
760*7f2fe78bSCy Schubert int
ktest_equal_authorization_data(krb5_authdata ** ref,krb5_authdata ** var)761*7f2fe78bSCy Schubert ktest_equal_authorization_data(krb5_authdata **ref, krb5_authdata **var)
762*7f2fe78bSCy Schubert {
763*7f2fe78bSCy Schubert     array_compare(ktest_equal_authdata);
764*7f2fe78bSCy Schubert }
765*7f2fe78bSCy Schubert 
766*7f2fe78bSCy Schubert int
ktest_equal_addresses(krb5_address ** ref,krb5_address ** var)767*7f2fe78bSCy Schubert ktest_equal_addresses(krb5_address **ref, krb5_address **var)
768*7f2fe78bSCy Schubert {
769*7f2fe78bSCy Schubert     array_compare(ktest_equal_address);
770*7f2fe78bSCy Schubert }
771*7f2fe78bSCy Schubert 
772*7f2fe78bSCy Schubert int
ktest_equal_last_req(krb5_last_req_entry ** ref,krb5_last_req_entry ** var)773*7f2fe78bSCy Schubert ktest_equal_last_req(krb5_last_req_entry **ref, krb5_last_req_entry **var)
774*7f2fe78bSCy Schubert {
775*7f2fe78bSCy Schubert     array_compare(ktest_equal_last_req_entry);
776*7f2fe78bSCy Schubert }
777*7f2fe78bSCy Schubert 
778*7f2fe78bSCy Schubert int
ktest_equal_sequence_of_ticket(krb5_ticket ** ref,krb5_ticket ** var)779*7f2fe78bSCy Schubert ktest_equal_sequence_of_ticket(krb5_ticket **ref, krb5_ticket **var)
780*7f2fe78bSCy Schubert {
781*7f2fe78bSCy Schubert     array_compare(ktest_equal_ticket);
782*7f2fe78bSCy Schubert }
783*7f2fe78bSCy Schubert 
784*7f2fe78bSCy Schubert int
ktest_equal_sequence_of_pa_data(krb5_pa_data ** ref,krb5_pa_data ** var)785*7f2fe78bSCy Schubert ktest_equal_sequence_of_pa_data(krb5_pa_data **ref, krb5_pa_data **var)
786*7f2fe78bSCy Schubert {
787*7f2fe78bSCy Schubert     array_compare(ktest_equal_pa_data);
788*7f2fe78bSCy Schubert }
789*7f2fe78bSCy Schubert 
790*7f2fe78bSCy Schubert int
ktest_equal_sequence_of_cred_info(krb5_cred_info ** ref,krb5_cred_info ** var)791*7f2fe78bSCy Schubert ktest_equal_sequence_of_cred_info(krb5_cred_info **ref, krb5_cred_info **var)
792*7f2fe78bSCy Schubert {
793*7f2fe78bSCy Schubert     array_compare(ktest_equal_cred_info);
794*7f2fe78bSCy Schubert }
795*7f2fe78bSCy Schubert 
796*7f2fe78bSCy Schubert int
ktest_equal_sequence_of_principal(krb5_principal * ref,krb5_principal * var)797*7f2fe78bSCy Schubert ktest_equal_sequence_of_principal(krb5_principal *ref, krb5_principal *var)
798*7f2fe78bSCy Schubert {
799*7f2fe78bSCy Schubert     array_compare(ktest_equal_principal_data);
800*7f2fe78bSCy Schubert }
801*7f2fe78bSCy Schubert 
802*7f2fe78bSCy Schubert int
ktest_equal_etype_info(krb5_etype_info_entry ** ref,krb5_etype_info_entry ** var)803*7f2fe78bSCy Schubert ktest_equal_etype_info(krb5_etype_info_entry **ref, krb5_etype_info_entry **var)
804*7f2fe78bSCy Schubert {
805*7f2fe78bSCy Schubert     array_compare(ktest_equal_krb5_etype_info_entry);
806*7f2fe78bSCy Schubert }
807*7f2fe78bSCy Schubert 
808*7f2fe78bSCy Schubert int
ktest_equal_sequence_of_checksum(krb5_checksum ** ref,krb5_checksum ** var)809*7f2fe78bSCy Schubert ktest_equal_sequence_of_checksum(krb5_checksum **ref, krb5_checksum **var)
810*7f2fe78bSCy Schubert {
811*7f2fe78bSCy Schubert     array_compare(ktest_equal_checksum);
812*7f2fe78bSCy Schubert }
813*7f2fe78bSCy Schubert 
814*7f2fe78bSCy Schubert int
ktest_equal_sequence_of_algorithm_identifier(krb5_algorithm_identifier ** ref,krb5_algorithm_identifier ** var)815*7f2fe78bSCy Schubert ktest_equal_sequence_of_algorithm_identifier(krb5_algorithm_identifier **ref,
816*7f2fe78bSCy Schubert                                              krb5_algorithm_identifier **var)
817*7f2fe78bSCy Schubert {
818*7f2fe78bSCy Schubert     array_compare(ktest_equal_algorithm_identifier);
819*7f2fe78bSCy Schubert }
820*7f2fe78bSCy Schubert 
821*7f2fe78bSCy Schubert int
ktest_equal_sequence_of_otp_tokeninfo(krb5_otp_tokeninfo ** ref,krb5_otp_tokeninfo ** var)822*7f2fe78bSCy Schubert ktest_equal_sequence_of_otp_tokeninfo(krb5_otp_tokeninfo **ref,
823*7f2fe78bSCy Schubert                                       krb5_otp_tokeninfo **var)
824*7f2fe78bSCy Schubert {
825*7f2fe78bSCy Schubert     array_compare(ktest_equal_otp_tokeninfo);
826*7f2fe78bSCy Schubert }
827*7f2fe78bSCy Schubert 
828*7f2fe78bSCy Schubert int
ktest_equal_sequence_of_spake_factor(krb5_spake_factor ** ref,krb5_spake_factor ** var)829*7f2fe78bSCy Schubert ktest_equal_sequence_of_spake_factor(krb5_spake_factor **ref,
830*7f2fe78bSCy Schubert                                      krb5_spake_factor **var)
831*7f2fe78bSCy Schubert {
832*7f2fe78bSCy Schubert     array_compare(ktest_equal_spake_factor);
833*7f2fe78bSCy Schubert }
834*7f2fe78bSCy Schubert 
835*7f2fe78bSCy Schubert #ifndef DISABLE_PKINIT
836*7f2fe78bSCy Schubert 
837*7f2fe78bSCy Schubert static int
ktest_equal_pk_authenticator(krb5_pk_authenticator * ref,krb5_pk_authenticator * var)838*7f2fe78bSCy Schubert ktest_equal_pk_authenticator(krb5_pk_authenticator *ref,
839*7f2fe78bSCy Schubert                              krb5_pk_authenticator *var)
840*7f2fe78bSCy Schubert {
841*7f2fe78bSCy Schubert     int p = TRUE;
842*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
843*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
844*7f2fe78bSCy Schubert     p = p && scalar_equal(cusec);
845*7f2fe78bSCy Schubert     p = p && scalar_equal(ctime);
846*7f2fe78bSCy Schubert     p = p && scalar_equal(nonce);
847*7f2fe78bSCy Schubert     p = p && struct_equal(paChecksum, ktest_equal_checksum);
848*7f2fe78bSCy Schubert     return p;
849*7f2fe78bSCy Schubert }
850*7f2fe78bSCy Schubert 
851*7f2fe78bSCy Schubert static int
ktest_equal_external_principal_identifier(krb5_external_principal_identifier * ref,krb5_external_principal_identifier * var)852*7f2fe78bSCy Schubert ktest_equal_external_principal_identifier(
853*7f2fe78bSCy Schubert     krb5_external_principal_identifier *ref,
854*7f2fe78bSCy Schubert     krb5_external_principal_identifier *var)
855*7f2fe78bSCy Schubert {
856*7f2fe78bSCy Schubert     int p = TRUE;
857*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
858*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
859*7f2fe78bSCy Schubert     p = p && equal_str(subjectName);
860*7f2fe78bSCy Schubert     p = p && equal_str(issuerAndSerialNumber);
861*7f2fe78bSCy Schubert     p = p && equal_str(subjectKeyIdentifier);
862*7f2fe78bSCy Schubert     return p;
863*7f2fe78bSCy Schubert }
864*7f2fe78bSCy Schubert 
865*7f2fe78bSCy Schubert static int
ktest_equal_sequence_of_external_principal_identifier(krb5_external_principal_identifier ** ref,krb5_external_principal_identifier ** var)866*7f2fe78bSCy Schubert ktest_equal_sequence_of_external_principal_identifier(
867*7f2fe78bSCy Schubert     krb5_external_principal_identifier **ref,
868*7f2fe78bSCy Schubert     krb5_external_principal_identifier **var)
869*7f2fe78bSCy Schubert {
870*7f2fe78bSCy Schubert     array_compare(ktest_equal_external_principal_identifier);
871*7f2fe78bSCy Schubert }
872*7f2fe78bSCy Schubert 
873*7f2fe78bSCy Schubert int
ktest_equal_pa_pk_as_req(krb5_pa_pk_as_req * ref,krb5_pa_pk_as_req * var)874*7f2fe78bSCy Schubert ktest_equal_pa_pk_as_req(krb5_pa_pk_as_req *ref, krb5_pa_pk_as_req *var)
875*7f2fe78bSCy Schubert {
876*7f2fe78bSCy Schubert     int p = TRUE;
877*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
878*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
879*7f2fe78bSCy Schubert     p = p && equal_str(signedAuthPack);
880*7f2fe78bSCy Schubert     p = p && ptr_equal(trustedCertifiers,
881*7f2fe78bSCy Schubert                        ktest_equal_sequence_of_external_principal_identifier);
882*7f2fe78bSCy Schubert     p = p && equal_str(kdcPkId);
883*7f2fe78bSCy Schubert     return p;
884*7f2fe78bSCy Schubert }
885*7f2fe78bSCy Schubert 
886*7f2fe78bSCy Schubert static int
ktest_equal_dh_rep_info(krb5_dh_rep_info * ref,krb5_dh_rep_info * var)887*7f2fe78bSCy Schubert ktest_equal_dh_rep_info(krb5_dh_rep_info *ref, krb5_dh_rep_info *var)
888*7f2fe78bSCy Schubert {
889*7f2fe78bSCy Schubert     int p = TRUE;
890*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
891*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
892*7f2fe78bSCy Schubert     p = p && equal_str(dhSignedData);
893*7f2fe78bSCy Schubert     p = p && equal_str(serverDHNonce);
894*7f2fe78bSCy Schubert     p = p && ptr_equal(kdfID, ktest_equal_data);
895*7f2fe78bSCy Schubert     return p;
896*7f2fe78bSCy Schubert }
897*7f2fe78bSCy Schubert 
898*7f2fe78bSCy Schubert int
ktest_equal_pa_pk_as_rep(krb5_pa_pk_as_rep * ref,krb5_pa_pk_as_rep * var)899*7f2fe78bSCy Schubert ktest_equal_pa_pk_as_rep(krb5_pa_pk_as_rep *ref, krb5_pa_pk_as_rep *var)
900*7f2fe78bSCy Schubert {
901*7f2fe78bSCy Schubert     int p = TRUE;
902*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
903*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
904*7f2fe78bSCy Schubert     if (ref->choice != var->choice) return FALSE;
905*7f2fe78bSCy Schubert     if (ref->choice == choice_pa_pk_as_rep_dhInfo)
906*7f2fe78bSCy Schubert         p = p && struct_equal(u.dh_Info, ktest_equal_dh_rep_info);
907*7f2fe78bSCy Schubert     else if (ref->choice == choice_pa_pk_as_rep_encKeyPack)
908*7f2fe78bSCy Schubert         p = p && equal_str(u.encKeyPack);
909*7f2fe78bSCy Schubert     return p;
910*7f2fe78bSCy Schubert }
911*7f2fe78bSCy Schubert 
912*7f2fe78bSCy Schubert static int
ktest_equal_sequence_of_data(krb5_data ** ref,krb5_data ** var)913*7f2fe78bSCy Schubert ktest_equal_sequence_of_data(krb5_data **ref, krb5_data **var)
914*7f2fe78bSCy Schubert {
915*7f2fe78bSCy Schubert     array_compare(ktest_equal_data);
916*7f2fe78bSCy Schubert }
917*7f2fe78bSCy Schubert 
918*7f2fe78bSCy Schubert int
ktest_equal_auth_pack(krb5_auth_pack * ref,krb5_auth_pack * var)919*7f2fe78bSCy Schubert ktest_equal_auth_pack(krb5_auth_pack *ref, krb5_auth_pack *var)
920*7f2fe78bSCy Schubert {
921*7f2fe78bSCy Schubert     int p = TRUE;
922*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
923*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
924*7f2fe78bSCy Schubert     p = p && struct_equal(pkAuthenticator, ktest_equal_pk_authenticator);
925*7f2fe78bSCy Schubert     p = p && equal_str(clientPublicValue);
926*7f2fe78bSCy Schubert     p = p && ptr_equal(supportedCMSTypes,
927*7f2fe78bSCy Schubert                        ktest_equal_sequence_of_algorithm_identifier);
928*7f2fe78bSCy Schubert     p = p && equal_str(clientDHNonce);
929*7f2fe78bSCy Schubert     p = p && ptr_equal(supportedKDFs, ktest_equal_sequence_of_data);
930*7f2fe78bSCy Schubert     return p;
931*7f2fe78bSCy Schubert }
932*7f2fe78bSCy Schubert 
933*7f2fe78bSCy Schubert int
ktest_equal_kdc_dh_key_info(krb5_kdc_dh_key_info * ref,krb5_kdc_dh_key_info * var)934*7f2fe78bSCy Schubert ktest_equal_kdc_dh_key_info(krb5_kdc_dh_key_info *ref,
935*7f2fe78bSCy Schubert                             krb5_kdc_dh_key_info *var)
936*7f2fe78bSCy Schubert {
937*7f2fe78bSCy Schubert     int p = TRUE;
938*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
939*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
940*7f2fe78bSCy Schubert     p = p && equal_str(subjectPublicKey);
941*7f2fe78bSCy Schubert     p = p && scalar_equal(nonce);
942*7f2fe78bSCy Schubert     p = p && scalar_equal(dhKeyExpiration);
943*7f2fe78bSCy Schubert     return p;
944*7f2fe78bSCy Schubert }
945*7f2fe78bSCy Schubert 
946*7f2fe78bSCy Schubert int
ktest_equal_reply_key_pack(krb5_reply_key_pack * ref,krb5_reply_key_pack * var)947*7f2fe78bSCy Schubert ktest_equal_reply_key_pack(krb5_reply_key_pack *ref, krb5_reply_key_pack *var)
948*7f2fe78bSCy Schubert {
949*7f2fe78bSCy Schubert     int p = TRUE;
950*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
951*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
952*7f2fe78bSCy Schubert     p = p && struct_equal(replyKey, ktest_equal_keyblock);
953*7f2fe78bSCy Schubert     p = p && struct_equal(asChecksum, ktest_equal_checksum);
954*7f2fe78bSCy Schubert     return p;
955*7f2fe78bSCy Schubert }
956*7f2fe78bSCy Schubert 
957*7f2fe78bSCy Schubert #endif /* not DISABLE_PKINIT */
958*7f2fe78bSCy Schubert 
959*7f2fe78bSCy Schubert int
ktest_equal_kkdcp_message(krb5_kkdcp_message * ref,krb5_kkdcp_message * var)960*7f2fe78bSCy Schubert ktest_equal_kkdcp_message(krb5_kkdcp_message *ref, krb5_kkdcp_message *var)
961*7f2fe78bSCy Schubert {
962*7f2fe78bSCy Schubert     int p = TRUE;
963*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
964*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
965*7f2fe78bSCy Schubert     p = p && data_eq(ref->kerb_message, var->kerb_message);
966*7f2fe78bSCy Schubert     p = p && data_eq(ref->target_domain, var->target_domain);
967*7f2fe78bSCy Schubert     p = p && scalar_equal(dclocator_hint);
968*7f2fe78bSCy Schubert     return p;
969*7f2fe78bSCy Schubert }
970*7f2fe78bSCy Schubert 
971*7f2fe78bSCy Schubert static int
vmac_eq(krb5_verifier_mac * ref,krb5_verifier_mac * var)972*7f2fe78bSCy Schubert vmac_eq(krb5_verifier_mac *ref, krb5_verifier_mac *var)
973*7f2fe78bSCy Schubert {
974*7f2fe78bSCy Schubert     int p = TRUE;
975*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
976*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
977*7f2fe78bSCy Schubert     p = p && ptr_equal(princ, ktest_equal_principal_data);
978*7f2fe78bSCy Schubert     p = p && scalar_equal(kvno);
979*7f2fe78bSCy Schubert     p = p && scalar_equal(enctype);
980*7f2fe78bSCy Schubert     p = p && struct_equal(checksum, ktest_equal_checksum);
981*7f2fe78bSCy Schubert     return p;
982*7f2fe78bSCy Schubert }
983*7f2fe78bSCy Schubert 
984*7f2fe78bSCy Schubert static int
vmac_list_eq(krb5_verifier_mac ** ref,krb5_verifier_mac ** var)985*7f2fe78bSCy Schubert vmac_list_eq(krb5_verifier_mac **ref, krb5_verifier_mac **var)
986*7f2fe78bSCy Schubert {
987*7f2fe78bSCy Schubert     array_compare(vmac_eq);
988*7f2fe78bSCy Schubert }
989*7f2fe78bSCy Schubert 
990*7f2fe78bSCy Schubert int
ktest_equal_cammac(krb5_cammac * ref,krb5_cammac * var)991*7f2fe78bSCy Schubert ktest_equal_cammac(krb5_cammac *ref, krb5_cammac *var)
992*7f2fe78bSCy Schubert {
993*7f2fe78bSCy Schubert     int p = TRUE;
994*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
995*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
996*7f2fe78bSCy Schubert     p = p && ptr_equal(elements, ktest_equal_authorization_data);
997*7f2fe78bSCy Schubert     p = p && ptr_equal(kdc_verifier, vmac_eq);
998*7f2fe78bSCy Schubert     p = p && ptr_equal(svc_verifier, vmac_eq);
999*7f2fe78bSCy Schubert     p = p && ptr_equal(other_verifiers, vmac_list_eq);
1000*7f2fe78bSCy Schubert     return p;
1001*7f2fe78bSCy Schubert }
1002*7f2fe78bSCy Schubert 
1003*7f2fe78bSCy Schubert int
ktest_equal_secure_cookie(krb5_secure_cookie * ref,krb5_secure_cookie * var)1004*7f2fe78bSCy Schubert ktest_equal_secure_cookie(krb5_secure_cookie *ref, krb5_secure_cookie *var)
1005*7f2fe78bSCy Schubert {
1006*7f2fe78bSCy Schubert     int p = TRUE;
1007*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
1008*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
1009*7f2fe78bSCy Schubert     p = p && ktest_equal_sequence_of_pa_data(ref->data, var->data);
1010*7f2fe78bSCy Schubert     p = p && scalar_equal(time);
1011*7f2fe78bSCy Schubert     return p;
1012*7f2fe78bSCy Schubert }
1013*7f2fe78bSCy Schubert 
1014*7f2fe78bSCy Schubert int
ktest_equal_spake_factor(krb5_spake_factor * ref,krb5_spake_factor * var)1015*7f2fe78bSCy Schubert ktest_equal_spake_factor(krb5_spake_factor *ref, krb5_spake_factor *var)
1016*7f2fe78bSCy Schubert {
1017*7f2fe78bSCy Schubert     int p = TRUE;
1018*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
1019*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
1020*7f2fe78bSCy Schubert     p = p && scalar_equal(type);
1021*7f2fe78bSCy Schubert     p = p && ptr_equal(data,ktest_equal_data);
1022*7f2fe78bSCy Schubert     return p;
1023*7f2fe78bSCy Schubert }
1024*7f2fe78bSCy Schubert 
1025*7f2fe78bSCy Schubert int
ktest_equal_pa_spake(krb5_pa_spake * ref,krb5_pa_spake * var)1026*7f2fe78bSCy Schubert ktest_equal_pa_spake(krb5_pa_spake *ref, krb5_pa_spake *var)
1027*7f2fe78bSCy Schubert {
1028*7f2fe78bSCy Schubert     int p = TRUE;
1029*7f2fe78bSCy Schubert     if (ref == var) return TRUE;
1030*7f2fe78bSCy Schubert     else if (ref == NULL || var == NULL) return FALSE;
1031*7f2fe78bSCy Schubert     else if (ref->choice != var->choice) return FALSE;
1032*7f2fe78bSCy Schubert     switch (ref->choice) {
1033*7f2fe78bSCy Schubert     case SPAKE_MSGTYPE_SUPPORT:
1034*7f2fe78bSCy Schubert         p = p && scalar_equal(u.support.ngroups);
1035*7f2fe78bSCy Schubert         p = p && (memcmp(ref->u.support.groups,var->u.support.groups,
1036*7f2fe78bSCy Schubert                          ref->u.support.ngroups * sizeof(int32_t)) == 0);
1037*7f2fe78bSCy Schubert         break;
1038*7f2fe78bSCy Schubert     case SPAKE_MSGTYPE_CHALLENGE:
1039*7f2fe78bSCy Schubert         p = p && struct_equal(u.challenge.pubkey,ktest_equal_data);
1040*7f2fe78bSCy Schubert         p = p && ptr_equal(u.challenge.factors,
1041*7f2fe78bSCy Schubert                            ktest_equal_sequence_of_spake_factor);
1042*7f2fe78bSCy Schubert         break;
1043*7f2fe78bSCy Schubert     case SPAKE_MSGTYPE_RESPONSE:
1044*7f2fe78bSCy Schubert         p = p && struct_equal(u.response.pubkey,ktest_equal_data);
1045*7f2fe78bSCy Schubert         p = p && struct_equal(u.response.factor,ktest_equal_enc_data);
1046*7f2fe78bSCy Schubert         break;
1047*7f2fe78bSCy Schubert     case SPAKE_MSGTYPE_ENCDATA:
1048*7f2fe78bSCy Schubert         p = p && struct_equal(u.encdata,ktest_equal_enc_data);
1049*7f2fe78bSCy Schubert         break;
1050*7f2fe78bSCy Schubert     default:
1051*7f2fe78bSCy Schubert         break;
1052*7f2fe78bSCy Schubert     }
1053*7f2fe78bSCy Schubert     return p;
1054*7f2fe78bSCy Schubert }
1055