diff options
| author | James Morris <jmorris@intercode.com.au> | 2002-10-29 22:45:00 -0800 |
|---|---|---|
| committer | David S. Miller <davem@nuts.ninka.net> | 2002-10-29 22:45:00 -0800 |
| commit | b56bc16aa33f97a846bccc295e0189ca55cb5b43 (patch) | |
| tree | 81da363a352746e3ee0925bb1208ed925c61767c /crypto | |
| parent | e3f4fb0b9e02371a82dd7fd7a1fc0cd26d43d486 (diff) | |
[CRYPTO]: Cleanups based upon suggestions by Jeff Garzik.
- Changed unsigned to unsigned int in algos.
- Consistent use of u32 for flags throughout api.
- Use of unsigned int rather than int for counting things which must
be positive, also replaced size_ts to keep code simpler and lessen
bloat on some archs.
- got rid of some unneeded returns.
- const correctness.
Diffstat (limited to 'crypto')
| -rw-r--r-- | crypto/api.c | 17 | ||||
| -rw-r--r-- | crypto/autoload.c | 3 | ||||
| -rw-r--r-- | crypto/cipher.c | 60 | ||||
| -rw-r--r-- | crypto/compress.c | 8 | ||||
| -rw-r--r-- | crypto/des.c | 27 | ||||
| -rw-r--r-- | crypto/digest.c | 20 | ||||
| -rw-r--r-- | crypto/internal.h | 2 | ||||
| -rw-r--r-- | crypto/md4.c | 10 | ||||
| -rw-r--r-- | crypto/md5.c | 8 | ||||
| -rw-r--r-- | crypto/sha1.c | 4 | ||||
| -rw-r--r-- | crypto/tcrypt.c | 68 | ||||
| -rw-r--r-- | crypto/tcrypt.h | 2 |
12 files changed, 107 insertions, 122 deletions
diff --git a/crypto/api.c b/crypto/api.c index 943d1f3d8d3d..51cd1a8113dc 100644 --- a/crypto/api.c +++ b/crypto/api.c @@ -34,7 +34,7 @@ static inline void crypto_alg_put(struct crypto_alg *alg) __MOD_DEC_USE_COUNT(alg->cra_module); } -struct crypto_alg *crypto_alg_lookup(char *name) +struct crypto_alg *crypto_alg_lookup(const char *name) { struct crypto_alg *q, *alg = NULL; @@ -68,7 +68,6 @@ static int crypto_init_flags(struct crypto_tfm *tfm, u32 flags) default: BUG(); - } return -EINVAL; @@ -95,7 +94,7 @@ static void crypto_init_ops(struct crypto_tfm *tfm) } } -struct crypto_tfm *crypto_alloc_tfm(char *name, u32 flags) +struct crypto_tfm *crypto_alloc_tfm(const char *name, u32 flags) { struct crypto_tfm *tfm = NULL; struct crypto_alg *alg; @@ -176,8 +175,8 @@ int crypto_register_alg(struct crypto_alg *alg) } if (crypto_alg_blocksize_check(alg)) { - printk(KERN_WARNING "%s: blocksize %Zd exceeds max. " - "size %d\n", __FUNCTION__, alg->cra_blocksize, + printk(KERN_WARNING "%s: blocksize %u exceeds max. " + "size %u\n", __FUNCTION__, alg->cra_blocksize, CRYPTO_MAX_CIPHER_BLOCK_SIZE); ret = -EINVAL; } @@ -242,16 +241,16 @@ static int c_show(struct seq_file *m, void *p) seq_printf(m, "name : %s\n", alg->cra_name); seq_printf(m, "module : %s\n", alg->cra_module ? alg->cra_module->name : "[static]"); - seq_printf(m, "blocksize : %Zd\n", alg->cra_blocksize); + seq_printf(m, "blocksize : %u\n", alg->cra_blocksize); switch (alg->cra_flags & CRYPTO_ALG_TYPE_MASK) { case CRYPTO_ALG_TYPE_CIPHER: - seq_printf(m, "keysize : %Zd\n", alg->cra_cipher.cia_keysize); - seq_printf(m, "ivsize : %Zd\n", alg->cra_cipher.cia_ivsize); + seq_printf(m, "keysize : %u\n", alg->cra_cipher.cia_keysize); + seq_printf(m, "ivsize : %u\n", alg->cra_cipher.cia_ivsize); break; case CRYPTO_ALG_TYPE_DIGEST: - seq_printf(m, "digestsize : %Zd\n", + seq_printf(m, "digestsize : %u\n", alg->cra_digest.dia_digestsize); break; } diff --git a/crypto/autoload.c b/crypto/autoload.c index e3c55dbe2e1c..ee001b6b05e2 100644 --- a/crypto/autoload.c +++ b/crypto/autoload.c @@ -21,8 +21,7 @@ * A far more intelligent version of this is planned. For now, just * try an exact match on the name of the algorithm. */ -void crypto_alg_autoload(char *name) +void crypto_alg_autoload(const char *name) { request_module(name); - return; } diff --git a/crypto/cipher.c b/crypto/cipher.c index ef6501918190..c2a83c665a8c 100644 --- a/crypto/cipher.c +++ b/crypto/cipher.c @@ -20,7 +20,7 @@ #include <asm/scatterlist.h> #include "internal.h" -typedef void (cryptfn_t)(void *, u8 *, u8 *); +typedef void (cryptfn_t)(void *, u8 *, const u8 *); typedef void (procfn_t)(struct crypto_tfm *, u8 *, cryptfn_t, int enc); static inline void xor_64(u8 *a, const u8 *b) @@ -29,10 +29,9 @@ static inline void xor_64(u8 *a, const u8 *b) ((u32 *)a)[1] ^= ((u32 *)b)[1]; } -static inline size_t sglen(struct scatterlist *sg, size_t nsg) +static inline unsigned int sglen(struct scatterlist *sg, unsigned int nsg) { - int i; - size_t n; + unsigned int i, n; for (i = 0, n = 0; i < nsg; i++) n += sg[i].length; @@ -44,21 +43,21 @@ static inline size_t sglen(struct scatterlist *sg, size_t nsg) * Do not call this unless the total length of all of the fragments * has been verified as multiple of the block size. */ -static int copy_chunks(struct crypto_tfm *tfm, u8 *buf, - struct scatterlist *sg, int sgidx, - int rlen, int *last, int in) +static unsigned int copy_chunks(struct crypto_tfm *tfm, u8 *buf, + struct scatterlist *sg, unsigned int sgidx, + unsigned int rlen, unsigned int *last, int in) { - int i, copied, coff, j, aligned; - size_t bsize = crypto_tfm_alg_blocksize(tfm); + unsigned int i, copied, coff, j, aligned; + unsigned int bsize = crypto_tfm_alg_blocksize(tfm); for (i = sgidx, j = copied = 0, aligned = 0 ; copied < bsize; i++) { - int len = sg[i].length; - int clen; + unsigned int len = sg[i].length; + unsigned int clen; char *p; if (copied) { coff = 0; - clen = min_t(int, len, bsize - copied); + clen = min(len, bsize - copied); if (len == bsize - copied) aligned = 1; /* last + right aligned */ @@ -83,16 +82,18 @@ static int copy_chunks(struct crypto_tfm *tfm, u8 *buf, return i - sgidx - 2 + aligned; } -static inline int gather_chunks(struct crypto_tfm *tfm, u8 *buf, - struct scatterlist *sg, - int sgidx, int rlen, int *last) +static inline unsigned int gather_chunks(struct crypto_tfm *tfm, u8 *buf, + struct scatterlist *sg, + unsigned int sgidx, unsigned int rlen, + unsigned int *last) { return copy_chunks(tfm, buf, sg, sgidx, rlen, last, 1); } -static inline int scatter_chunks(struct crypto_tfm *tfm, u8 *buf, - struct scatterlist *sg, - int sgidx, int rlen, int *last) +static inline unsigned int scatter_chunks(struct crypto_tfm *tfm, u8 *buf, + struct scatterlist *sg, + unsigned int sgidx, unsigned int rlen, + unsigned int *last) { return copy_chunks(tfm, buf, sg, sgidx, rlen, last, 0); } @@ -111,10 +112,10 @@ static inline int scatter_chunks(struct crypto_tfm *tfm, u8 *buf, * and the block offset (boff). */ static int crypt(struct crypto_tfm *tfm, struct scatterlist *sg, - size_t nsg, cryptfn_t crfn, procfn_t prfn, int enc) + unsigned int nsg, cryptfn_t crfn, procfn_t prfn, int enc) { - int i, coff; - size_t bsize = crypto_tfm_alg_blocksize(tfm); + unsigned int i, coff; + unsigned int bsize = crypto_tfm_alg_blocksize(tfm); u8 tmp[CRYPTO_MAX_CIPHER_BLOCK_SIZE]; if (sglen(sg, nsg) % bsize) { @@ -123,8 +124,8 @@ static int crypt(struct crypto_tfm *tfm, struct scatterlist *sg, } for (i = 0, coff = 0; i < nsg; i++) { - int n = 0, boff = 0; - int len = sg[i].length - coff; + unsigned int n = 0, boff = 0; + unsigned int len = sg[i].length - coff; char *p = crypto_kmap(sg[i].page) + sg[i].offset + coff; while (len) { @@ -185,41 +186,42 @@ static void ecb_process(struct crypto_tfm *tfm, u8 *block, fn(tfm->crt_ctx, block, block); } -static int setkey(struct crypto_tfm *tfm, const u8 *key, size_t keylen) +static int setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen) { return tfm->__crt_alg->cra_cipher.cia_setkey(tfm->crt_ctx, key, keylen, &tfm->crt_flags); } static int ecb_encrypt(struct crypto_tfm *tfm, - struct scatterlist *sg, size_t nsg) + struct scatterlist *sg, unsigned int nsg) { return crypt(tfm, sg, nsg, tfm->__crt_alg->cra_cipher.cia_encrypt, ecb_process, 1); } static int ecb_decrypt(struct crypto_tfm *tfm, - struct scatterlist *sg, size_t nsg) + struct scatterlist *sg, unsigned int nsg) { return crypt(tfm, sg, nsg, tfm->__crt_alg->cra_cipher.cia_decrypt, ecb_process, 1); } static int cbc_encrypt(struct crypto_tfm *tfm, - struct scatterlist *sg, size_t nsg) + struct scatterlist *sg, unsigned int nsg) { return crypt(tfm, sg, nsg, tfm->__crt_alg->cra_cipher.cia_encrypt, cbc_process, 1); } static int cbc_decrypt(struct crypto_tfm *tfm, - struct scatterlist *sg, size_t nsg) + struct scatterlist *sg, unsigned int nsg) { return crypt(tfm, sg, nsg, tfm->__crt_alg->cra_cipher.cia_decrypt, cbc_process, 0); } -static int nocrypt(struct crypto_tfm *tfm, struct scatterlist *sg, size_t nsg) +static int nocrypt(struct crypto_tfm *tfm, + struct scatterlist *sg, unsigned int nsg) { return -ENOSYS; } diff --git a/crypto/compress.c b/crypto/compress.c index 0266ac5b3515..f599a4e37954 100644 --- a/crypto/compress.c +++ b/crypto/compress.c @@ -23,14 +23,10 @@ * lossless Quadruple ROT13 compression. */ static void crypto_compress(struct crypto_tfm *tfm) -{ - return; -} +{ } static void crypto_decompress(struct crypto_tfm *tfm) -{ - return; -} +{ } int crypto_init_compress_flags(struct crypto_tfm *tfm, u32 flags) { diff --git a/crypto/des.c b/crypto/des.c index 9972c622bbc1..69d718ebce11 100644 --- a/crypto/des.c +++ b/crypto/des.c @@ -278,7 +278,7 @@ const static u8 parity[] = { }; -static void des_small_fips_encrypt(u32 *expkey, u8 *dst, u8 *src) +static void des_small_fips_encrypt(u32 *expkey, u8 *dst, const u8 *src) { u32 x, y, z; @@ -648,10 +648,9 @@ static void des_small_fips_encrypt(u32 *expkey, u8 *dst, u8 *src) dst[6] = y; y >>= 8; dst[7] = y; - return; } -static void des_small_fips_decrypt(u32 *expkey, u8 *dst, u8 *src) +static void des_small_fips_decrypt(u32 *expkey, u8 *dst, const u8 *src) { u32 x, y, z; @@ -1021,14 +1020,13 @@ static void des_small_fips_decrypt(u32 *expkey, u8 *dst, u8 *src) dst[6] = y; y >>= 8; dst[7] = y; - return; } /* * RFC2451: Weak key checks SHOULD be performed. */ -static int setkey(u32 *expkey, const u8 *key, size_t keylen, int *flags) +static int setkey(u32 *expkey, const u8 *key, unsigned int keylen, u32 *flags) { const u8 *k; u8 *b0, *b1; @@ -1177,17 +1175,17 @@ not_weak: return 0; } -static int des_setkey(void *ctx, const u8 *key, size_t keylen, int *flags) +static int des_setkey(void *ctx, const u8 *key, unsigned int keylen, u32 *flags) { return setkey(((struct des_ctx *)ctx)->expkey, key, keylen, flags); } -static void des_encrypt(void *ctx, u8 *dst, u8 *src) +static void des_encrypt(void *ctx, u8 *dst, const u8 *src) { des_small_fips_encrypt(((struct des_ctx *)ctx)->expkey, dst, src); } -static void des_decrypt(void *ctx, u8 *dst, u8 *src) +static void des_decrypt(void *ctx, u8 *dst, const u8 *src) { des_small_fips_decrypt(((struct des_ctx *)ctx)->expkey, dst, src); } @@ -1205,9 +1203,10 @@ static void des_decrypt(void *ctx, u8 *dst, u8 *src) * property. * */ -static int des3_ede_setkey(void *ctx, const u8 *key, size_t keylen, int *flags) +static int des3_ede_setkey(void *ctx, const u8 *key, + unsigned int keylen, u32 *flags) { - int i, off; + unsigned int i, off; struct des3_ede_ctx *dctx = ctx; if (keylen != DES3_EDE_KEY_SIZE) { @@ -1232,26 +1231,22 @@ static int des3_ede_setkey(void *ctx, const u8 *key, size_t keylen, int *flags) return 0; } -static void des3_ede_encrypt(void *ctx, u8 *dst, u8 *src) +static void des3_ede_encrypt(void *ctx, u8 *dst, const u8 *src) { struct des3_ede_ctx *dctx = ctx; des_small_fips_encrypt(dctx->expkey, dst, src); des_small_fips_decrypt(&dctx->expkey[DES_EXPKEY_WORDS], dst, dst); des_small_fips_encrypt(&dctx->expkey[DES_EXPKEY_WORDS * 2], dst, dst); - - return; } -static void des3_ede_decrypt(void *ctx, u8 *dst, u8 *src) +static void des3_ede_decrypt(void *ctx, u8 *dst, const u8 *src) { struct des3_ede_ctx *dctx = ctx; des_small_fips_decrypt(&dctx->expkey[DES_EXPKEY_WORDS * 2], dst, src); des_small_fips_encrypt(&dctx->expkey[DES_EXPKEY_WORDS], dst, dst); des_small_fips_decrypt(dctx->expkey, dst, dst); - - return; } static struct crypto_alg des_alg = { diff --git a/crypto/digest.c b/crypto/digest.c index 87212dc33bf2..dde4deb1deed 100644 --- a/crypto/digest.c +++ b/crypto/digest.c @@ -23,12 +23,12 @@ static void init(struct crypto_tfm *tfm) { tfm->__crt_alg->cra_digest.dia_init(tfm->crt_ctx); - return; } -static void update(struct crypto_tfm *tfm, struct scatterlist *sg, size_t nsg) +static void update(struct crypto_tfm *tfm, + struct scatterlist *sg, unsigned int nsg) { - int i; + unsigned int i; for (i = 0; i < nsg; i++) { char *p = crypto_kmap(sg[i].page) + sg[i].offset; @@ -37,19 +37,17 @@ static void update(struct crypto_tfm *tfm, struct scatterlist *sg, size_t nsg) crypto_kunmap(p); crypto_yield(tfm); } - return; } static void final(struct crypto_tfm *tfm, u8 *out) { tfm->__crt_alg->cra_digest.dia_final(tfm->crt_ctx, out); - return; } static void digest(struct crypto_tfm *tfm, - struct scatterlist *sg, size_t nsg, u8 *out) + struct scatterlist *sg, unsigned int nsg, u8 *out) { - int i; + unsigned int i; tfm->crt_digest.dit_init(tfm); @@ -61,13 +59,12 @@ static void digest(struct crypto_tfm *tfm, crypto_yield(tfm); } crypto_digest_final(tfm, out); - return; } -static void hmac(struct crypto_tfm *tfm, u8 *key, size_t keylen, - struct scatterlist *sg, size_t nsg, u8 *out) +static void hmac(struct crypto_tfm *tfm, u8 *key, unsigned int keylen, + struct scatterlist *sg, unsigned int nsg, u8 *out) { - int i; + unsigned int i; struct scatterlist tmp; char ipad[crypto_tfm_alg_blocksize(tfm) + 1]; char opad[crypto_tfm_alg_blocksize(tfm) + 1]; @@ -112,7 +109,6 @@ static void hmac(struct crypto_tfm *tfm, u8 *key, size_t keylen, crypto_digest_update(tfm, &tmp, 1); crypto_digest_final(tfm, out); - return; } int crypto_init_digest_flags(struct crypto_tfm *tfm, u32 flags) diff --git a/crypto/internal.h b/crypto/internal.h index 28d74da44d74..c19048305950 100644 --- a/crypto/internal.h +++ b/crypto/internal.h @@ -41,7 +41,7 @@ static inline int crypto_cipher_flags(u32 flags) } #ifdef CONFIG_KMOD -void crypto_alg_autoload(char *name); +void crypto_alg_autoload(const char *name); #endif int crypto_init_digest_flags(struct crypto_tfm *tfm, u32 flags); diff --git a/crypto/md4.c b/crypto/md4.c index 37e0999cd1c8..3d168dee5742 100644 --- a/crypto/md4.c +++ b/crypto/md4.c @@ -37,7 +37,7 @@ struct md4_ctx { u64 byte_count; }; -static u32 lshift(u32 x, int s) +static u32 lshift(u32 x, unsigned int s) { x &= 0xFFFFFFFF; return ((x << s) & 0xFFFFFFFF) | (x >> (32 - s)); @@ -63,7 +63,7 @@ static inline u32 H(u32 x, u32 y, u32 z) #define ROUND3(a,b,c,d,k,s) (a = lshift(a + H(b,c,d) + k + (u32)0x6ED9EBA1,s)) /* XXX: this stuff can be optimized */ -static inline void le32_to_cpu_array(u32 *buf, unsigned words) +static inline void le32_to_cpu_array(u32 *buf, unsigned int words) { while (words--) { __le32_to_cpus(buf); @@ -71,7 +71,7 @@ static inline void le32_to_cpu_array(u32 *buf, unsigned words) } } -static inline void cpu_to_le32_array(u32 *buf, unsigned words) +static inline void cpu_to_le32_array(u32 *buf, unsigned int words) { while (words--) { __cpu_to_le32s(buf); @@ -162,7 +162,7 @@ static void md4_init(void *ctx) mctx->byte_count = 0; } -static void md4_update(void *ctx, const u8 *data, size_t len) +static void md4_update(void *ctx, const u8 *data, unsigned int len) { struct md4_ctx *mctx = ctx; const u32 avail = sizeof(mctx->block) - (mctx->byte_count & 0x3f); @@ -195,7 +195,7 @@ static void md4_update(void *ctx, const u8 *data, size_t len) static void md4_final(void *ctx, u8 *out) { struct md4_ctx *mctx = ctx; - const int offset = mctx->byte_count & 0x3f; + const unsigned int offset = mctx->byte_count & 0x3f; char *p = (char *)mctx->block + offset; int padding = 56 - (offset + 1); diff --git a/crypto/md5.c b/crypto/md5.c index c219d5983750..27e95113f756 100644 --- a/crypto/md5.c +++ b/crypto/md5.c @@ -124,7 +124,7 @@ static inline void md5_transform(u32 *hash, u32 const *in) } /* XXX: this stuff can be optimized */ -static inline void le32_to_cpu_array(u32 *buf, unsigned words) +static inline void le32_to_cpu_array(u32 *buf, unsigned int words) { while (words--) { __le32_to_cpus(buf); @@ -132,7 +132,7 @@ static inline void le32_to_cpu_array(u32 *buf, unsigned words) } } -static inline void cpu_to_le32_array(u32 *buf, unsigned words) +static inline void cpu_to_le32_array(u32 *buf, unsigned int words) { while (words--) { __cpu_to_le32s(buf); @@ -157,7 +157,7 @@ static void md5_init(void *ctx) mctx->byte_count = 0; } -static void md5_update(void *ctx, const u8 *data, size_t len) +static void md5_update(void *ctx, const u8 *data, unsigned int len) { struct md5_ctx *mctx = ctx; const u32 avail = sizeof(mctx->block) - (mctx->byte_count & 0x3f); @@ -190,7 +190,7 @@ static void md5_update(void *ctx, const u8 *data, size_t len) static void md5_final(void *ctx, u8 *out) { struct md5_ctx *mctx = ctx; - const int offset = mctx->byte_count & 0x3f; + const unsigned int offset = mctx->byte_count & 0x3f; char *p = (char *)mctx->block + offset; int padding = 56 - (offset + 1); diff --git a/crypto/sha1.c b/crypto/sha1.c index 874a05dade98..4618f0dc4f4b 100644 --- a/crypto/sha1.c +++ b/crypto/sha1.c @@ -116,10 +116,10 @@ static void sha1_init(void *ctx) *sctx = initstate; } -static void sha1_update(void *ctx, const u8 *data, size_t len) +static void sha1_update(void *ctx, const u8 *data, unsigned int len) { struct sha1_ctx *sctx = ctx; - unsigned i, j; + unsigned int i, j; j = (sctx->count >> 3) & 0x3f; sctx->count += len << 3; diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c index 8408d0ddc163..adebcd9f4c46 100644 --- a/crypto/tcrypt.c +++ b/crypto/tcrypt.c @@ -47,7 +47,7 @@ static char *xbuf; static char *tvmem; static void -hexdump(unsigned char *buf, size_t len) +hexdump(unsigned char *buf, unsigned int len) { while (len--) printk("%02x", *buf++); @@ -59,19 +59,19 @@ static void test_md5(void) { char *p; - int i; + unsigned int i; struct scatterlist sg[2]; char result[128]; struct crypto_tfm *tfm; struct md5_testvec *md5_tv; struct hmac_md5_testvec *hmac_md5_tv; - size_t tsize; + unsigned int tsize; printk("\ntesting md5\n"); tsize = sizeof (md5_tv_template); if (tsize > TVMEMSIZE) { - printk("template (%Zd) too big for tvmem (%d)\n", tsize, + printk("template (%u) too big for tvmem (%u)\n", tsize, TVMEMSIZE); return; } @@ -86,7 +86,7 @@ test_md5(void) } for (i = 0; i < MD5_TEST_VECTORS; i++) { - printk("test %d:\n", i + 1); + printk("test %u:\n", i + 1); memset(result, 0, sizeof (result)); p = md5_tv[i].plaintext; @@ -134,7 +134,7 @@ test_md5(void) tsize = sizeof (hmac_md5_tv_template); if (tsize > TVMEMSIZE) { - printk("template (%Zd) too big for tvmem (%d)\n", tsize, + printk("template (%u) too big for tvmem (%u)\n", tsize, TVMEMSIZE); return; } @@ -143,7 +143,7 @@ test_md5(void) hmac_md5_tv = (void *) tvmem; for (i = 0; i < HMAC_MD5_TEST_VECTORS; i++) { - printk("test %d:\n", i + 1); + printk("test %u:\n", i + 1); memset(result, 0, sizeof (result)); p = hmac_md5_tv[i].plaintext; @@ -194,18 +194,18 @@ static void test_md4(void) { char *p; - int i; + unsigned int i; struct scatterlist sg[1]; char result[128]; struct crypto_tfm *tfm; struct md4_testvec *md4_tv; - size_t tsize; + unsigned int tsize; printk("\ntesting md4\n"); tsize = sizeof (md4_tv_template); if (tsize > TVMEMSIZE) { - printk("template (%Zd) too big for tvmem (%d)\n", tsize, + printk("template (%u) too big for tvmem (%u)\n", tsize, TVMEMSIZE); return; } @@ -220,7 +220,7 @@ test_md4(void) } for (i = 0; i < MD4_TEST_VECTORS; i++) { - printk("test %d:\n", i + 1); + printk("test %u:\n", i + 1); memset(result, 0, sizeof (result)); p = md4_tv[i].plaintext; @@ -244,19 +244,19 @@ static void test_sha1(void) { char *p; - int i; + unsigned int i; struct crypto_tfm *tfm; struct sha1_testvec *sha1_tv; struct hmac_sha1_testvec *hmac_sha1_tv; struct scatterlist sg[2]; - size_t tsize; + unsigned int tsize; char result[SHA1_DIGEST_SIZE]; printk("\ntesting sha1\n"); tsize = sizeof (sha1_tv_template); if (tsize > TVMEMSIZE) { - printk("template (%Zd) too big for tvmem (%d)\n", tsize, + printk("template (%u) too big for tvmem (%u)\n", tsize, TVMEMSIZE); return; } @@ -271,7 +271,7 @@ test_sha1(void) } for (i = 0; i < SHA1_TEST_VECTORS; i++) { - printk("test %d:\n", i + 1); + printk("test %u:\n", i + 1); memset(result, 0, sizeof (result)); p = sha1_tv[i].plaintext; @@ -318,7 +318,7 @@ test_sha1(void) tsize = sizeof (hmac_sha1_tv_template); if (tsize > TVMEMSIZE) { - printk("template (%Zd) too big for tvmem (%d)\n", tsize, + printk("template (%u) too big for tvmem (%u)\n", tsize, TVMEMSIZE); return; } @@ -327,7 +327,7 @@ test_sha1(void) hmac_sha1_tv = (void *) tvmem; for (i = 0; i < HMAC_SHA1_TEST_VECTORS; i++) { - printk("test %d:\n", i + 1); + printk("test %u:\n", i + 1); memset(result, 0, sizeof (result)); p = hmac_sha1_tv[i].plaintext; @@ -377,8 +377,8 @@ test_sha1(void) void test_des(void) { - int ret, i, len; - size_t tsize; + unsigned int ret, i, len; + unsigned int tsize; char *p, *q; struct crypto_tfm *tfm; char *key; @@ -390,7 +390,7 @@ test_des(void) tsize = sizeof (des_enc_tv_template); if (tsize > TVMEMSIZE) { - printk("template (%Zd) too big for tvmem (%d)\n", tsize, + printk("template (%u) too big for tvmem (%u)\n", tsize, TVMEMSIZE); return; } @@ -405,7 +405,7 @@ test_des(void) } for (i = 0; i < DES_ENC_TEST_VECTORS; i++) { - printk("test %d:\n", i + 1); + printk("test %u:\n", i + 1); key = des_tv[i].key; tfm->crt_flags |= CRYPTO_TFM_REQ_WEAK_KEY; @@ -815,7 +815,7 @@ test_des(void) tsize = sizeof (des_dec_tv_template); if (tsize > TVMEMSIZE) { - printk("template (%Zd) too big for tvmem (%d)\n", tsize, + printk("template (%u) too big for tvmem (%u)\n", tsize, TVMEMSIZE); return; } @@ -823,7 +823,7 @@ test_des(void) des_tv = (void *) tvmem; for (i = 0; i < DES_DEC_TEST_VECTORS; i++) { - printk("test %d:\n", i + 1); + printk("test %u:\n", i + 1); key = des_tv[i].key; @@ -975,7 +975,7 @@ test_des(void) tsize = sizeof (des_cbc_enc_tv_template); if (tsize > TVMEMSIZE) { - printk("template (%Zd) too big for tvmem (%d)\n", tsize, + printk("template (%u) too big for tvmem (%u)\n", tsize, TVMEMSIZE); return; } @@ -991,7 +991,7 @@ test_des(void) } for (i = 0; i < DES_CBC_ENC_TEST_VECTORS; i++) { - printk("test %d:\n", i + 1); + printk("test %u:\n", i + 1); key = des_tv[i].key; @@ -1088,7 +1088,7 @@ test_des(void) tsize = sizeof (des_cbc_dec_tv_template); if (tsize > TVMEMSIZE) { - printk("template (%Zd) too big for tvmem (%d)\n", tsize, + printk("template (%u) too big for tvmem (%u)\n", tsize, TVMEMSIZE); return; } @@ -1098,7 +1098,7 @@ test_des(void) printk("\ntesting des cbc decryption\n"); for (i = 0; i < DES_CBC_DEC_TEST_VECTORS; i++) { - printk("test %d:\n", i + 1); + printk("test %u:\n", i + 1); tfm->crt_flags = 0; key = des_tv[i].key; @@ -1189,14 +1189,13 @@ test_des(void) out: crypto_free_tfm(tfm); - return; } void test_des3_ede(void) { - int ret, i, len; - size_t tsize; + unsigned int ret, i, len; + unsigned int tsize; char *p, *q; struct crypto_tfm *tfm; char *key; @@ -1208,7 +1207,7 @@ test_des3_ede(void) tsize = sizeof (des3_ede_enc_tv_template); if (tsize > TVMEMSIZE) { - printk("template (%Zd) too big for tvmem (%d)\n", tsize, + printk("template (%u) too big for tvmem (%u)\n", tsize, TVMEMSIZE); return; } @@ -1223,7 +1222,7 @@ test_des3_ede(void) } for (i = 0; i < DES3_EDE_ENC_TEST_VECTORS; i++) { - printk("test %d:\n", i + 1); + printk("test %u:\n", i + 1); key = des_tv[i].key; ret = crypto_cipher_setkey(tfm, key, 24); @@ -1257,7 +1256,7 @@ test_des3_ede(void) tsize = sizeof (des3_ede_dec_tv_template); if (tsize > TVMEMSIZE) { - printk("template (%Zd) too big for tvmem (%d)\n", tsize, + printk("template (%u) too big for tvmem (%u)\n", tsize, TVMEMSIZE); return; } @@ -1266,7 +1265,7 @@ test_des3_ede(void) des_tv = (void *) tvmem; for (i = 0; i < DES3_EDE_DEC_TEST_VECTORS; i++) { - printk("test %d:\n", i + 1); + printk("test %u:\n", i + 1); key = des_tv[i].key; ret = crypto_cipher_setkey(tfm, key, 24); @@ -1298,7 +1297,6 @@ test_des3_ede(void) out: crypto_free_tfm(tfm); - return; } static void diff --git a/crypto/tcrypt.h b/crypto/tcrypt.h index 03830318d4ee..d6ab3149367d 100644 --- a/crypto/tcrypt.h +++ b/crypto/tcrypt.h @@ -370,7 +370,7 @@ struct sha1_testvec { #define DES3_EDE_DEC_TEST_VECTORS 3 struct des_tv { - int len; + unsigned int len; int fail; char key[24]; char iv[8]; |
