Index: uspace/lib/crypto/crypto.c
===================================================================
--- uspace/lib/crypto/crypto.c	(revision a931b7b2faca447e0708fd5fae0f85116e4c788d)
+++ uspace/lib/crypto/crypto.c	(revision cc575ef99163b3a869a65477f280acca17c5bdd5)
@@ -54,7 +54,4 @@
 	(uint32_t)((val) - 1) : (uint32_t)(val))
 
-/* Left rotation for UINT32. */
-#define rotl_uint32(val, shift) (((val) << shift) | ((val) >> (32 - shift)))
-
 /* Pick value at specified index from array or zero if out of bounds. */
 #define get_at(input, size, i) (i < size ? input[i] : 0)
@@ -290,5 +287,5 @@
 	}
 	
-	uint8_t temp_work[HMAC_BLOCK_LENGTH + msg_size];
+	uint8_t temp_work[HMAC_BLOCK_LENGTH + max(msg_size, hash_sel)];
 	memcpy(temp_work, i_key_pad, HMAC_BLOCK_LENGTH);
 	memcpy(temp_work + HMAC_BLOCK_LENGTH, msg, msg_size);
@@ -328,5 +325,5 @@
 		return ENOMEM;
 	
-	uint8_t work_salt[salt_size + sizeof(uint32_t)];
+	uint8_t work_salt[salt_size + 4];
 	memcpy(work_salt, salt, salt_size);
 	uint8_t work_hmac[HASH_SHA1];
@@ -336,9 +333,10 @@
 	
 	for(size_t i = 0; i < 2; i++) {
-		uint32_t big_i = host2uint32_t_be(i+1);
-		memcpy(work_salt + salt_size, &big_i, sizeof(uint32_t));
-		hmac(pass, pass_size, work_salt, salt_size + sizeof(uint32_t),
+		uint32_t be_i = host2uint32_t_be(i+1);
+		memcpy(work_salt + salt_size, &be_i, 4);
+		hmac(pass, pass_size, work_salt, salt_size + 4,
 			work_hmac, HASH_SHA1);
 		memcpy(xor_hmac, work_hmac, HASH_SHA1);
+		
 		for(size_t k = 1; k < 4096; k++) {
 			memcpy(temp_hmac, work_hmac, HASH_SHA1);
Index: uspace/lib/crypto/crypto.h
===================================================================
--- uspace/lib/crypto/crypto.h	(revision a931b7b2faca447e0708fd5fae0f85116e4c788d)
+++ uspace/lib/crypto/crypto.h	(revision cc575ef99163b3a869a65477f280acca17c5bdd5)
@@ -35,4 +35,10 @@
 #define PBKDF2_KEY_LENGTH 32
 
+/* Left rotation for UINT32. */
+#define rotl_uint32(val, shift) (((val) << shift) | ((val) >> (32 - shift)))
+
+/* Right rotation for UINT32. */
+#define rotr_uint32(val, shift) (((val) >> shift) | ((val) << (32 - shift)))
+
 /** Hash function selector and also result hash length indicator. */
 typedef enum {
Index: uspace/lib/crypto/rc4.c
===================================================================
--- uspace/lib/crypto/rc4.c	(revision a931b7b2faca447e0708fd5fae0f85116e4c788d)
+++ uspace/lib/crypto/rc4.c	(revision cc575ef99163b3a869a65477f280acca17c5bdd5)
@@ -104,5 +104,5 @@
 	uint8_t i = 0, j = 0;
 	for(size_t k = 0; k < skip; k++) {
-		i = i+1;
+		i = i + 1;
 		j = j + sbox[i];
 		swap(i, j, sbox);
@@ -112,5 +112,5 @@
 	uint8_t val;
 	for(size_t k = 0; k < input_size; k++) {
-		i = i+1;
+		i = i + 1;
 		j = j + sbox[i];
 		swap(i, j, sbox);
