From: Joel Reardon <joel@clambassador.com> To: Artem Bityutskiy <dedekind1@gmail.com> Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [patch] UBIFS: Add a encryption key parameter to the compress / decompress function. Date: Thu, 29 Mar 2012 16:11:03 +0200 (CEST) [thread overview] Message-ID: <alpine.DEB.2.00.1203291606450.912@eristoteles.iwoars.net> (raw) In-Reply-To: <1332836863.31549.9.camel@sauron.fi.intel.com> Added a crypto_key parameter to ubifs compress and decompress. Will be used later if non-NULL to encrypt / decrypt data nodes. Signed-off-by: Joel Reardon <reardonj@inf.ethz.ch> --- fs/ubifs/compress.c | 8 ++++++-- fs/ubifs/file.c | 5 +++-- fs/ubifs/journal.c | 7 ++++--- fs/ubifs/ubifs.h | 4 ++-- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/fs/ubifs/compress.c b/fs/ubifs/compress.c index 11e4132..c91974a 100644 --- a/fs/ubifs/compress.c +++ b/fs/ubifs/compress.c @@ -82,6 +82,8 @@ struct ubifs_compressor *ubifs_compressors[UBIFS_COMPR_TYPES_CNT]; * @out_len: output buffer length is returned here * @compr_type: type of compression to use on enter, actually used compression * type on exit + * @crypto_key: a pointer to bytes to use as the encryption key, + * if NULL then no encryption is performed. * * This function compresses input buffer @in_buf of length @in_len and stores * the result in the output buffer @out_buf and the resulting length in @@ -93,7 +95,7 @@ struct ubifs_compressor *ubifs_compressors[UBIFS_COMPR_TYPES_CNT]; * buffer and %UBIFS_COMPR_NONE is returned in @compr_type. */ void ubifs_compress(const void *in_buf, int in_len, void *out_buf, int *out_len, - int *compr_type) + int *compr_type, u8 *crypto_key) { int err; struct ubifs_compressor *compr = ubifs_compressors[*compr_type]; @@ -140,13 +142,15 @@ no_compr: * @out_buf: output buffer where decompressed data should * @out_len: output length is returned here * @compr_type: type of compression + * @crypto_key: a pointer to bytes to use as the decryption key, + * if NULL then no decryption is performed. * * This function decompresses data from buffer @in_buf into buffer @out_buf. * The length of the uncompressed data is returned in @out_len. This functions * returns %0 on success or a negative error code on failure. */ int ubifs_decompress(const void *in_buf, int in_len, void *out_buf, - int *out_len, int compr_type) + int *out_len, int compr_type, u8 *crypto_key) { int err; struct ubifs_compressor *compr; diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c index f9c234b..2660c9f 100644 --- a/fs/ubifs/file.c +++ b/fs/ubifs/file.c @@ -80,7 +80,7 @@ static int read_block(struct inode *inode, void *addr, unsigned int block, dlen = le32_to_cpu(dn->ch.len) - UBIFS_DATA_NODE_SZ; out_len = UBIFS_BLOCK_SIZE; err = ubifs_decompress(&dn->data, dlen, addr, &out_len, - le16_to_cpu(dn->compr_type)); + le16_to_cpu(dn->compr_type), NULL); if (err || len != out_len) goto dump; @@ -649,7 +649,8 @@ static int populate_page(struct ubifs_info *c, struct page *page, dlen = le32_to_cpu(dn->ch.len) - UBIFS_DATA_NODE_SZ; out_len = UBIFS_BLOCK_SIZE; err = ubifs_decompress(&dn->data, dlen, addr, &out_len, - le16_to_cpu(dn->compr_type)); + le16_to_cpu(dn->compr_type), + NULL); if (err || len != out_len) goto out_err; diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c index 2f438ab..9156395 100644 --- a/fs/ubifs/journal.c +++ b/fs/ubifs/journal.c @@ -727,7 +727,7 @@ int ubifs_jnl_write_data(struct ubifs_info *c, const struct inode *inode, compr_type = ui->compr_type; out_len = dlen - UBIFS_DATA_NODE_SZ; - ubifs_compress(buf, len, &data->data, &out_len, &compr_type); + ubifs_compress(buf, len, &data->data, &out_len, &compr_type, NULL); ubifs_assert(out_len <= UBIFS_BLOCK_SIZE); dlen = UBIFS_DATA_NODE_SZ + out_len; @@ -1110,11 +1110,12 @@ static int recomp_data_node(struct ubifs_data_node *dn, int *new_len) len = le32_to_cpu(dn->ch.len) - UBIFS_DATA_NODE_SZ; compr_type = le16_to_cpu(dn->compr_type); - err = ubifs_decompress(&dn->data, len, buf, &out_len, compr_type); + err = ubifs_decompress( + &dn->data, len, buf, &out_len, compr_type, NULL); if (err) goto out; - ubifs_compress(buf, *new_len, &dn->data, &out_len, &compr_type); + ubifs_compress(buf, *new_len, &dn->data, &out_len, &compr_type, NULL); ubifs_assert(out_len <= UBIFS_BLOCK_SIZE); dn->compr_type = cpu_to_le16(compr_type); dn->size = cpu_to_le32(*new_len); diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h index 93d59ac..0cc1180 100644 --- a/fs/ubifs/ubifs.h +++ b/fs/ubifs/ubifs.h @@ -1772,9 +1772,9 @@ long ubifs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg); int __init ubifs_compressors_init(void); void ubifs_compressors_exit(void); void ubifs_compress(const void *in_buf, int in_len, void *out_buf, int *out_len, - int *compr_type); + int *compr_type, u8 *crypto_key); int ubifs_decompress(const void *buf, int len, void *out, int *out_len, - int compr_type); + int compr_type, u8 *crypto_key); #include "debug.h" #include "misc.h" -- 1.7.5.4
WARNING: multiple messages have this Message-ID (diff)
From: Joel Reardon <joel@clambassador.com> To: Artem Bityutskiy <dedekind1@gmail.com> Cc: linux-fsdevel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [patch] UBIFS: Add a encryption key parameter to the compress / decompress function. Date: Thu, 29 Mar 2012 16:11:03 +0200 (CEST) [thread overview] Message-ID: <alpine.DEB.2.00.1203291606450.912@eristoteles.iwoars.net> (raw) In-Reply-To: <1332836863.31549.9.camel@sauron.fi.intel.com> Added a crypto_key parameter to ubifs compress and decompress. Will be used later if non-NULL to encrypt / decrypt data nodes. Signed-off-by: Joel Reardon <reardonj@inf.ethz.ch> --- fs/ubifs/compress.c | 8 ++++++-- fs/ubifs/file.c | 5 +++-- fs/ubifs/journal.c | 7 ++++--- fs/ubifs/ubifs.h | 4 ++-- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/fs/ubifs/compress.c b/fs/ubifs/compress.c index 11e4132..c91974a 100644 --- a/fs/ubifs/compress.c +++ b/fs/ubifs/compress.c @@ -82,6 +82,8 @@ struct ubifs_compressor *ubifs_compressors[UBIFS_COMPR_TYPES_CNT]; * @out_len: output buffer length is returned here * @compr_type: type of compression to use on enter, actually used compression * type on exit + * @crypto_key: a pointer to bytes to use as the encryption key, + * if NULL then no encryption is performed. * * This function compresses input buffer @in_buf of length @in_len and stores * the result in the output buffer @out_buf and the resulting length in @@ -93,7 +95,7 @@ struct ubifs_compressor *ubifs_compressors[UBIFS_COMPR_TYPES_CNT]; * buffer and %UBIFS_COMPR_NONE is returned in @compr_type. */ void ubifs_compress(const void *in_buf, int in_len, void *out_buf, int *out_len, - int *compr_type) + int *compr_type, u8 *crypto_key) { int err; struct ubifs_compressor *compr = ubifs_compressors[*compr_type]; @@ -140,13 +142,15 @@ no_compr: * @out_buf: output buffer where decompressed data should * @out_len: output length is returned here * @compr_type: type of compression + * @crypto_key: a pointer to bytes to use as the decryption key, + * if NULL then no decryption is performed. * * This function decompresses data from buffer @in_buf into buffer @out_buf. * The length of the uncompressed data is returned in @out_len. This functions * returns %0 on success or a negative error code on failure. */ int ubifs_decompress(const void *in_buf, int in_len, void *out_buf, - int *out_len, int compr_type) + int *out_len, int compr_type, u8 *crypto_key) { int err; struct ubifs_compressor *compr; diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c index f9c234b..2660c9f 100644 --- a/fs/ubifs/file.c +++ b/fs/ubifs/file.c @@ -80,7 +80,7 @@ static int read_block(struct inode *inode, void *addr, unsigned int block, dlen = le32_to_cpu(dn->ch.len) - UBIFS_DATA_NODE_SZ; out_len = UBIFS_BLOCK_SIZE; err = ubifs_decompress(&dn->data, dlen, addr, &out_len, - le16_to_cpu(dn->compr_type)); + le16_to_cpu(dn->compr_type), NULL); if (err || len != out_len) goto dump; @@ -649,7 +649,8 @@ static int populate_page(struct ubifs_info *c, struct page *page, dlen = le32_to_cpu(dn->ch.len) - UBIFS_DATA_NODE_SZ; out_len = UBIFS_BLOCK_SIZE; err = ubifs_decompress(&dn->data, dlen, addr, &out_len, - le16_to_cpu(dn->compr_type)); + le16_to_cpu(dn->compr_type), + NULL); if (err || len != out_len) goto out_err; diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c index 2f438ab..9156395 100644 --- a/fs/ubifs/journal.c +++ b/fs/ubifs/journal.c @@ -727,7 +727,7 @@ int ubifs_jnl_write_data(struct ubifs_info *c, const struct inode *inode, compr_type = ui->compr_type; out_len = dlen - UBIFS_DATA_NODE_SZ; - ubifs_compress(buf, len, &data->data, &out_len, &compr_type); + ubifs_compress(buf, len, &data->data, &out_len, &compr_type, NULL); ubifs_assert(out_len <= UBIFS_BLOCK_SIZE); dlen = UBIFS_DATA_NODE_SZ + out_len; @@ -1110,11 +1110,12 @@ static int recomp_data_node(struct ubifs_data_node *dn, int *new_len) len = le32_to_cpu(dn->ch.len) - UBIFS_DATA_NODE_SZ; compr_type = le16_to_cpu(dn->compr_type); - err = ubifs_decompress(&dn->data, len, buf, &out_len, compr_type); + err = ubifs_decompress( + &dn->data, len, buf, &out_len, compr_type, NULL); if (err) goto out; - ubifs_compress(buf, *new_len, &dn->data, &out_len, &compr_type); + ubifs_compress(buf, *new_len, &dn->data, &out_len, &compr_type, NULL); ubifs_assert(out_len <= UBIFS_BLOCK_SIZE); dn->compr_type = cpu_to_le16(compr_type); dn->size = cpu_to_le32(*new_len); diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h index 93d59ac..0cc1180 100644 --- a/fs/ubifs/ubifs.h +++ b/fs/ubifs/ubifs.h @@ -1772,9 +1772,9 @@ long ubifs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg); int __init ubifs_compressors_init(void); void ubifs_compressors_exit(void); void ubifs_compress(const void *in_buf, int in_len, void *out_buf, int *out_len, - int *compr_type); + int *compr_type, u8 *crypto_key); int ubifs_decompress(const void *buf, int len, void *out, int *out_len, - int compr_type); + int compr_type, u8 *crypto_key); #include "debug.h" #include "misc.h" -- 1.7.5.4
next prev parent reply other threads:[~2012-03-29 14:11 UTC|newest] Thread overview: 112+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-02-09 15:24 [patch] Adding Secure Deletion to UBIFS Joel Reardon 2012-02-09 15:24 ` Joel Reardon 2012-02-09 15:24 ` Joel Reardon 2012-02-13 16:54 ` Artem Bityutskiy 2012-02-13 16:54 ` Artem Bityutskiy 2012-02-23 14:59 ` Joel Reardon 2012-02-23 14:59 ` Joel Reardon 2012-02-23 15:29 ` [patch] Add encryption key parameter to compress/decompress functions Joel Reardon 2012-02-23 15:29 ` Joel Reardon 2012-03-09 7:17 ` Artem Bityutskiy 2012-03-09 7:17 ` Artem Bityutskiy 2012-03-19 16:54 ` [patch] Add design document for UBIFS secure deletion Joel Reardon 2012-03-19 16:54 ` Joel Reardon 2012-03-20 20:10 ` Randy Dunlap 2012-03-20 20:10 ` Randy Dunlap 2012-03-21 13:26 ` Joel Reardon 2012-03-21 13:26 ` Joel Reardon 2012-03-21 16:20 ` Artem Bityutskiy 2012-03-21 16:20 ` Artem Bityutskiy 2012-03-21 16:10 ` Artem Bityutskiy 2012-03-21 16:10 ` Artem Bityutskiy 2012-03-23 13:50 ` Joel Reardon 2012-03-23 13:50 ` Joel Reardon 2012-03-23 15:38 ` Artem Bityutskiy 2012-03-23 15:38 ` Artem Bityutskiy 2012-03-23 16:38 ` Joel Reardon 2012-03-23 16:38 ` Joel Reardon 2012-03-26 15:03 ` Artem Bityutskiy 2012-03-26 15:03 ` Artem Bityutskiy 2012-02-29 17:09 ` [patch] Adding Secure Deletion to UBIFS Artem Bityutskiy 2012-02-29 17:09 ` Artem Bityutskiy 2012-03-15 14:48 ` [patch] Remove notion of key schemes Joel Reardon 2012-03-15 14:48 ` Joel Reardon 2012-03-16 12:43 ` Artem Bityutskiy 2012-03-16 12:43 ` Artem Bityutskiy 2012-03-16 12:51 ` Artem Bityutskiy 2012-03-16 12:51 ` Artem Bityutskiy 2012-03-16 13:34 ` Joel Reardon 2012-03-16 13:34 ` Joel Reardon 2012-03-16 13:41 ` Artem Bityutskiy 2012-03-16 13:41 ` Artem Bityutskiy 2012-03-16 15:02 ` Joel Reardon 2012-03-16 15:02 ` Joel Reardon 2012-03-19 14:56 ` Artem Bityutskiy 2012-03-19 14:56 ` Artem Bityutskiy 2012-02-20 20:15 ` [patch] Move CRC computation to separate function Joel Reardon 2012-02-20 20:15 ` Joel Reardon 2012-02-29 16:10 ` Artem Bityutskiy 2012-02-29 16:10 ` Artem Bityutskiy 2012-03-19 22:46 ` Joel Reardon 2012-03-19 22:46 ` Joel Reardon 2012-03-23 14:09 ` Artem Bityutskiy 2012-03-23 14:09 ` Artem Bityutskiy 2012-03-23 16:45 ` Joel Reardon 2012-03-23 16:45 ` Joel Reardon 2012-03-23 16:51 ` Artem Bityutskiy 2012-03-23 16:51 ` Artem Bityutskiy 2012-03-25 20:38 ` Joel Reardon 2012-03-25 20:38 ` Joel Reardon 2012-03-26 15:34 ` Artem Bityutskiy 2012-03-26 15:34 ` Artem Bityutskiy 2012-03-25 21:11 ` [patch] Add a encryption key parameter to the compress / decompress function Joel Reardon 2012-03-25 21:11 ` Joel Reardon 2012-03-25 21:38 ` [patch] Add cryptographic functionality when a key is passed to the compress / decompress functions Joel Reardon 2012-03-25 21:38 ` Joel Reardon 2012-03-27 8:33 ` Artem Bityutskiy 2012-03-27 8:33 ` Artem Bityutskiy 2012-03-29 14:39 ` [patch] UBIFS: " Joel Reardon 2012-03-29 14:39 ` Joel Reardon 2012-04-02 14:36 ` Artem Bityutskiy 2012-04-02 14:36 ` Artem Bityutskiy 2012-04-02 14:48 ` Joel Reardon 2012-04-02 14:48 ` Joel Reardon 2012-04-02 14:57 ` Artem Bityutskiy 2012-04-02 14:57 ` Artem Bityutskiy 2012-04-02 14:58 ` Joel Reardon 2012-04-02 14:58 ` Joel Reardon 2012-04-03 10:29 ` Joel Reardon 2012-04-03 10:29 ` Joel Reardon 2012-04-03 10:41 ` Guillaume LECERF 2012-04-03 10:41 ` Guillaume LECERF 2012-04-03 10:41 ` Guillaume LECERF 2012-04-03 11:35 ` Joel Reardon 2012-04-03 11:35 ` Joel Reardon 2012-04-12 14:05 ` Artem Bityutskiy 2012-04-12 14:05 ` Artem Bityutskiy 2012-03-27 8:27 ` [patch] Add a encryption key parameter to the compress / decompress function Artem Bityutskiy 2012-03-27 8:27 ` Artem Bityutskiy 2012-03-29 14:11 ` Joel Reardon [this message] 2012-03-29 14:11 ` [patch] UBIFS: " Joel Reardon 2012-04-02 14:02 ` Artem Bityutskiy 2012-04-02 14:02 ` Artem Bityutskiy 2012-02-29 17:25 ` [patch] Adding Secure Deletion to UBIFS Artem Bityutskiy 2012-02-29 17:25 ` Artem Bityutskiy 2012-03-01 13:41 ` Joel Reardon 2012-03-01 13:41 ` Joel Reardon 2012-03-09 7:36 ` Artem Bityutskiy 2012-03-09 7:36 ` Artem Bityutskiy 2012-03-09 19:29 ` Joel Reardon 2012-03-09 19:29 ` Joel Reardon 2012-03-12 13:30 ` Artem Bityutskiy 2012-03-12 13:30 ` Artem Bityutskiy 2012-03-12 13:34 ` Joel Reardon 2012-03-12 13:34 ` Joel Reardon 2012-03-12 13:36 ` Artem Bityutskiy 2012-03-12 13:36 ` Artem Bityutskiy 2012-03-12 13:37 ` Joel Reardon 2012-03-12 13:37 ` Joel Reardon 2012-03-14 10:20 ` Joel Reardon 2012-03-14 10:20 ` Joel Reardon 2012-03-14 10:27 ` Artem Bityutskiy 2012-03-14 10:27 ` Artem Bityutskiy
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=alpine.DEB.2.00.1203291606450.912@eristoteles.iwoars.net \ --to=joel@clambassador.com \ --cc=dedekind1@gmail.com \ --cc=linux-fsdevel@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mtd@lists.infradead.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.