summaryrefslogtreecommitdiff
path: root/src/skey/sha1.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/skey/sha1.c')
-rw-r--r--src/skey/sha1.c58
1 files changed, 30 insertions, 28 deletions
diff --git a/src/skey/sha1.c b/src/skey/sha1.c
index ac34ccc..d1c57d1 100644
--- a/src/skey/sha1.c
+++ b/src/skey/sha1.c
@@ -27,13 +27,15 @@
*/
static void byteReverse(unsigned char *buf, unsigned longs)
{
- guint32 t;
- do {
- t = (guint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
- ((unsigned) buf[1] << 8 | buf[0]);
- *(guint32 *) buf = t;
- buf += 4;
- } while (--longs);
+ guint32 t;
+ do
+ {
+ t = (guint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
+ ((unsigned) buf[1] << 8 | buf[0]);
+ *(guint32 *) buf = t;
+ buf += 4;
+ }
+ while (--longs);
}
#endif
@@ -41,10 +43,10 @@ static void byteReverse(unsigned char *buf, unsigned longs)
int SHA1Keycrunch(char *result, const char *seed, const char *passphrase)
{
char *buf;
- gsize len;
- GChecksum *checksum;
- guint8 digest[20];
- gsize digest_len = sizeof (digest);
+ gsize len;
+ GChecksum *checksum;
+ guint8 digest[20];
+ gsize digest_len = sizeof (digest);
guint32 *results;
len = strlen(seed) + strlen(passphrase);
@@ -56,14 +58,14 @@ int SHA1Keycrunch(char *result, const char *seed, const char *passphrase)
strcat(buf, passphrase);
skey_sevenbit(buf);
- checksum = g_checksum_new (G_CHECKSUM_SHA1);
- g_checksum_update (checksum, (const guchar *) buf, len);
+ checksum = g_checksum_new (G_CHECKSUM_SHA1);
+ g_checksum_update (checksum, (const guchar *) buf, len);
g_free(buf);
- g_checksum_get_digest (checksum, digest, &digest_len);
- g_assert (digest_len == 20);
+ g_checksum_get_digest (checksum, digest, &digest_len);
+ g_assert (digest_len == 20);
- results = (guint32 *) digest;
+ results = (guint32 *) digest;
#ifndef WORDS_BIGENDIAN
HTONDIGEST(results);
@@ -71,31 +73,31 @@ int SHA1Keycrunch(char *result, const char *seed, const char *passphrase)
byteReverse((unsigned char *)digest, 5);
#endif
- results = (guint32 *) digest;
- results[0] ^= results[2];
+ results = (guint32 *) digest;
+ results[0] ^= results[2];
results[1] ^= results[3];
results[0] ^= results[4];
memcpy((void *)result, (void *)results, SKEY_SIZE);
- g_checksum_free (checksum);
+ g_checksum_free (checksum);
return 0;
}
void SHA1SKey(char *x)
{
- GChecksum *checksum;
- guint8 digest[20];
- gsize digest_len = sizeof (digest);
+ GChecksum *checksum;
+ guint8 digest[20];
+ gsize digest_len = sizeof (digest);
guint32 *results;
- checksum = g_checksum_new (G_CHECKSUM_SHA1);
- g_checksum_update (checksum, (const guchar *) x, SKEY_SIZE);
- g_checksum_get_digest (checksum, digest, &digest_len);
- g_assert (digest_len == 20);
+ checksum = g_checksum_new (G_CHECKSUM_SHA1);
+ g_checksum_update (checksum, (const guchar *) x, SKEY_SIZE);
+ g_checksum_get_digest (checksum, digest, &digest_len);
+ g_assert (digest_len == 20);
- results = (guint32 *) digest;
+ results = (guint32 *) digest;
#ifndef WORDS_BIGENDIAN
HTONDIGEST(results);
#else
@@ -108,5 +110,5 @@ void SHA1SKey(char *x)
memcpy((void *)x, (void *)results, SKEY_SIZE);
- g_checksum_free (checksum);
+ g_checksum_free (checksum);
}