diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2010-07-28 20:26:44 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2010-07-28 20:28:10 +0200 |
commit | 7a31387b49e0b04ba43bdf6fbc869c6a3e970251 (patch) | |
tree | 568ab043a8df33cd114e8cf236062bbdf10c7cc9 | |
parent | be973132e3717f46bbc7b5e54889ec5736c4f9a6 (diff) | |
download | kernel-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-- | TODO | 1 | ||||
-rw-r--r-- | ncr-int.h | 1 | ||||
-rw-r--r-- | ncr.c | 7 | ||||
-rw-r--r-- | ncr.h | 3 | ||||
-rw-r--r-- | userspace/setkey.c | 4 |
5 files changed, 11 insertions, 5 deletions
@@ -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__) @@ -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; @@ -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 */ |