libpurple/protocols/gg/lib/sha1.c

branch
release-2.x.y
changeset 35627
fd11790cc4d6
parent 35617
c9069e0e3c36
child 35630
8e5d0d726b09
child 35685
703d7d7bdf60
--- a/libpurple/protocols/gg/lib/sha1.c	Sun Mar 02 10:34:51 2014 +0100
+++ b/libpurple/protocols/gg/lib/sha1.c	Fri Mar 07 23:17:08 2014 +0100
@@ -88,20 +88,22 @@
 /* blk0() and blk() perform the initial expand. */
 /* I got the idea of expanding during the round function from SSLeay */
 #ifndef GG_CONFIG_BIGENDIAN
-#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
-    |(rol(block->l[i],8)&0x00FF00FF))
+#define blk0(i) (block->l[i] = (rol(block->l[i], 24) & 0xFF00FF00) \
+    |(rol(block->l[i], 8) & 0x00FF00FF))
 #else
 #define blk0(i) block->l[i]
 #endif
 #define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
-    ^block->l[(i+2)&15]^block->l[i&15],1))
+    ^block->l[(i+2)&15]^block->l[i&15], 1))
 
 /* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */
+/* style:comma:start-ignore */
 #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
 #define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
 #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
 #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
 #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
+/* style:comma:end-ignore */
 
 
 /* Hash a single 512-bit block. This is the core of the algorithm. */
@@ -124,6 +126,7 @@
     d = state[3];
     e = state[4];
     /* 4 rounds of 20 operations each. Loop unrolled. */
+    /* style:comma:start-ignore */
     R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
     R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
     R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
@@ -144,6 +147,7 @@
     R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
     R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
     R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
+    /* style:comma:end-ignore */
     /* Add the working vars back into context.state[] */
     state[0] += a;
     state[1] += b;
@@ -240,7 +244,7 @@
  * \param password Hasło
  * \param seed Ziarno
  * \param result Bufor na wynik funkcji skrótu (20 bajtów)
- * 
+ *
  * \return 0 lub -1
  */
 int gg_login_hash_sha1_2(const char *password, uint32_t seed, uint8_t *result)
@@ -256,7 +260,7 @@
 	seed = gg_fix32(seed);
 	if (!SHA1_Update(&ctx, (uint8_t*) &seed, 4))
 		goto fail;
-	
+
 	if (!SHA1_Final(result, &ctx))
 		return -1;
 
@@ -264,7 +268,7 @@
 
 fail:
 	/* Zwolnij zasoby. Tylko GnuTLS przyjęłoby NULL zamiast result, więc przekaż result. */
-	SHA1_Final(result, &ctx);
+	(void)SHA1_Final(result, &ctx);
 	return -1;
 }
 
@@ -296,7 +300,7 @@
 			chunk_len = sizeof(buf);
 
 		res = read(fd, buf, chunk_len);
-		
+
 		if (res == -1 && errno != EINTR)
 			break;
 
@@ -316,7 +320,7 @@
 
 /**
  * \internal Liczy skrót SHA1 z pliku.
- * 
+ *
  * Dla plików poniżej 10MB liczony jest skrót z całego pliku, dla plików
  * powyżej 10MB liczy się 9 jednomegabajtowych fragmentów.
  *

mercurial