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

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

Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent dd7f0b80
......@@ -66,8 +66,7 @@ static char *check[] = {
"khazad", "wp512", "wp384", "wp256", "tnepres", NULL
};
static void
hexdump(unsigned char *buf, unsigned int len)
static void hexdump(unsigned char *buf, unsigned int len)
{
while (len--)
printk("%02x", *buf++);
......@@ -75,8 +74,8 @@ hexdump(unsigned char *buf, unsigned int len)
printk("\n");
}
static void
test_hash (char * algo, struct hash_testvec * template, unsigned int tcount)
static void test_hash(char *algo, struct hash_testvec *template,
unsigned int tcount)
{
char *p;
unsigned int i, j, k, temp;
......@@ -88,7 +87,7 @@ test_hash (char * algo, struct hash_testvec * template, unsigned int tcount)
printk("\ntesting %s\n", algo);
tsize = sizeof (struct hash_testvec);
tsize = sizeof(struct hash_testvec);
tsize *= tcount;
if (tsize > TVMEMSIZE) {
......@@ -97,7 +96,7 @@ test_hash (char * algo, struct hash_testvec * template, unsigned int tcount)
}
memcpy(tvmem, template, tsize);
hash_tv = (void *) tvmem;
hash_tv = (void *)tvmem;
tfm = crypto_alloc_tfm(algo, 0);
if (tfm == NULL) {
printk("failed to load transform for %s\n", algo);
......@@ -105,30 +104,30 @@ test_hash (char * algo, struct hash_testvec * template, unsigned int tcount)
}
for (i = 0; i < tcount; i++) {
printk ("test %u:\n", i + 1);
memset (result, 0, 64);
printk("test %u:\n", i + 1);
memset(result, 0, 64);
p = hash_tv[i].plaintext;
sg[0].page = virt_to_page (p);
sg[0].offset = offset_in_page (p);
sg[0].page = virt_to_page(p);
sg[0].offset = offset_in_page(p);
sg[0].length = hash_tv[i].psize;
crypto_digest_init (tfm);
crypto_digest_init(tfm);
if (tfm->crt_u.digest.dit_setkey) {
crypto_digest_setkey (tfm, hash_tv[i].key,
crypto_digest_setkey(tfm, hash_tv[i].key,
hash_tv[i].ksize);
}
crypto_digest_update (tfm, sg, 1);
crypto_digest_final (tfm, result);
crypto_digest_update(tfm, sg, 1);
crypto_digest_final(tfm, result);
hexdump (result, crypto_tfm_alg_digestsize (tfm));
hexdump(result, crypto_tfm_alg_digestsize(tfm));
printk("%s\n",
memcmp(result, hash_tv[i].digest,
crypto_tfm_alg_digestsize(tfm)) ? "fail" :
"pass");
crypto_tfm_alg_digestsize(tfm)) ?
"fail" : "pass");
}
printk ("testing %s across pages\n", algo);
printk("testing %s across pages\n", algo);
/* setup the dummy buffer first */
memset(xbuf, 0, XBUFSIZE);
......@@ -137,38 +136,39 @@ test_hash (char * algo, struct hash_testvec * template, unsigned int tcount)
for (i = 0; i < tcount; i++) {
if (hash_tv[i].np) {
j++;
printk ("test %u:\n", j);
memset (result, 0, 64);
printk("test %u:\n", j);
memset(result, 0, 64);
temp = 0;
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]);
temp += hash_tv[i].tap[k];
p = &xbuf[IDX[k]];
sg[k].page = virt_to_page (p);
sg[k].offset = offset_in_page (p);
sg[k].page = virt_to_page(p);
sg[k].offset = offset_in_page(p);
sg[k].length = hash_tv[i].tap[k];
}
crypto_digest_digest (tfm, sg, hash_tv[i].np, result);
crypto_digest_digest(tfm, sg, hash_tv[i].np, result);
hexdump (result, crypto_tfm_alg_digestsize (tfm));
hexdump(result, crypto_tfm_alg_digestsize(tfm));
printk("%s\n",
memcmp(result, hash_tv[i].digest,
crypto_tfm_alg_digestsize(tfm)) ? "fail" :
"pass");
crypto_tfm_alg_digestsize(tfm)) ?
"fail" : "pass");
}
}
crypto_free_tfm (tfm);
crypto_free_tfm(tfm);
}
#ifdef CONFIG_CRYPTO_HMAC
static void
test_hmac(char *algo, struct hmac_testvec * template, unsigned int tcount)
static void test_hmac(char *algo, struct hmac_testvec *template,
unsigned int tcount)
{
char *p;
unsigned int i, j, k, temp;
......@@ -186,7 +186,7 @@ test_hmac(char *algo, struct hmac_testvec * template, unsigned int tcount)
printk("\ntesting hmac_%s\n", algo);
tsize = sizeof (struct hmac_testvec);
tsize = sizeof(struct hmac_testvec);
tsize *= tcount;
if (tsize > TVMEMSIZE) {
printk("template (%u) too big for tvmem (%u)\n", tsize,
......@@ -195,7 +195,7 @@ test_hmac(char *algo, struct hmac_testvec * template, unsigned int tcount)
}
memcpy(tvmem, template, tsize);
hmac_tv = (void *) tvmem;
hmac_tv = (void *)tvmem;
for (i = 0; i < tcount; i++) {
printk("test %u:\n", i + 1);
......@@ -224,29 +224,30 @@ test_hmac(char *algo, struct hmac_testvec * template, unsigned int tcount)
for (i = 0; i < tcount; i++) {
if (hmac_tv[i].np) {
j++;
printk ("test %u:\n",j);
memset (result, 0, 64);
printk("test %u:\n",j);
memset(result, 0, 64);
temp = 0;
klen = hmac_tv[i].ksize;
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]);
temp += hmac_tv[i].tap[k];
p = &xbuf[IDX[k]];
sg[k].page = virt_to_page (p);
sg[k].offset = offset_in_page (p);
sg[k].page = virt_to_page(p);
sg[k].offset = offset_in_page(p);
sg[k].length = hmac_tv[i].tap[k];
}
crypto_hmac(tfm, hmac_tv[i].key, &klen, sg, hmac_tv[i].np,
result);
crypto_hmac(tfm, hmac_tv[i].key, &klen, sg,
hmac_tv[i].np, result);
hexdump(result, crypto_tfm_alg_digestsize(tfm));
printk("%s\n",
memcmp(result, hmac_tv[i].digest,
crypto_tfm_alg_digestsize(tfm)) ? "fail" :
"pass");
crypto_tfm_alg_digestsize(tfm)) ?
"fail" : "pass");
}
}
out:
......@@ -255,8 +256,8 @@ out:
#endif /* CONFIG_CRYPTO_HMAC */
static void
test_cipher(char * algo, int mode, int enc, struct cipher_testvec * template, unsigned int tcount)
static void test_cipher(char *algo, int mode, int enc,
struct cipher_testvec *template, unsigned int tcount)
{
unsigned int ret, i, j, k, temp;
unsigned int tsize;
......@@ -276,7 +277,7 @@ test_cipher(char * algo, int mode, int enc, struct cipher_testvec * template, un
else
strncpy(m, "CBC", 4);
printk("\ntesting %s %s %s \n", algo, m, e);
printk("\ntesting %s %s %s\n", algo, m, e);
tsize = sizeof (struct cipher_testvec);
tsize *= tcount;
......@@ -288,12 +289,12 @@ test_cipher(char * algo, int mode, int enc, struct cipher_testvec * template, un
}
memcpy(tvmem, template, tsize);
cipher_tv = (void *) tvmem;
cipher_tv = (void *)tvmem;
if (mode)
tfm = crypto_alloc_tfm (algo, 0);
tfm = crypto_alloc_tfm(algo, 0);
else
tfm = crypto_alloc_tfm (algo, CRYPTO_TFM_MODE_CBC);
tfm = crypto_alloc_tfm(algo, CRYPTO_TFM_MODE_CBC);
if (tfm == NULL) {
printk("failed to load transform for %s %s\n", algo, m);
......@@ -327,7 +328,7 @@ test_cipher(char * algo, int mode, int enc, struct cipher_testvec * template, un
if (!mode) {
crypto_cipher_set_iv(tfm, cipher_tv[i].iv,
crypto_tfm_alg_ivsize (tfm));
crypto_tfm_alg_ivsize(tfm));
}
if (enc)
......@@ -345,12 +346,12 @@ test_cipher(char * algo, int mode, int enc, struct cipher_testvec * template, un
hexdump(q, cipher_tv[i].rlen);
printk("%s\n",
memcmp(q, cipher_tv[i].result, cipher_tv[i].rlen) ? "fail" :
"pass");
memcmp(q, cipher_tv[i].result,
cipher_tv[i].rlen) ? "fail" : "pass");
}
}
printk("\ntesting %s %s %s across pages (chunking) \n", algo, m, e);
printk("\ntesting %s %s %s across pages (chunking)\n", algo, m, e);
memset(xbuf, 0, XBUFSIZE);
j = 0;
......@@ -375,18 +376,19 @@ test_cipher(char * algo, int mode, int enc, struct cipher_testvec * template, un
temp = 0;
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]);
temp += cipher_tv[i].tap[k];
p = &xbuf[IDX[k]];
sg[k].page = virt_to_page (p);
sg[k].offset = offset_in_page (p);
sg[k].page = virt_to_page(p);
sg[k].offset = offset_in_page(p);
sg[k].length = cipher_tv[i].tap[k];
}
if (!mode) {
crypto_cipher_set_iv(tfm, cipher_tv[i].iv,
crypto_tfm_alg_ivsize (tfm));
crypto_tfm_alg_ivsize(tfm));
}
if (enc)
......@@ -417,8 +419,7 @@ out:
crypto_free_tfm(tfm);
}
static void
test_deflate(void)
static void test_deflate(void)
{
unsigned int i;
char result[COMP_BUF_SIZE];
......@@ -436,7 +437,7 @@ test_deflate(void)
}
memcpy(tvmem, deflate_comp_tv_template, tsize);
tv = (void *) tvmem;
tv = (void *)tvmem;
tfm = crypto_alloc_tfm("deflate", 0);
if (tfm == NULL) {
......@@ -473,7 +474,7 @@ test_deflate(void)
}
memcpy(tvmem, deflate_decomp_tv_template, tsize);
tv = (void *) tvmem;
tv = (void *)tvmem;
for (i = 0; i < DEFLATE_DECOMP_TEST_VECTORS; i++) {
int ilen, ret, dlen = COMP_BUF_SIZE;
......@@ -497,8 +498,7 @@ out:
crypto_free_tfm(tfm);
}
static void
test_crc32c(void)
static void test_crc32c(void)
{
#define NUMVEC 6
#define VECSIZE 40
......@@ -598,8 +598,7 @@ test_crc32c(void)
printk("crc32c test complete\n");
}
static void
test_available(void)
static void test_available(void)
{
char **name = check;
......@@ -611,8 +610,7 @@ test_available(void)
}
}
static void
do_test(void)
static void do_test(void)
{
switch (mode) {
......@@ -874,8 +872,7 @@ do_test(void)
}
}
static int __init
init(void)
static int __init init(void)
{
tvmem = kmalloc(TVMEMSIZE, GFP_KERNEL);
if (tvmem == NULL)
......
......@@ -1578,8 +1578,7 @@ static struct cipher_testvec tf_cbc_dec_tv_template[] = {
#define TNEPRES_ENC_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,
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 */
.input = { 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,
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,
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_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,
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,
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_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,
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,
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_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 },
.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 },
.klen = 8,
......@@ -2117,8 +2107,7 @@ static struct cipher_testvec arc4_dec_tv_template[] =
#define TEA_ENC_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 },
.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 },
.klen = 16,
......@@ -2211,8 +2199,7 @@ static struct cipher_testvec tea_dec_tv_template[] =
#define XTEA_ENC_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 },
.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 },
.klen = 16,
......@@ -2697,8 +2683,7 @@ static struct comp_testvec deflate_decomp_tv_template[] = {
*/
#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 },
.ksize = 8,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment