X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=crypt_common.c;h=3a44dbdddcd1cf59108ba110c8d83c4fac11d609;hb=2bad70d84e763b4d866d7b97dbc1cdc8e030bd45;hp=ff24e356ab8d837f8d59d67a3c983d5264376db1;hpb=5d27648bfa9921f158e700151296af3e4c4fe13c;p=paraslash.git 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. *