summaryrefslogtreecommitdiff
path: root/dbus/dbus-sha.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2003-02-24 02:24:13 +0000
committerHavoc Pennington <hp@redhat.com>2003-02-24 02:24:13 +0000
commit2f38c959212d98e2194139daa9120fda37415b4f (patch)
tree725edc511caad936a6ab424d451533c9ce3ff48e /dbus/dbus-sha.c
parent32b4b2a2f6b4dc7b2ee07f1efb75ec8c871ca04b (diff)
downloaddbus-2f38c959212d98e2194139daa9120fda37415b4f.tar.gz
2003-02-23 Havoc Pennington <hp@pobox.com>
* dbus/dbus-keyring.c: finish most of this implementation and simple unit test * dbus/dbus-errors.c (dbus_set_error_const, dbus_set_error): make these barf if the error isn't cleared to NULL * dbus/dbus-sysdeps.c (_dbus_delete_file): set error on failure (_dbus_create_directory): new function * dbus/dbus-errors.c (dbus_set_error): fix warning * dbus/dbus-string.c (_dbus_string_hex_encode): new function (_dbus_string_hex_decode): new function (test_hex_roundtrip): test code * dbus/dbus-sha.c (_dbus_sha_compute): use dbus_string_hex_encode * dbus/dbus-md5.c (_dbus_md5_compute): use dbus_string_hex_encode * dbus/dbus-sysdeps.c (_dbus_string_save_to_file): make this use the save-to-temp/rename trick to atomically write the new file (_dbus_string_parse_uint): new function
Diffstat (limited to 'dbus/dbus-sha.c')
-rw-r--r--dbus/dbus-sha.c28
1 files changed, 3 insertions, 25 deletions
diff --git a/dbus/dbus-sha.c b/dbus/dbus-sha.c
index d0a8e4fb..2035a475 100644
--- a/dbus/dbus-sha.c
+++ b/dbus/dbus-sha.c
@@ -484,13 +484,6 @@ _dbus_sha_compute (const DBusString *data,
{
DBusSHAContext context;
DBusString digest;
- const char hexdigits[16] = {
- '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
- 'a', 'b', 'c', 'd', 'e', 'f'
- };
- unsigned char *p;
- unsigned char *end;
- int orig_len;
_dbus_sha_init (&context);
@@ -499,32 +492,17 @@ _dbus_sha_compute (const DBusString *data,
if (!_dbus_string_init (&digest, _DBUS_INT_MAX))
return FALSE;
- orig_len = _dbus_string_get_length (ascii_output);
-
if (!_dbus_sha_final (&context, &digest))
goto error;
- _dbus_string_get_const_data (&digest, (const char **) &p);
- end = p + 20;
-
- while (p != end)
- {
- if (!_dbus_string_append_byte (ascii_output,
- hexdigits[(*p >> 4)]))
- goto error;
-
- if (!_dbus_string_append_byte (ascii_output,
- hexdigits[(*p & 0x0f)]))
- goto error;
-
- ++p;
- }
+ if (!_dbus_string_hex_encode (&digest, 0, ascii_output,
+ _dbus_string_get_length (ascii_output)))
+ goto error;
return TRUE;
error:
_dbus_string_free (&digest);
- _dbus_string_set_length (ascii_output, orig_len);
return FALSE;
}