Re: [PATCH PATCH net-next 07/18] ceph: fix whitespace
On Tue, Jul 24, 2018 at 9:31 PM Stephen Hemminger wrote: > > Remove blank lines at end of file and trailing whitespace. > > Signed-off-by: Stephen Hemminger > --- > net/ceph/Kconfig | 1 - > net/ceph/Makefile | 1 - > net/ceph/auth_none.c | 1 - > net/ceph/auth_none.h | 1 - > net/ceph/auth_x.c | 2 -- > net/ceph/auth_x.h | 1 - > net/ceph/mon_client.c | 2 +- > net/ceph/pagevec.c| 1 - > 8 files changed, 1 insertion(+), 9 deletions(-) > > diff --git a/net/ceph/Kconfig b/net/ceph/Kconfig > index f8cceb99e732..cd2d5b9301a1 100644 > --- a/net/ceph/Kconfig > +++ b/net/ceph/Kconfig > @@ -41,4 +41,3 @@ config CEPH_LIB_USE_DNS_RESOLVER > Documentation/networking/dns_resolver.txt > > If unsure, say N. > - > diff --git a/net/ceph/Makefile b/net/ceph/Makefile > index 12bf49772d24..db09defe27d0 100644 > --- a/net/ceph/Makefile > +++ b/net/ceph/Makefile > @@ -15,4 +15,3 @@ libceph-y := ceph_common.o messenger.o msgpool.o buffer.o > pagelist.o \ > auth_x.o \ > ceph_fs.o ceph_strings.o ceph_hash.o \ > pagevec.o snapshot.o string_table.o > - > diff --git a/net/ceph/auth_none.c b/net/ceph/auth_none.c > index 41d2a0c72236..edb7042479ed 100644 > --- a/net/ceph/auth_none.c > +++ b/net/ceph/auth_none.c > @@ -142,4 +142,3 @@ int ceph_auth_none_init(struct ceph_auth_client *ac) > ac->ops = _auth_none_ops; > return 0; > } > - > diff --git a/net/ceph/auth_none.h b/net/ceph/auth_none.h > index 860ed9875791..4158f064302e 100644 > --- a/net/ceph/auth_none.h > +++ b/net/ceph/auth_none.h > @@ -26,4 +26,3 @@ struct ceph_auth_none_info { > int ceph_auth_none_init(struct ceph_auth_client *ac); > > #endif > - > diff --git a/net/ceph/auth_x.c b/net/ceph/auth_x.c > index 2f4a1baf5f52..32c7f5c4b1a6 100644 > --- a/net/ceph/auth_x.c > +++ b/net/ceph/auth_x.c > @@ -823,5 +823,3 @@ int ceph_x_init(struct ceph_auth_client *ac) > out: > return ret; > } > - > - > diff --git a/net/ceph/auth_x.h b/net/ceph/auth_x.h > index 454cb54568af..a71c4c282b57 100644 > --- a/net/ceph/auth_x.h > +++ b/net/ceph/auth_x.h > @@ -52,4 +52,3 @@ struct ceph_x_info { > int ceph_x_init(struct ceph_auth_client *ac); > > #endif > - > diff --git a/net/ceph/mon_client.c b/net/ceph/mon_client.c > index d7a7a2330ef7..18deb3d889c4 100644 > --- a/net/ceph/mon_client.c > +++ b/net/ceph/mon_client.c > @@ -1249,7 +1249,7 @@ static void dispatch(struct ceph_connection *con, > struct ceph_msg *msg) > if (monc->client->extra_mon_dispatch && > monc->client->extra_mon_dispatch(monc->client, msg) == 0) > break; > - > + > pr_err("received unknown message type %d %s\n", type, >ceph_msg_type_name(type)); > } > diff --git a/net/ceph/pagevec.c b/net/ceph/pagevec.c > index e560d3975f41..d3736f5bffec 100644 > --- a/net/ceph/pagevec.c > +++ b/net/ceph/pagevec.c > @@ -197,4 +197,3 @@ void ceph_zero_page_vector_range(int off, int len, struct > page **pages) > } > } > EXPORT_SYMBOL(ceph_zero_page_vector_range); > - Applied. Thanks, Ilya
Re: [PATCH 16/26] libceph: Use skcipher
On Tue, Jan 26, 2016 at 11:54 AM, Herbert Xu <herb...@gondor.apana.org.au> wrote: > On Mon, Jan 25, 2016 at 05:18:47PM +0100, Ilya Dryomov wrote: >> >> Could you get rid of ivsize instead of assigning to it - see the >> attached diff? > > How about an incremental patch like this? Thanks! > > ---8<--- > From: Ilya Dryomov <idryo...@gmail.com> > Subject: libceph: Remove unnecessary ivsize variables > > This patch removes the unnecessary ivsize variabls as they always > have the value of AES_BLOCK_SIZE. > > Signed-off-by: Ilya Dryomov <idryo...@gmail.com> > > diff --git a/net/ceph/crypto.c b/net/ceph/crypto.c > index fb9cb2b..db2847a 100644 > --- a/net/ceph/crypto.c > +++ b/net/ceph/crypto.c > @@ -166,8 +166,7 @@ static int ceph_aes_encrypt(const void *key, int key_len, > struct crypto_skcipher *tfm = ceph_crypto_alloc_cipher(); > SKCIPHER_REQUEST_ON_STACK(req, tfm); > int ret; > - int ivsize = AES_BLOCK_SIZE; > - char iv[ivsize]; > + char iv[AES_BLOCK_SIZE]; > size_t zero_padding = (0x10 - (src_len & 0x0f)); > char pad[16]; > > @@ -186,7 +185,7 @@ static int ceph_aes_encrypt(const void *key, int key_len, > goto out_tfm; > > crypto_skcipher_setkey((void *)tfm, key, key_len); > - memcpy(iv, aes_iv, ivsize); > + memcpy(iv, aes_iv, AES_BLOCK_SIZE); > > skcipher_request_set_tfm(req, tfm); > skcipher_request_set_callback(req, 0, NULL, NULL); > @@ -229,8 +228,7 @@ static int ceph_aes_encrypt2(const void *key, int > key_len, void *dst, > struct crypto_skcipher *tfm = ceph_crypto_alloc_cipher(); > SKCIPHER_REQUEST_ON_STACK(req, tfm); > int ret; > - int ivsize = AES_BLOCK_SIZE; > - char iv[ivsize]; > + char iv[AES_BLOCK_SIZE]; > size_t zero_padding = (0x10 - ((src1_len + src2_len) & 0x0f)); > char pad[16]; > > @@ -250,7 +248,7 @@ static int ceph_aes_encrypt2(const void *key, int > key_len, void *dst, > goto out_tfm; > > crypto_skcipher_setkey((void *)tfm, key, key_len); > - memcpy(iv, aes_iv, ivsize); > + memcpy(iv, aes_iv, AES_BLOCK_SIZE); > > skcipher_request_set_tfm(req, tfm); > skcipher_request_set_callback(req, 0, NULL, NULL); > @@ -294,8 +292,7 @@ static int ceph_aes_decrypt(const void *key, int key_len, > struct crypto_skcipher *tfm = ceph_crypto_alloc_cipher(); > SKCIPHER_REQUEST_ON_STACK(req, tfm); > char pad[16]; > - int ivsize = AES_BLOCK_SIZE; > - char iv[16]; > + char iv[AES_BLOCK_SIZE]; > int ret; > int last_byte; > > @@ -310,7 +307,7 @@ static int ceph_aes_decrypt(const void *key, int key_len, > goto out_tfm; > > crypto_skcipher_setkey((void *)tfm, key, key_len); > - memcpy(iv, aes_iv, ivsize); > + memcpy(iv, aes_iv, AES_BLOCK_SIZE); > > skcipher_request_set_tfm(req, tfm); > skcipher_request_set_callback(req, 0, NULL, NULL); > @@ -363,8 +360,7 @@ static int ceph_aes_decrypt2(const void *key, int key_len, > struct crypto_skcipher *tfm = ceph_crypto_alloc_cipher(); > SKCIPHER_REQUEST_ON_STACK(req, tfm); > char pad[16]; > - int ivsize = AES_BLOCK_SIZE; > - char iv[ivsize]; > + char iv[AES_BLOCK_SIZE]; > int ret; > int last_byte; > > @@ -380,7 +376,7 @@ static int ceph_aes_decrypt2(const void *key, int key_len, > goto out_tfm; > > crypto_skcipher_setkey((void *)tfm, key, key_len); > - memcpy(iv, aes_iv, ivsize); > + memcpy(iv, aes_iv, AES_BLOCK_SIZE); > > skcipher_request_set_tfm(req, tfm); > skcipher_request_set_callback(req, 0, NULL, NULL); LGTM. You want to take it through crypto? Thanks, Ilya -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 16/26] libceph: Use skcipher
On Sun, Jan 24, 2016 at 2:18 PM, Herbert Xu <herb...@gondor.apana.org.au> wrote: > This patch replaces uses of blkcipher with skcipher. > > Signed-off-by: Herbert Xu <herb...@gondor.apana.org.au> > --- > > net/ceph/crypto.c | 97 > +++--- > 1 file changed, 56 insertions(+), 41 deletions(-) Could you get rid of ivsize instead of assigning to it - see the attached diff? Otherwise: Acked-by: Ilya Dryomov <idryo...@gmail.com> Thanks, Ilya diff --git a/net/ceph/crypto.c b/net/ceph/crypto.c index 42e8649c6e79..db2847ac5f12 100644 --- a/net/ceph/crypto.c +++ b/net/ceph/crypto.c @@ -4,7 +4,8 @@ #include #include #include -#include +#include +#include #include #include @@ -79,9 +80,9 @@ int ceph_crypto_key_unarmor(struct ceph_crypto_key *key, const char *inkey) return 0; } -static struct crypto_blkcipher *ceph_crypto_alloc_cipher(void) +static struct crypto_skcipher *ceph_crypto_alloc_cipher(void) { - return crypto_alloc_blkcipher("cbc(aes)", 0, CRYPTO_ALG_ASYNC); + return crypto_alloc_skcipher("cbc(aes)", 0, CRYPTO_ALG_ASYNC); } static const u8 *aes_iv = (u8 *)CEPH_AES_IV; @@ -162,11 +163,10 @@ static int ceph_aes_encrypt(const void *key, int key_len, { struct scatterlist sg_in[2], prealloc_sg; struct sg_table sg_out; - struct crypto_blkcipher *tfm = ceph_crypto_alloc_cipher(); - struct blkcipher_desc desc = { .tfm = tfm, .flags = 0 }; + struct crypto_skcipher *tfm = ceph_crypto_alloc_cipher(); + SKCIPHER_REQUEST_ON_STACK(req, tfm); int ret; - void *iv; - int ivsize; + char iv[AES_BLOCK_SIZE]; size_t zero_padding = (0x10 - (src_len & 0x0f)); char pad[16]; @@ -184,10 +184,13 @@ static int ceph_aes_encrypt(const void *key, int key_len, if (ret) goto out_tfm; - crypto_blkcipher_setkey((void *)tfm, key, key_len); - iv = crypto_blkcipher_crt(tfm)->iv; - ivsize = crypto_blkcipher_ivsize(tfm); - memcpy(iv, aes_iv, ivsize); + crypto_skcipher_setkey((void *)tfm, key, key_len); + memcpy(iv, aes_iv, AES_BLOCK_SIZE); + + skcipher_request_set_tfm(req, tfm); + skcipher_request_set_callback(req, 0, NULL, NULL); + skcipher_request_set_crypt(req, sg_in, sg_out.sgl, + src_len + zero_padding, iv); /* print_hex_dump(KERN_ERR, "enc key: ", DUMP_PREFIX_NONE, 16, 1, @@ -197,8 +200,8 @@ static int ceph_aes_encrypt(const void *key, int key_len, print_hex_dump(KERN_ERR, "enc pad: ", DUMP_PREFIX_NONE, 16, 1, pad, zero_padding, 1); */ - ret = crypto_blkcipher_encrypt(, sg_out.sgl, sg_in, -src_len + zero_padding); + ret = crypto_skcipher_encrypt(req); + skcipher_request_zero(req); if (ret < 0) { pr_err("ceph_aes_crypt failed %d\n", ret); goto out_sg; @@ -211,7 +214,7 @@ static int ceph_aes_encrypt(const void *key, int key_len, out_sg: teardown_sgtable(_out); out_tfm: - crypto_free_blkcipher(tfm); + crypto_free_skcipher(tfm); return ret; } @@ -222,11 +225,10 @@ static int ceph_aes_encrypt2(const void *key, int key_len, void *dst, { struct scatterlist sg_in[3], prealloc_sg; struct sg_table sg_out; - struct crypto_blkcipher *tfm = ceph_crypto_alloc_cipher(); - struct blkcipher_desc desc = { .tfm = tfm, .flags = 0 }; + struct crypto_skcipher *tfm = ceph_crypto_alloc_cipher(); + SKCIPHER_REQUEST_ON_STACK(req, tfm); int ret; - void *iv; - int ivsize; + char iv[AES_BLOCK_SIZE]; size_t zero_padding = (0x10 - ((src1_len + src2_len) & 0x0f)); char pad[16]; @@ -245,10 +247,13 @@ static int ceph_aes_encrypt2(const void *key, int key_len, void *dst, if (ret) goto out_tfm; - crypto_blkcipher_setkey((void *)tfm, key, key_len); - iv = crypto_blkcipher_crt(tfm)->iv; - ivsize = crypto_blkcipher_ivsize(tfm); - memcpy(iv, aes_iv, ivsize); + crypto_skcipher_setkey((void *)tfm, key, key_len); + memcpy(iv, aes_iv, AES_BLOCK_SIZE); + + skcipher_request_set_tfm(req, tfm); + skcipher_request_set_callback(req, 0, NULL, NULL); + skcipher_request_set_crypt(req, sg_in, sg_out.sgl, + src1_len + src2_len + zero_padding, iv); /* print_hex_dump(KERN_ERR, "enc key: ", DUMP_PREFIX_NONE, 16, 1, @@ -260,8 +265,8 @@ static int ceph_aes_encrypt2(const void *key, int key_len, void *dst, print_hex_dump(KERN_ERR, "enc pad: ", DUMP_PREFIX_NONE, 16, 1, pad, zero_padding, 1); */ - ret = cr