X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=crypt_common.c;fp=crypt_common.c;h=3a44dbdddcd1cf59108ba110c8d83c4fac11d609;hp=ff24e356ab8d837f8d59d67a3c983d5264376db1;hb=e74113b0e1a6ca1c047667218b089362372aa0f0;hpb=d44413588dd70fe7e6b08a97dde6456b45db9280 diff --git a/crypt_common.c b/crypt_common.c index ff24e356..3a44dbdd 100644 --- a/crypt_common.c +++ b/crypt_common.c @@ -160,6 +160,31 @@ int hash_compare(const unsigned char *h1, const unsigned char *h2) return 0; } +void hash2_to_asc(const unsigned char *hash, char *asc) +{ + int i; + const char hexchar[] = "0123456789abcdef"; + + for (i = 0; i < HASH2_SIZE; i++) { + asc[2 * i] = hexchar[hash[i] >> 4]; + asc[2 * i + 1] = hexchar[hash[i] & 0xf]; + } + asc[2 * HASH2_SIZE] = '\0'; +} + +int hash2_compare(const unsigned char *h1, const unsigned char *h2) +{ + int i; + + for (i = 0; i < HASH2_SIZE; i++) { + if (h1[i] < h2[i]) + return -1; + if (h1[i] > h2[i]) + return 1; + } + return 0; +} + /** * Check header of an openssh private key and compute bignum offset. *