diff options
author | Andrew Bartlett <abartlet@samba.org> | 2005-08-09 03:04:47 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:31:33 -0500 |
commit | c0e8144c5d1e402b36ebe04b843eba62e7ab9958 (patch) | |
tree | 1b885ceee1a88e8cb2822051690b023c8f8acb78 /source4/heimdal/lib/asn1/der_cmp.c | |
parent | 4b93e377cd9809199487e20fa53d8a2c98ad32ea (diff) | |
download | samba-c0e8144c5d1e402b36ebe04b843eba62e7ab9958.tar.gz samba-c0e8144c5d1e402b36ebe04b843eba62e7ab9958.tar.bz2 samba-c0e8144c5d1e402b36ebe04b843eba62e7ab9958.zip |
r9221: Try to merge Heimdal across from lorikeet-heimdal to samba4.
This is my first attempt at this, so there may be a few rough edges.
Andrew Bartlett
(This used to be commit 9a1d2f2fec67930975da856a2d365345cec46216)
Diffstat (limited to 'source4/heimdal/lib/asn1/der_cmp.c')
-rwxr-xr-x | source4/heimdal/lib/asn1/der_cmp.c | 51 |
1 files changed, 48 insertions, 3 deletions
diff --git a/source4/heimdal/lib/asn1/der_cmp.c b/source4/heimdal/lib/asn1/der_cmp.c index a5ed7ff2b3..306fcbdf57 100755 --- a/source4/heimdal/lib/asn1/der_cmp.c +++ b/source4/heimdal/lib/asn1/der_cmp.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003 - 2004 Kungliga Tekniska Högskolan + * Copyright (c) 2003-2005 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -33,8 +33,6 @@ #include "der_locl.h" -RCSID("$Id: der_cmp.c,v 1.2 2004/04/26 20:54:02 lha Exp $"); - int heim_oid_cmp(const heim_oid *p, const heim_oid *q) { @@ -52,3 +50,50 @@ heim_octet_string_cmp(const heim_octet_string *p, const heim_octet_string *q) return p->length - q->length; return memcmp(p->data, q->data, p->length); } + +int +heim_bit_string_cmp(const heim_bit_string *p, const heim_bit_string *q) +{ + int i, r1, r2; + if (p->length != q->length) + return p->length - q->length; + i = memcmp(p->data, q->data, p->length / 8); + if (i) + return i; + if ((p->length % 8) == 0) + return 0; + i = (p->length / 8); + r1 = ((unsigned char *)p->data)[i]; + r2 = ((unsigned char *)q->data)[i]; + i = 8 - (p->length % 8); + r1 = r1 >> i; + r2 = r2 >> i; + return r1 - r2; +} + +int +heim_integer_cmp(const heim_integer *p, const heim_integer *q) +{ + if (p->length != q->length) + return p->length - q->length; + if (p->negative != q->negative) + return p->negative - q->negative; + return memcmp(p->data, q->data, p->length); +} + +int +heim_bmp_string_cmp(const heim_bmp_string *p, const heim_bmp_string *q) +{ + if (p->length != q->length) + return p->length - q->length; + return memcmp(p->data, q->data, q->length * sizeof(q->data[0])); +} + +int +heim_universal_string_cmp(const heim_universal_string *p, + const heim_universal_string *q) +{ + if (p->length != q->length) + return p->length - q->length; + return memcmp(p->data, q->data, q->length * sizeof(q->data[0])); +} |