linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC][PATCH 6/6] ecryptfs: added support for the encrypted key type
@ 2010-12-23 17:17 Roberto Sassu
  0 siblings, 0 replies; 3+ messages in thread
From: Roberto Sassu @ 2010-12-23 17:17 UTC (permalink / raw)
  To: linux-security-module
  Cc: keyrings, linux-fsdevel, Mimi Zohar, David Howells, James Morris,
	David Safford, Gianluca Ramunno, Tyler Hicks, kirkland

[-- Attachment #1: Type: text/plain, Size: 2497 bytes --]

The function ecryptfs_keyring_auth_tok_for_sig() has been modified in order
to search keys of both 'user' and 'encrypted' types.

Signed-off-by: Roberto Sassu <roberto.sassu@polito.it>
---
 fs/ecryptfs/ecryptfs_kernel.h |   11 +++++++++--
 fs/ecryptfs/keystore.c        |   15 +++++++++++----
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h
index a27cad4..068eade 100644
--- a/fs/ecryptfs/ecryptfs_kernel.h
+++ b/fs/ecryptfs/ecryptfs_kernel.h
@@ -29,6 +29,7 @@
 #define ECRYPTFS_KERNEL_H
 
 #include <keys/user-type.h>
+#include <keys/encrypted-type.h>
 #include <linux/fs.h>
 #include <linux/fs_stack.h>
 #include <linux/namei.h>
@@ -81,8 +82,14 @@ struct ecryptfs_page_crypt_context {
 static inline struct ecryptfs_auth_tok *
 ecryptfs_get_key_payload_data(struct key *key)
 {
-	return (struct ecryptfs_auth_tok *)
-		(((struct user_key_payload*)key->payload.data)->data);
+#if defined(CONFIG_ENCRYPTED_KEYS) || defined(CONFIG_ENCRYPTED_KEYS_MODULE)
+	if (key->type == &key_type_encrypted)
+		return (struct ecryptfs_auth_tok *)
+			(&((struct encrypted_key_payload *)key->payload.data)-
>payload_data);
+	else
+#endif
+		return (struct ecryptfs_auth_tok *)
+			(((struct user_key_payload *)key->payload.data)->data);
 }
 
 #define ECRYPTFS_SUPER_MAGIC 0xf15f
diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c
index 73811cf..8d72635 100644
--- a/fs/ecryptfs/keystore.c
+++ b/fs/ecryptfs/keystore.c
@@ -1542,10 +1542,17 @@ int ecryptfs_keyring_auth_tok_for_sig(struct key 
**auth_tok_key,
 
 	(*auth_tok_key) = request_key(&key_type_user, sig, NULL);
 	if (!(*auth_tok_key) || IS_ERR(*auth_tok_key)) {
-		printk(KERN_ERR "Could not find key with description: [%s]\n",
-		       sig);
-		rc = process_request_key_err(PTR_ERR(*auth_tok_key));
-		goto out;
+#if defined(CONFIG_ENCRYPTED_KEYS) || defined(CONFIG_ENCRYPTED_KEYS_MODULE)
+		(*auth_tok_key) = request_key(&key_type_encrypted, sig, NULL);
+		if (!(*auth_tok_key) || IS_ERR(*auth_tok_key)) {
+#endif
+			printk(KERN_ERR "Could not find key with description: [%s]\n",
+			      sig);
+			rc = process_request_key_err(PTR_ERR(*auth_tok_key));
+			goto out;
+#if defined(CONFIG_ENCRYPTED_KEYS) || defined(CONFIG_ENCRYPTED_KEYS_MODULE)
+		}
+#endif
 	}
 	(*auth_tok) = ecryptfs_get_key_payload_data(*auth_tok_key);
 	if (ecryptfs_verify_version((*auth_tok)->version)) {
-- 
1.7.2.3


[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 4401 bytes --]

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [RFC][PATCH 6/6] ecryptfs: added support for the encrypted key type
@ 2010-12-23 17:36 Roberto Sassu
  2010-12-24 15:47 ` Mimi Zohar
  0 siblings, 1 reply; 3+ messages in thread
From: Roberto Sassu @ 2010-12-23 17:36 UTC (permalink / raw)
  To: linux-security-module
  Cc: keyrings, linux-fsdevel, linux-kernel, Mimi Zohar, David Howells,
	James Morris, David Safford, Gianluca Ramunno, Tyler Hicks,
	kirkland

[-- Attachment #1: Type: text/plain, Size: 2493 bytes --]

The function ecryptfs_keyring_auth_tok_for_sig() has been modified in order
to search keys of both 'user' and 'encrypted' types.

Signed-off-by: Roberto Sassu <roberto.sassu@polito.it>
---
 fs/ecryptfs/ecryptfs_kernel.h |   11 +++++++++--
 fs/ecryptfs/keystore.c        |   15 +++++++++++----
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h
index a27cad4..068eade 100644
--- a/fs/ecryptfs/ecryptfs_kernel.h
+++ b/fs/ecryptfs/ecryptfs_kernel.h
@@ -29,6 +29,7 @@
 #define ECRYPTFS_KERNEL_H
 
 #include <keys/user-type.h>
+#include <keys/encrypted-type.h>
 #include <linux/fs.h>
 #include <linux/fs_stack.h>
 #include <linux/namei.h>
@@ -81,8 +82,14 @@ struct ecryptfs_page_crypt_context {
 static inline struct ecryptfs_auth_tok *
 ecryptfs_get_key_payload_data(struct key *key)
 {
-	return (struct ecryptfs_auth_tok *)
-		(((struct user_key_payload*)key->payload.data)->data);
+#if defined(CONFIG_ENCRYPTED_KEYS) || defined(CONFIG_ENCRYPTED_KEYS_MODULE)
+	if (key->type == &key_type_encrypted)
+		return (struct ecryptfs_auth_tok *)
+			(&((struct encrypted_key_payload *)key->payload.data)->payload_data);
+	else
+#endif
+		return (struct ecryptfs_auth_tok *)
+			(((struct user_key_payload *)key->payload.data)->data);
 }
 
 #define ECRYPTFS_SUPER_MAGIC 0xf15f
diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c
index 73811cf..8d72635 100644
--- a/fs/ecryptfs/keystore.c
+++ b/fs/ecryptfs/keystore.c
@@ -1542,10 +1542,17 @@ int ecryptfs_keyring_auth_tok_for_sig(struct key **auth_tok_key,
 
 	(*auth_tok_key) = request_key(&key_type_user, sig, NULL);
 	if (!(*auth_tok_key) || IS_ERR(*auth_tok_key)) {
-		printk(KERN_ERR "Could not find key with description: [%s]\n",
-		       sig);
-		rc = process_request_key_err(PTR_ERR(*auth_tok_key));
-		goto out;
+#if defined(CONFIG_ENCRYPTED_KEYS) || defined(CONFIG_ENCRYPTED_KEYS_MODULE)
+		(*auth_tok_key) = request_key(&key_type_encrypted, sig, NULL);
+		if (!(*auth_tok_key) || IS_ERR(*auth_tok_key)) {
+#endif
+			printk(KERN_ERR "Could not find key with description: [%s]\n",
+			      sig);
+			rc = process_request_key_err(PTR_ERR(*auth_tok_key));
+			goto out;
+#if defined(CONFIG_ENCRYPTED_KEYS) || defined(CONFIG_ENCRYPTED_KEYS_MODULE)
+		}
+#endif
 	}
 	(*auth_tok) = ecryptfs_get_key_payload_data(*auth_tok_key);
 	if (ecryptfs_verify_version((*auth_tok)->version)) {
-- 
1.7.2.3


[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 4401 bytes --]

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [RFC][PATCH 6/6] ecryptfs: added support for the encrypted key type
  2010-12-23 17:36 [RFC][PATCH 6/6] ecryptfs: added support for the encrypted key type Roberto Sassu
@ 2010-12-24 15:47 ` Mimi Zohar
  0 siblings, 0 replies; 3+ messages in thread
From: Mimi Zohar @ 2010-12-24 15:47 UTC (permalink / raw)
  To: Roberto Sassu
  Cc: linux-security-module, keyrings, linux-fsdevel, linux-kernel,
	David Howells, James Morris, David Safford, Gianluca Ramunno,
	Tyler Hicks, kirkland

On Thu, 2010-12-23 at 18:36 +0100, Roberto Sassu wrote: 
> The function ecryptfs_keyring_auth_tok_for_sig() has been modified in order
> to search keys of both 'user' and 'encrypted' types.
> 
> Signed-off-by: Roberto Sassu <roberto.sassu@polito.it>
> ---
>  fs/ecryptfs/ecryptfs_kernel.h |   11 +++++++++--
>  fs/ecryptfs/keystore.c        |   15 +++++++++++----
>  2 files changed, 20 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h
> index a27cad4..068eade 100644
> --- a/fs/ecryptfs/ecryptfs_kernel.h
> +++ b/fs/ecryptfs/ecryptfs_kernel.h
> @@ -29,6 +29,7 @@
>  #define ECRYPTFS_KERNEL_H
>  
>  #include <keys/user-type.h>
> +#include <keys/encrypted-type.h>
>  #include <linux/fs.h>
>  #include <linux/fs_stack.h>
>  #include <linux/namei.h>
> @@ -81,8 +82,14 @@ struct ecryptfs_page_crypt_context {
>  static inline struct ecryptfs_auth_tok *
>  ecryptfs_get_key_payload_data(struct key *key)
>  {
> -	return (struct ecryptfs_auth_tok *)
> -		(((struct user_key_payload*)key->payload.data)->data);
> +#if defined(CONFIG_ENCRYPTED_KEYS) || defined(CONFIG_ENCRYPTED_KEYS_MODULE)
> +	if (key->type == &key_type_encrypted)
> +		return (struct ecryptfs_auth_tok *)
> +			(&((struct encrypted_key_payload *)key->payload.data)->payload_data);
> +	else
> +#endif
> +		return (struct ecryptfs_auth_tok *)
> +			(((struct user_key_payload *)key->payload.data)->data);
>  }

'ifdefs' belong in include files. How about defining
ecryptfs_get_encrypted_key_payload_data() with stub function?


> #define ECRYPTFS_SUPER_MAGIC 0xf15f
> diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c
> index 73811cf..8d72635 100644
> --- a/fs/ecryptfs/keystore.c
> +++ b/fs/ecryptfs/keystore.c
> @@ -1542,10 +1542,17 @@ int ecryptfs_keyring_auth_tok_for_sig(struct key **auth_tok_key,
>  
>  	(*auth_tok_key) = request_key(&key_type_user, sig, NULL);
>  	if (!(*auth_tok_key) || IS_ERR(*auth_tok_key)) {
> -		printk(KERN_ERR "Could not find key with description: [%s]\n",
> -		       sig);
> -		rc = process_request_key_err(PTR_ERR(*auth_tok_key));
> -		goto out;
> +#if defined(CONFIG_ENCRYPTED_KEYS) || defined(CONFIG_ENCRYPTED_KEYS_MODULE)
> +		(*auth_tok_key) = request_key(&key_type_encrypted, sig, NULL);
> +		if (!(*auth_tok_key) || IS_ERR(*auth_tok_key)) {
> +#endif
> +			printk(KERN_ERR "Could not find key with description: [%s]\n",
> +			      sig);
> +			rc = process_request_key_err(PTR_ERR(*auth_tok_key));
> +			goto out;
> +#if defined(CONFIG_ENCRYPTED_KEYS) || defined(CONFIG_ENCRYPTED_KEYS_MODULE)
> +		}
> +#endif

Same here.

thanks,

Mimi

> 	}
>  	(*auth_tok) = ecryptfs_get_key_payload_data(*auth_tok_key);
>  	if (ecryptfs_verify_version((*auth_tok)->version)) {




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-12-24 15:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-23 17:36 [RFC][PATCH 6/6] ecryptfs: added support for the encrypted key type Roberto Sassu
2010-12-24 15:47 ` Mimi Zohar
  -- strict thread matches above, loose matches on Subject: below --
2010-12-23 17:17 Roberto Sassu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).