Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ef2736fc authored by Herbert Xu's avatar Herbert Xu Committed by David S. Miller
Browse files

[CRYPTO]: White space and coding style clean up in tcrypt

parent dd7f0b80
Loading
Loading
Loading
Loading
+165 −168
Original line number Original line Diff line number Diff line
@@ -66,8 +66,7 @@ static char *check[] = {
	"khazad", "wp512", "wp384", "wp256", "tnepres", NULL
	"khazad", "wp512", "wp384", "wp256", "tnepres", NULL
};
};


static void
static void hexdump(unsigned char *buf, unsigned int len)
hexdump(unsigned char *buf, unsigned int len)
{
{
	while (len--)
	while (len--)
		printk("%02x", *buf++);
		printk("%02x", *buf++);
@@ -75,8 +74,8 @@ hexdump(unsigned char *buf, unsigned int len)
	printk("\n");
	printk("\n");
}
}


static void 
static void test_hash(char *algo, struct hash_testvec *template,
test_hash (char * algo, struct hash_testvec * template, unsigned int tcount)
		      unsigned int tcount)
{
{
	char *p;
	char *p;
	unsigned int i, j, k, temp;
	unsigned int i, j, k, temp;
@@ -124,8 +123,8 @@ test_hash (char * algo, struct hash_testvec * template, unsigned int tcount)
		hexdump(result, crypto_tfm_alg_digestsize(tfm));
		hexdump(result, crypto_tfm_alg_digestsize(tfm));
		printk("%s\n",
		printk("%s\n",
		       memcmp(result, hash_tv[i].digest,
		       memcmp(result, hash_tv[i].digest,
				crypto_tfm_alg_digestsize(tfm)) ? "fail" :
			      crypto_tfm_alg_digestsize(tfm)) ?
			"pass");
		       "fail" : "pass");
	}
	}


	printk("testing %s across pages\n", algo);
	printk("testing %s across pages\n", algo);
@@ -142,7 +141,8 @@ test_hash (char * algo, struct hash_testvec * template, unsigned int tcount)


			temp = 0;
			temp = 0;
			for (k = 0; k < hash_tv[i].np; k++) {
			for (k = 0; k < hash_tv[i].np; k++) {
				memcpy (&xbuf[IDX[k]], hash_tv[i].plaintext + temp, 
				memcpy(&xbuf[IDX[k]],
				       hash_tv[i].plaintext + temp,
				       hash_tv[i].tap[k]);
				       hash_tv[i].tap[k]);
				temp += hash_tv[i].tap[k];
				temp += hash_tv[i].tap[k];
				p = &xbuf[IDX[k]];
				p = &xbuf[IDX[k]];
@@ -156,8 +156,8 @@ test_hash (char * algo, struct hash_testvec * template, unsigned int tcount)
			hexdump(result, crypto_tfm_alg_digestsize(tfm));
			hexdump(result, crypto_tfm_alg_digestsize(tfm));
			printk("%s\n",
			printk("%s\n",
			       memcmp(result, hash_tv[i].digest,
			       memcmp(result, hash_tv[i].digest,
					crypto_tfm_alg_digestsize(tfm)) ? "fail" :
				      crypto_tfm_alg_digestsize(tfm)) ?
				"pass");
			       "fail" : "pass");
		}
		}
	}
	}


@@ -167,8 +167,8 @@ test_hash (char * algo, struct hash_testvec * template, unsigned int tcount)


#ifdef CONFIG_CRYPTO_HMAC
#ifdef CONFIG_CRYPTO_HMAC


static void
static void test_hmac(char *algo, struct hmac_testvec *template,
test_hmac(char *algo, struct hmac_testvec * template, unsigned int tcount)
		      unsigned int tcount)
{
{
	char *p;
	char *p;
	unsigned int i, j, k, temp;
	unsigned int i, j, k, temp;
@@ -230,7 +230,8 @@ test_hmac(char *algo, struct hmac_testvec * template, unsigned int tcount)
			temp = 0;
			temp = 0;
			klen = hmac_tv[i].ksize;
			klen = hmac_tv[i].ksize;
			for (k = 0; k < hmac_tv[i].np; k++) {
			for (k = 0; k < hmac_tv[i].np; k++) {
				memcpy (&xbuf[IDX[k]], hmac_tv[i].plaintext + temp, 
				memcpy(&xbuf[IDX[k]],
				       hmac_tv[i].plaintext + temp,
				       hmac_tv[i].tap[k]);
				       hmac_tv[i].tap[k]);
				temp += hmac_tv[i].tap[k];
				temp += hmac_tv[i].tap[k];
				p = &xbuf[IDX[k]];
				p = &xbuf[IDX[k]];
@@ -239,14 +240,14 @@ test_hmac(char *algo, struct hmac_testvec * template, unsigned int tcount)
				sg[k].length = hmac_tv[i].tap[k];
				sg[k].length = hmac_tv[i].tap[k];
			}
			}


			crypto_hmac(tfm, hmac_tv[i].key, &klen, sg, hmac_tv[i].np, 
			crypto_hmac(tfm, hmac_tv[i].key, &klen, sg,
					result);
				    hmac_tv[i].np, result);
			hexdump(result, crypto_tfm_alg_digestsize(tfm));
			hexdump(result, crypto_tfm_alg_digestsize(tfm));


			printk("%s\n",
			printk("%s\n",
			       memcmp(result, hmac_tv[i].digest,
			       memcmp(result, hmac_tv[i].digest,
					crypto_tfm_alg_digestsize(tfm)) ? "fail" : 
				      crypto_tfm_alg_digestsize(tfm)) ?
				"pass");
			       "fail" : "pass");
		}
		}
	}
	}
out:
out:
@@ -255,8 +256,8 @@ test_hmac(char *algo, struct hmac_testvec * template, unsigned int tcount)


#endif	/* CONFIG_CRYPTO_HMAC */
#endif	/* CONFIG_CRYPTO_HMAC */


static void
static void test_cipher(char *algo, int mode, int enc,
test_cipher(char * algo, int mode, int enc, struct cipher_testvec * template, unsigned int tcount)
			struct cipher_testvec *template, unsigned int tcount)
{
{
	unsigned int ret, i, j, k, temp;
	unsigned int ret, i, j, k, temp;
	unsigned int tsize;
	unsigned int tsize;
@@ -345,8 +346,8 @@ test_cipher(char * algo, int mode, int enc, struct cipher_testvec * template, un
			hexdump(q, cipher_tv[i].rlen);
			hexdump(q, cipher_tv[i].rlen);


			printk("%s\n",
			printk("%s\n",
				memcmp(q, cipher_tv[i].result, cipher_tv[i].rlen) ? "fail" : 
			       memcmp(q, cipher_tv[i].result,
			"pass");
				      cipher_tv[i].rlen) ? "fail" : "pass");
		}
		}
	}
	}


@@ -375,7 +376,8 @@ test_cipher(char * algo, int mode, int enc, struct cipher_testvec * template, un


			temp = 0;
			temp = 0;
			for (k = 0; k < cipher_tv[i].np; k++) {
			for (k = 0; k < cipher_tv[i].np; k++) {
				memcpy (&xbuf[IDX[k]], cipher_tv[i].input + temp, 
				memcpy(&xbuf[IDX[k]],
				       cipher_tv[i].input + temp,
				       cipher_tv[i].tap[k]);
				       cipher_tv[i].tap[k]);
				temp += cipher_tv[i].tap[k];
				temp += cipher_tv[i].tap[k];
				p = &xbuf[IDX[k]];
				p = &xbuf[IDX[k]];
@@ -417,8 +419,7 @@ test_cipher(char * algo, int mode, int enc, struct cipher_testvec * template, un
	crypto_free_tfm(tfm);
	crypto_free_tfm(tfm);
}
}


static void
static void test_deflate(void)
test_deflate(void)
{
{
	unsigned int i;
	unsigned int i;
	char result[COMP_BUF_SIZE];
	char result[COMP_BUF_SIZE];
@@ -497,8 +498,7 @@ test_deflate(void)
	crypto_free_tfm(tfm);
	crypto_free_tfm(tfm);
}
}


static void
static void test_crc32c(void)
test_crc32c(void)
{
{
#define NUMVEC 6
#define NUMVEC 6
#define VECSIZE 40
#define VECSIZE 40
@@ -598,8 +598,7 @@ test_crc32c(void)
	printk("crc32c test complete\n");
	printk("crc32c test complete\n");
}
}


static void
static void test_available(void)
test_available(void)
{
{
	char **name = check;
	char **name = check;


@@ -611,8 +610,7 @@ test_available(void)
	}
	}
}
}


static void
static void do_test(void)
do_test(void)
{
{
	switch (mode) {
	switch (mode) {


@@ -874,8 +872,7 @@ do_test(void)
	}
	}
}
}


static int __init
static int __init init(void)
init(void)
{
{
	tvmem = kmalloc(TVMEMSIZE, GFP_KERNEL);
	tvmem = kmalloc(TVMEMSIZE, GFP_KERNEL);
	if (tvmem == NULL)
	if (tvmem == NULL)
+171 −186
Original line number Original line Diff line number Diff line
@@ -1578,8 +1578,7 @@ static struct cipher_testvec tf_cbc_dec_tv_template[] = {
#define TNEPRES_ENC_TEST_VECTORS	4
#define TNEPRES_ENC_TEST_VECTORS	4
#define TNEPRES_DEC_TEST_VECTORS	4
#define TNEPRES_DEC_TEST_VECTORS	4


static struct cipher_testvec serpent_enc_tv_template[] = 
static struct cipher_testvec serpent_enc_tv_template[] = {
{
	{
	{
		.input	= { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
		.input	= { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
			    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
			    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
@@ -1620,8 +1619,7 @@ static struct cipher_testvec serpent_enc_tv_template[] =
	},
	},
};
};


static struct cipher_testvec tnepres_enc_tv_template[] = 
static struct cipher_testvec tnepres_enc_tv_template[] = {
{
	{ /* KeySize=128, PT=0, I=1 */
	{ /* KeySize=128, PT=0, I=1 */
		.input	= { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		.input	= { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
			    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
			    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
@@ -1671,8 +1669,7 @@ static struct cipher_testvec tnepres_enc_tv_template[] =
};
};




static struct cipher_testvec serpent_dec_tv_template[] = 
static struct cipher_testvec serpent_dec_tv_template[] = {
{
	{
	{
		.input	= { 0x12, 0x07, 0xfc, 0xce, 0x9b, 0xd0, 0xd6, 0x47,
		.input	= { 0x12, 0x07, 0xfc, 0xce, 0x9b, 0xd0, 0xd6, 0x47,
			    0x6a, 0xe9, 0x8f, 0xbe, 0xd1, 0x43, 0xa0, 0xe2 },
			    0x6a, 0xe9, 0x8f, 0xbe, 0xd1, 0x43, 0xa0, 0xe2 },
@@ -1713,8 +1710,7 @@ static struct cipher_testvec serpent_dec_tv_template[] =
	},
	},
};
};


static struct cipher_testvec tnepres_dec_tv_template[] =
static struct cipher_testvec tnepres_dec_tv_template[] = {
{
	{
	{
		.input	= { 0x41, 0xcc, 0x6b, 0x31, 0x59, 0x31, 0x45, 0x97,
		.input	= { 0x41, 0xcc, 0x6b, 0x31, 0x59, 0x31, 0x45, 0x97,
			    0x6d, 0x6f, 0xbb, 0x38, 0x4b, 0x37, 0x21, 0x28 },
			    0x6d, 0x6f, 0xbb, 0x38, 0x4b, 0x37, 0x21, 0x28 },
@@ -1760,8 +1756,7 @@ static struct cipher_testvec tnepres_dec_tv_template[] =
#define CAST6_ENC_TEST_VECTORS	3
#define CAST6_ENC_TEST_VECTORS	3
#define CAST6_DEC_TEST_VECTORS  3
#define CAST6_DEC_TEST_VECTORS  3


static struct cipher_testvec cast6_enc_tv_template[] = 
static struct cipher_testvec cast6_enc_tv_template[] = {
{
	{
	{
		.key	= { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
		.key	= { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
			    0x0a, 0xf7, 0x56, 0x47, 0xf2, 0x9f, 0x61, 0x5d },
			    0x0a, 0xf7, 0x56, 0x47, 0xf2, 0x9f, 0x61, 0x5d },
@@ -1795,8 +1790,7 @@ static struct cipher_testvec cast6_enc_tv_template[] =
	},
	},
};
};


static struct cipher_testvec cast6_dec_tv_template[] = 
static struct cipher_testvec cast6_dec_tv_template[] = {
{
	{
	{
		.key	= { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
		.key	= { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
			    0x0a, 0xf7, 0x56, 0x47, 0xf2, 0x9f, 0x61, 0x5d },
			    0x0a, 0xf7, 0x56, 0x47, 0xf2, 0x9f, 0x61, 0x5d },
@@ -1915,8 +1909,7 @@ static struct cipher_testvec aes_dec_tv_template[] = {
#define CAST5_ENC_TEST_VECTORS	3
#define CAST5_ENC_TEST_VECTORS	3
#define CAST5_DEC_TEST_VECTORS	3
#define CAST5_DEC_TEST_VECTORS	3


static struct cipher_testvec cast5_enc_tv_template[] =
static struct cipher_testvec cast5_enc_tv_template[] = {
{
	{
	{
		.key	= { 0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
		.key	= { 0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
			    0x23, 0x45, 0x67, 0x89, 0x34, 0x56, 0x78, 0x9a },
			    0x23, 0x45, 0x67, 0x89, 0x34, 0x56, 0x78, 0x9a },
@@ -1943,8 +1936,7 @@ static struct cipher_testvec cast5_enc_tv_template[] =
	},
	},
};
};


static struct cipher_testvec cast5_dec_tv_template[] =
static struct cipher_testvec cast5_dec_tv_template[] = {
{
	{
	{
		.key	= { 0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
		.key	= { 0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
			    0x23, 0x45, 0x67, 0x89, 0x34, 0x56, 0x78, 0x9a },
			    0x23, 0x45, 0x67, 0x89, 0x34, 0x56, 0x78, 0x9a },
@@ -1977,8 +1969,7 @@ static struct cipher_testvec cast5_dec_tv_template[] =
#define ARC4_ENC_TEST_VECTORS	7
#define ARC4_ENC_TEST_VECTORS	7
#define ARC4_DEC_TEST_VECTORS	7
#define ARC4_DEC_TEST_VECTORS	7


static struct cipher_testvec arc4_enc_tv_template[] =
static struct cipher_testvec arc4_enc_tv_template[] = {
{
	{
	{
		.key	= { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
		.key	= { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
		.klen	= 8,
		.klen	= 8,
@@ -2044,8 +2035,7 @@ static struct cipher_testvec arc4_enc_tv_template[] =
	},
	},
};
};


static struct cipher_testvec arc4_dec_tv_template[] =
static struct cipher_testvec arc4_dec_tv_template[] = {
{
	{
	{
		.key	= { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
		.key	= { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
		.klen	= 8,
		.klen	= 8,
@@ -2117,8 +2107,7 @@ static struct cipher_testvec arc4_dec_tv_template[] =
#define TEA_ENC_TEST_VECTORS	4
#define TEA_ENC_TEST_VECTORS	4
#define TEA_DEC_TEST_VECTORS	4
#define TEA_DEC_TEST_VECTORS	4


static struct cipher_testvec tea_enc_tv_template[] =
static struct cipher_testvec tea_enc_tv_template[] = {
{
	{
	{
		.key    = { [0 ... 15] = 0x00 },
		.key    = { [0 ... 15] = 0x00 },
		.klen	= 16,
		.klen	= 16,
@@ -2161,8 +2150,7 @@ static struct cipher_testvec tea_enc_tv_template[] =
	}
	}
};
};


static struct cipher_testvec tea_dec_tv_template[] =
static struct cipher_testvec tea_dec_tv_template[] = {
{
	{
	{
		.key    = { [0 ... 15] = 0x00 },
		.key    = { [0 ... 15] = 0x00 },
		.klen	= 16,
		.klen	= 16,
@@ -2211,8 +2199,7 @@ static struct cipher_testvec tea_dec_tv_template[] =
#define XTEA_ENC_TEST_VECTORS	4
#define XTEA_ENC_TEST_VECTORS	4
#define XTEA_DEC_TEST_VECTORS	4
#define XTEA_DEC_TEST_VECTORS	4


static struct cipher_testvec xtea_enc_tv_template[] =
static struct cipher_testvec xtea_enc_tv_template[] = {
{
	{
	{
		.key    = { [0 ... 15] = 0x00 },
		.key    = { [0 ... 15] = 0x00 },
		.klen	= 16,
		.klen	= 16,
@@ -2255,8 +2242,7 @@ static struct cipher_testvec xtea_enc_tv_template[] =
	}
	}
};
};


static struct cipher_testvec xtea_dec_tv_template[] =
static struct cipher_testvec xtea_dec_tv_template[] = {
{
	{
	{
		.key    = { [0 ... 15] = 0x00 },
		.key    = { [0 ... 15] = 0x00 },
		.klen	= 16,
		.klen	= 16,
@@ -2697,8 +2683,7 @@ static struct comp_testvec deflate_decomp_tv_template[] = {
 */
 */
#define MICHAEL_MIC_TEST_VECTORS 6
#define MICHAEL_MIC_TEST_VECTORS 6


static struct hash_testvec michael_mic_tv_template[] =
static struct hash_testvec michael_mic_tv_template[] = {
{
	{
	{
		.key = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
		.key = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
		.ksize = 8,
		.ksize = 8,