2 * lib/krb5/krb/princ_comp.c
4 * Copyright 1990,1991 by the Massachusetts Institute of Technology.
7 * Export of this software from the United States of America may
8 * require a specific license from the United States Government.
9 * It is the responsibility of any person or organization contemplating
10 * export to obtain such a license before exporting.
12 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
13 * distribute this software and its documentation for any purpose and
14 * without fee is hereby granted, provided that the above copyright
15 * notice appear in all copies and that both that copyright notice and
16 * this permission notice appear in supporting documentation, and that
17 * the name of M.I.T. not be used in advertising or publicity pertaining
18 * to distribution of the software without specific, written prior
19 * permission. M.I.T. makes no representations about the suitability of
20 * this software for any purpose. It is provided "as is" without express
21 * or implied warranty.
24 * compare two principals, returning a krb5_boolean true if equal, false if
30 krb5_boolean INTERFACE
31 krb5_realm_compare(context, princ1, princ2)
33 krb5_const_principal princ1;
34 krb5_const_principal princ2;
36 if (krb5_princ_realm(context, princ1)->length !=
37 krb5_princ_realm(context, princ2)->length ||
38 memcmp (krb5_princ_realm(context, princ1)->data,
39 krb5_princ_realm(context, princ2)->data,
40 krb5_princ_realm(context, princ2)->length))
46 krb5_boolean INTERFACE
47 krb5_principal_compare(context, princ1, princ2)
49 krb5_const_principal princ1;
50 krb5_const_principal princ2;
55 nelem = krb5_princ_size(context, princ1);
56 if (nelem != krb5_princ_size(context, princ2))
59 if (! krb5_realm_compare(context, princ1, princ2))
62 for (i = 0; i < (int) nelem; i++) {
63 register const krb5_data *p1 = krb5_princ_component(context, princ1, i);
64 register const krb5_data *p2 = krb5_princ_component(context, princ2, i);
65 if (p1->length != p2->length ||
66 memcmp(p1->data, p2->data, p1->length))