summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2010-07-28 20:26:44 +0200
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2010-07-28 20:28:10 +0200
commit7a31387b49e0b04ba43bdf6fbc869c6a3e970251 (patch)
tree568ab043a8df33cd114e8cf236062bbdf10c7cc9
parentbe973132e3717f46bbc7b5e54889ec5736c4f9a6 (diff)
downloadkernel-crypto-7a31387b49e0b04ba43bdf6fbc869c6a3e970251.tar.gz
kernel-crypto-7a31387b49e0b04ba43bdf6fbc869c6a3e970251.tar.xz
kernel-crypto-7a31387b49e0b04ba43bdf6fbc869c6a3e970251.zip
NCR_CIPHER_MAX_KEY_LEN no longer exist in userspace API.
-rw-r--r--TODO1
-rw-r--r--ncr-int.h1
-rw-r--r--ncr.c7
-rw-r--r--ncr.h3
-rw-r--r--userspace/setkey.c4
5 files changed, 11 insertions, 5 deletions
diff --git a/TODO b/TODO
index 5ed80e126f0..98b81fc24ff 100644
--- a/TODO
+++ b/TODO
@@ -1,3 +1,4 @@
* ioctl_compat() mode for ncr.h API as it is in cryptodev.h
* Put limits to sessions
* Export private keys to PKCS #8 format (can it be implemented?)
+* Documentation for functions
diff --git a/ncr-int.h b/ncr-int.h
index 489e052b1bb..e79747c12ca 100644
--- a/ncr-int.h
+++ b/ncr-int.h
@@ -8,6 +8,7 @@
#include <ncr-dh.h>
#define KEY_DATA_MAX_SIZE 3*1024
+#define NCR_CIPHER_MAX_KEY_LEN 1024
#define err() printk(KERN_DEBUG"ncr: %s: %s: %d\n", __FILE__, __func__, __LINE__)
diff --git a/ncr.c b/ncr.c
index 624d2174e4c..7608312ed7b 100644
--- a/ncr.c
+++ b/ncr.c
@@ -103,11 +103,14 @@ struct ncr_master_key_st st;
dprintk(0, KERN_DEBUG, "Master key was previously initialized.\n");
}
+ if (unlikely(copy_from_user(master_key.key.secret.data, st.key, st.key_size))) {
+ err();
+ return -EFAULT;
+ }
+
dprintk(0, KERN_INFO, "Initializing master key.\n");
master_key.type = NCR_KEY_TYPE_SECRET;
-
- memcpy(master_key.key.secret.data, st.key, st.key_size);
master_key.key.secret.size = st.key_size;
return 0;
diff --git a/ncr.h b/ncr.h
index 01fd4131187..53c77be865f 100644
--- a/ncr.h
+++ b/ncr.h
@@ -7,7 +7,6 @@
#endif
#define NCR_CIPHER_MAX_BLOCK_LEN 32
-#define NCR_CIPHER_MAX_KEY_LEN 512
#define NCR_HASH_MAX_OUTPUT_SIZE 64
typedef enum {
@@ -221,7 +220,7 @@ struct ncr_key_wrap_st {
/* Internal ops */
struct ncr_master_key_st {
- uint8_t key[NCR_CIPHER_MAX_KEY_LEN];
+ uint8_t __user * key;
uint16_t key_size;
};
diff --git a/userspace/setkey.c b/userspace/setkey.c
index d0a2b62d42d..ea9d30ea684 100644
--- a/userspace/setkey.c
+++ b/userspace/setkey.c
@@ -25,6 +25,7 @@ int main(int argc, char** argv)
struct ncr_master_key_st key;
int size, ret;
struct stat st;
+ uint8_t rawkey[32];
if (argc != 2) {
fprintf(stderr, "Usage: setkey [filename]\n");
@@ -52,12 +53,13 @@ int main(int argc, char** argv)
exit(1);
}
- size = fread(key.key, 1, sizeof(key.key), fp);
+ size = fread(rawkey, 1, sizeof(rawkey), fp);
if (size < 16) {
fprintf(stderr, "Illegal key!\n");
exit(1);
}
fclose(fp);
+ key.key = rawkey;
key.key_size = size;
/* Open the crypto device */