]> code.ossystems Code Review - meta-freescale.git/blob
2213faec87935d5cefe5499730235327ad320923
[meta-freescale.git] /
1 From 800af48d0c26830943ca2308dd426b5b09811750 Mon Sep 17 00:00:00 2001
2 From: Yashpal Dutta <yashpal.dutta@freescale.com>
3 Date: Thu, 17 Apr 2014 07:08:47 +0545
4 Subject: [PATCH 09/15] Fixed compilation error of openssl with fsl cryptodev
5
6 Upstream-status: Pending
7
8 Signed-off-by: Yashpal Dutta <yashpal.dutta@freescale.com>
9 Tested-by: Cristian Stoica <cristian.stoica@freescale.com>
10 ---
11  authenc.c          | 1 +
12  cryptlib.c         | 9 ++++-----
13  crypto/cryptodev.h | 9 ++++++++-
14  cryptodev_int.h    | 2 +-
15  ioctl.c            | 8 ++++++--
16  main.c             | 1 +
17  6 files changed, 21 insertions(+), 9 deletions(-)
18
19 diff --git a/authenc.c b/authenc.c
20 index ef0d3db..2aa4d38 100644
21 --- a/authenc.c
22 +++ b/authenc.c
23 @@ -2,6 +2,7 @@
24   * Driver for /dev/crypto device (aka CryptoDev)
25   *
26   * Copyright (c) 2011, 2012 OpenSSL Software Foundation, Inc.
27 + * Copyright (c) 2014 Freescale Semiconductor, Inc.
28   *
29   * Author: Nikos Mavrogiannopoulos
30   *
31 diff --git a/cryptlib.c b/cryptlib.c
32 index 4dd1847..ec6693e 100644
33 --- a/cryptlib.c
34 +++ b/cryptlib.c
35 @@ -4,8 +4,7 @@
36   * Copyright (c) 2010,2011 Nikos Mavrogiannopoulos <nmav@gnutls.org>
37   * Portions Copyright (c) 2010 Michael Weiser
38   * Portions Copyright (c) 2010 Phil Sutter
39 - *
40 - * Copyright 2012 Freescale Semiconductor, Inc.
41 + * Copyright 2012-2014 Freescale Semiconductor, Inc.
42   *
43   * This file is part of linux cryptodev.
44   *
45 @@ -144,7 +143,7 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name,
46                         if (alg->max_keysize > 0 &&
47                                         unlikely((keylen < alg->min_keysize) ||
48                                         (keylen > alg->max_keysize))) {
49 -                               ddebug(1, "Wrong keylen '%zu' for algorithm '%s'. Use %u to %u.",
50 +                               ddebug(1, "Wrong keylen '%u' for algorithm '%s'. Use %u to %u.",
51                                                 keylen, alg_name, alg->min_keysize, alg->max_keysize);
52                                 ret = -EINVAL;
53                                 goto error;
54 @@ -171,7 +170,7 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name,
55         }
56  
57         if (unlikely(ret)) {
58 -               ddebug(1, "Setting key failed for %s-%zu.", alg_name, keylen*8);
59 +               ddebug(1, "Setting key failed for %s-%u.", alg_name, keylen*8);
60                 ret = -EINVAL;
61                 goto error;
62         }
63 @@ -338,7 +337,7 @@ int cryptodev_hash_init(struct hash_data *hdata, const char *alg_name,
64         if (hmac_mode != 0) {
65                 ret = crypto_ahash_setkey(hdata->async.s, mackey, mackeylen);
66                 if (unlikely(ret)) {
67 -                       ddebug(1, "Setting hmac key failed for %s-%zu.",
68 +                       ddebug(1, "Setting hmac key failed for %s-%u.",
69                                         alg_name, mackeylen*8);
70                         ret = -EINVAL;
71                         goto error;
72 diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h
73 index d0cc542..e7edd97 100644
74 --- a/crypto/cryptodev.h
75 +++ b/crypto/cryptodev.h
76 @@ -234,6 +234,13 @@ struct crypt_auth_op {
77  #define        CRYPTO_ALG_FLAG_RNG_ENABLE      2
78  #define        CRYPTO_ALG_FLAG_DSA_SHA         4
79  
80 +enum ec_curve_t {
81 +       EC_DISCRETE_LOG,
82 +       EC_PRIME,
83 +       EC_BINARY,
84 +       MAX_EC_TYPE
85 +};
86 +
87  struct crparam {
88         __u8    *crp_p;
89         __u32   crp_nbits;
90 @@ -249,7 +256,7 @@ struct crypt_kop {
91         __u16   crk_oparams;
92         __u32   crk_pad1;
93         struct crparam  crk_param[CRK_MAXPARAM];
94 -       enum curve_t curve_type; /* 0 == Discrete Log,
95 +       enum ec_curve_t curve_type; /* 0 == Discrete Log,
96                                 1 = EC_PRIME, 2 = EC_BINARY */
97         void *cookie;
98  };
99 diff --git a/cryptodev_int.h b/cryptodev_int.h
100 index 5347cae..c83c885 100644
101 --- a/cryptodev_int.h
102 +++ b/cryptodev_int.h
103 @@ -88,7 +88,7 @@ struct compat_crypt_kop {
104         uint16_t        crk_oparams;
105         uint32_t        crk_pad1;
106         struct compat_crparam   crk_param[CRK_MAXPARAM];
107 -       enum curve_t curve_type; /* 0 == Discrete Log, 1 = EC_PRIME,
108 +       enum ec_curve_t curve_type; /* 0 == Discrete Log, 1 = EC_PRIME,
109                                  2 = EC_BINARY */
110         compat_uptr_t cookie;
111  };
112 diff --git a/ioctl.c b/ioctl.c
113 index 3762a47..c97320b 100644
114 --- a/ioctl.c
115 +++ b/ioctl.c
116 @@ -4,7 +4,7 @@
117   * Copyright (c) 2004 Michal Ludvig <mludvig@logix.net.nz>, SuSE Labs
118   * Copyright (c) 2009,2010,2011 Nikos Mavrogiannopoulos <nmav@gnutls.org>
119   * Copyright (c) 2010 Phil Sutter
120 - * Copyright 2012 Freescale Semiconductor, Inc.
121 + * Copyright 2012-2014 Freescale Semiconductor, Inc.
122   *
123   * This file is part of linux cryptodev.
124   *
125 @@ -501,6 +501,7 @@ cryptodev_open(struct inode *inode, struct file *filp)
126         INIT_LIST_HEAD(&pcr->done.list);
127         INIT_LIST_HEAD(&pcr->asym_completed_list);
128         spin_lock_init(&pcr->completion_lock);
129 +
130         INIT_WORK(&pcr->cryptask, cryptask_routine);
131  
132         init_waitqueue_head(&pcr->user_waiter);
133 @@ -780,8 +781,11 @@ static int fill_kcop_from_cop(struct kernel_crypt_op *kcop, struct fcrypt *fcr)
134  
135         if (cop->iv) {
136                 rc = copy_from_user(kcop->iv, cop->iv, kcop->ivlen);
137 -               if (unlikely(rc))
138 +               if (unlikely(rc)) {
139 +                       derr(1, "error copying IV (%d bytes), copy_from_user returned %d for address %p",
140 +                                       kcop->ivlen, rc, cop->iv);
141                         return -EFAULT;
142 +               }
143         }
144  
145         return 0;
146 diff --git a/main.c b/main.c
147 index 14dcf40..6365911 100644
148 --- a/main.c
149 +++ b/main.c
150 @@ -3,6 +3,7 @@
151   *
152   * Copyright (c) 2004 Michal Ludvig <mludvig@logix.net.nz>, SuSE Labs
153   * Copyright (c) 2009-2013 Nikos Mavrogiannopoulos <nmav@gnutls.org>
154 + * Copyright (c) 2014 Freescale Semiconductor, Inc.
155   *
156   * This file is part of linux cryptodev.
157   *
158 -- 
159 2.3.5
160