diff options
author | Perberos <[email protected]> | 2011-11-06 19:14:03 -0300 |
---|---|---|
committer | Perberos <[email protected]> | 2011-11-06 19:14:03 -0300 |
commit | f2a13175e5a3a38d1340d2fff5e03f8c2e0d8f8e (patch) | |
tree | 5bc248a29ae93e5534428e6908a94d50d419ceb9 /src/skey/sha1.c | |
parent | def492f92d29f294c62d94ef562dd6271bd9b84b (diff) | |
download | mate-terminal-f2a13175e5a3a38d1340d2fff5e03f8c2e0d8f8e.tar.bz2 mate-terminal-f2a13175e5a3a38d1340d2fff5e03f8c2e0d8f8e.tar.xz |
aplicando formato allman
Diffstat (limited to 'src/skey/sha1.c')
-rw-r--r-- | src/skey/sha1.c | 58 |
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); } |