]> code.ossystems Code Review - meta-freescale.git/blob
afd97515ed2603b5a79da864458cb712028330b6
[meta-freescale.git] /
1 From 4843f76a74558b85944dbf923cf699bfd5b354eb Mon Sep 17 00:00:00 2001
2 From: Cristian Stoica <cristian.stoica@nxp.com>
3 Date: Tue, 29 Nov 2016 13:37:23 +0200
4 Subject: [PATCH 097/104] avoid implicit conversion between signed and unsigned
5  char
6
7 Use uint8_t type for all variables with this problem and avoid casting
8 from char in assignments. With uint8_t we also convey the information
9 that we're using small numbers rather than strings.
10
11 Although cryptodev.h uses the synonym type __u8, we use uint8_t
12 for consistency with other files in tests directory and also because it
13 is a standard POSIX type.
14
15 Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com>
16 ---
17  tests/async_hmac.c  | 12 ++++++------
18  tests/cipher-aead.c | 10 +++++-----
19  tests/cipher-gcm.c  | 40 ++++++++++++++++++++--------------------
20  tests/cipher.c      |  1 -
21  tests/fullspeed.c   |  1 +
22  tests/hmac.c        | 12 ++++++------
23  6 files changed, 38 insertions(+), 38 deletions(-)
24
25 diff --git a/tests/async_hmac.c b/tests/async_hmac.c
26 index 1bdaad3..014b8ed 100644
27 --- a/tests/async_hmac.c
28 +++ b/tests/async_hmac.c
29 @@ -61,7 +61,7 @@ test_crypto(int cfd)
30  
31         cryp.ses = sess.ses;
32         cryp.len = sizeof("what do ya want for nothing?")-1;
33 -       cryp.src = (uint8_t*)"what do ya want for nothing?";
34 +       cryp.src = (uint8_t *)"what do ya want for nothing?";
35         cryp.mac = mac;
36         cryp.op = COP_ENCRYPT;
37  
38 @@ -88,7 +88,7 @@ test_crypto(int cfd)
39         memset(mac, 0, sizeof(mac));
40  
41         sess.cipher = 0;
42 -       sess.mackey = (uint8_t*)"Jefe";
43 +       sess.mackey = (uint8_t *)"Jefe";
44         sess.mackeylen = 4;
45         sess.mac = CRYPTO_MD5_HMAC;
46         if (ioctl(cfd, CIOCGSESSION, &sess)) {
47 @@ -98,7 +98,7 @@ test_crypto(int cfd)
48  
49         cryp.ses = sess.ses;
50         cryp.len = sizeof("what do ya want for nothing?")-1;
51 -       cryp.src = (uint8_t*)"what do ya want for nothing?";
52 +       cryp.src = (uint8_t *)"what do ya want for nothing?";
53         cryp.mac = mac;
54         cryp.op = COP_ENCRYPT;
55  
56 @@ -127,7 +127,7 @@ test_crypto(int cfd)
57         sess.keylen = KEY_SIZE;
58         sess.key = data.key;
59         sess.mackeylen = 16;
60 -       sess.mackey = (uint8_t*)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b";
61 +       sess.mackey = (uint8_t *)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b";
62         if (ioctl(cfd, CIOCGSESSION, &sess)) {
63                 perror("ioctl(CIOCGSESSION)");
64                 return 1;
65 @@ -206,7 +206,7 @@ test_extras(int cfd)
66  
67         cryp.ses = sess.ses;
68         cryp.len = sizeof("what do")-1;
69 -       cryp.src = (uint8_t*)"what do";
70 +       cryp.src = (uint8_t *)"what do";
71         cryp.mac = mac;
72         cryp.op = COP_ENCRYPT;
73         cryp.flags = COP_FLAG_UPDATE;
74 @@ -216,7 +216,7 @@ test_extras(int cfd)
75  
76         cryp.ses = sess.ses;
77         cryp.len = sizeof(" ya want for nothing?")-1;
78 -       cryp.src = (uint8_t*)" ya want for nothing?";
79 +       cryp.src = (uint8_t *)" ya want for nothing?";
80         cryp.mac = mac;
81         cryp.op = COP_ENCRYPT;
82         cryp.flags = COP_FLAG_FINAL;
83 diff --git a/tests/cipher-aead.c b/tests/cipher-aead.c
84 index b329d12..305b720 100644
85 --- a/tests/cipher-aead.c
86 +++ b/tests/cipher-aead.c
87 @@ -118,7 +118,7 @@ test_crypto(int cfd)
88  
89         sess.mac = CRYPTO_SHA1_HMAC;
90         sess.mackeylen = 16;
91 -       sess.mackey = (uint8_t*)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b";
92 +       sess.mackey = (uint8_t *)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b";
93  
94         if (ioctl(cfd, CIOCGSESSION, &sess)) {
95                 perror("ioctl(CIOCGSESSION)");
96 @@ -271,7 +271,7 @@ test_encrypt_decrypt(int cfd)
97  
98         sess.mac = CRYPTO_SHA1_HMAC;
99         sess.mackeylen = 16;
100 -       sess.mackey = (uint8_t*)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b";
101 +       sess.mackey = (uint8_t *)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b";
102  
103         if (ioctl(cfd, CIOCGSESSION, &sess)) {
104                 perror("ioctl(CIOCGSESSION)");
105 @@ -329,7 +329,7 @@ test_encrypt_decrypt(int cfd)
106         sess.key = key;
107         sess.mac = CRYPTO_SHA1_HMAC;
108         sess.mackeylen = 16;
109 -       sess.mackey = (uint8_t*)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b";
110 +       sess.mackey = (uint8_t *)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b";
111  
112         if (ioctl(cfd, CIOCGSESSION, &sess)) {
113                 perror("ioctl(CIOCGSESSION)");
114 @@ -420,7 +420,7 @@ test_encrypt_decrypt_error(int cfd, int err)
115  
116         sess.mac = CRYPTO_SHA1_HMAC;
117         sess.mackeylen = 16;
118 -       sess.mackey = (uint8_t*)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b";
119 +       sess.mackey = (uint8_t *)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b";
120  
121         if (ioctl(cfd, CIOCGSESSION, &sess)) {
122                 perror("ioctl(CIOCGSESSION)");
123 @@ -477,7 +477,7 @@ test_encrypt_decrypt_error(int cfd, int err)
124         sess.key = key;
125         sess.mac = CRYPTO_SHA1_HMAC;
126         sess.mackeylen = 16;
127 -       sess.mackey = (uint8_t*)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b";
128 +       sess.mackey = (uint8_t *)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b";
129  
130         if (ioctl(cfd, CIOCGSESSION, &sess)) {
131                 perror("ioctl(CIOCGSESSION)");
132 diff --git a/tests/cipher-gcm.c b/tests/cipher-gcm.c
133 index d5f8486..36c827a 100644
134 --- a/tests/cipher-gcm.c
135 +++ b/tests/cipher-gcm.c
136 @@ -46,45 +46,45 @@ struct aes_gcm_vectors_st {
137  
138  struct aes_gcm_vectors_st aes_gcm_vectors[] = {
139         {
140 -        .key = (uint8_t*)
141 +        .key = (uint8_t *)
142          "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
143          .auth = NULL,
144          .auth_size = 0,
145 -        .plaintext = (uint8_t*)
146 +        .plaintext = (uint8_t *)
147          "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
148          .plaintext_size = 16,
149 -        .ciphertext = (uint8_t*)
150 +        .ciphertext = (uint8_t *)
151          "\x03\x88\xda\xce\x60\xb6\xa3\x92\xf3\x28\xc2\xb9\x71\xb2\xfe\x78",
152 -        .iv = (uint8_t*)"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
153 -        .tag = (uint8_t*)
154 +        .iv = (uint8_t *)"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
155 +        .tag = (uint8_t *)
156          "\xab\x6e\x47\xd4\x2c\xec\x13\xbd\xf5\x3a\x67\xb2\x12\x57\xbd\xdf"
157         },
158         {
159 -        .key = (uint8_t*)
160 +        .key = (uint8_t *)
161          "\xfe\xff\xe9\x92\x86\x65\x73\x1c\x6d\x6a\x8f\x94\x67\x30\x83\x08",
162          .auth = NULL,
163          .auth_size = 0,
164 -        .plaintext = (uint8_t*)
165 +        .plaintext = (uint8_t *)
166          "\xd9\x31\x32\x25\xf8\x84\x06\xe5\xa5\x59\x09\xc5\xaf\xf5\x26\x9a\x86\xa7\xa9\x53\x15\x34\xf7\xda\x2e\x4c\x30\x3d\x8a\x31\x8a\x72\x1c\x3c\x0c\x95\x95\x68\x09\x53\x2f\xcf\x0e\x24\x49\xa6\xb5\x25\xb1\x6a\xed\xf5\xaa\x0d\xe6\x57\xba\x63\x7b\x39\x1a\xaf\xd2\x55",
167          .plaintext_size = 64,
168 -        .ciphertext = (uint8_t*)
169 +        .ciphertext = (uint8_t *)
170          "\x42\x83\x1e\xc2\x21\x77\x74\x24\x4b\x72\x21\xb7\x84\xd0\xd4\x9c\xe3\xaa\x21\x2f\x2c\x02\xa4\xe0\x35\xc1\x7e\x23\x29\xac\xa1\x2e\x21\xd5\x14\xb2\x54\x66\x93\x1c\x7d\x8f\x6a\x5a\xac\x84\xaa\x05\x1b\xa3\x0b\x39\x6a\x0a\xac\x97\x3d\x58\xe0\x91\x47\x3f\x59\x85",
171 -        .iv = (uint8_t*)"\xca\xfe\xba\xbe\xfa\xce\xdb\xad\xde\xca\xf8\x88",
172 -        .tag = (uint8_t*)"\x4d\x5c\x2a\xf3\x27\xcd\x64\xa6\x2c\xf3\x5a\xbd\x2b\xa6\xfa\xb4"
173 +        .iv = (uint8_t *)"\xca\xfe\xba\xbe\xfa\xce\xdb\xad\xde\xca\xf8\x88",
174 +        .tag = (uint8_t *)"\x4d\x5c\x2a\xf3\x27\xcd\x64\xa6\x2c\xf3\x5a\xbd\x2b\xa6\xfa\xb4"
175         },
176         {
177 -        .key = (uint8_t*)
178 +        .key = (uint8_t *)
179          "\xfe\xff\xe9\x92\x86\x65\x73\x1c\x6d\x6a\x8f\x94\x67\x30\x83\x08",
180 -        .auth = (uint8_t*)
181 +        .auth = (uint8_t *)
182          "\xfe\xed\xfa\xce\xde\xad\xbe\xef\xfe\xed\xfa\xce\xde\xad\xbe\xef\xab\xad\xda\xd2",
183          .auth_size = 20,
184 -        .plaintext = (uint8_t*)
185 +        .plaintext = (uint8_t *)
186          "\xd9\x31\x32\x25\xf8\x84\x06\xe5\xa5\x59\x09\xc5\xaf\xf5\x26\x9a\x86\xa7\xa9\x53\x15\x34\xf7\xda\x2e\x4c\x30\x3d\x8a\x31\x8a\x72\x1c\x3c\x0c\x95\x95\x68\x09\x53\x2f\xcf\x0e\x24\x49\xa6\xb5\x25\xb1\x6a\xed\xf5\xaa\x0d\xe6\x57\xba\x63\x7b\x39",
187          .plaintext_size = 60,
188 -        .ciphertext = (uint8_t*)
189 +        .ciphertext = (uint8_t *)
190          "\x42\x83\x1e\xc2\x21\x77\x74\x24\x4b\x72\x21\xb7\x84\xd0\xd4\x9c\xe3\xaa\x21\x2f\x2c\x02\xa4\xe0\x35\xc1\x7e\x23\x29\xac\xa1\x2e\x21\xd5\x14\xb2\x54\x66\x93\x1c\x7d\x8f\x6a\x5a\xac\x84\xaa\x05\x1b\xa3\x0b\x39\x6a\x0a\xac\x97\x3d\x58\xe0\x91",
191 -        .iv = (uint8_t*)"\xca\xfe\xba\xbe\xfa\xce\xdb\xad\xde\xca\xf8\x88",
192 -        .tag = (uint8_t*)
193 +        .iv = (uint8_t *)"\xca\xfe\xba\xbe\xfa\xce\xdb\xad\xde\xca\xf8\x88",
194 +        .tag = (uint8_t *)
195          "\x5b\xc9\x4f\xbc\x32\x21\xa5\xdb\x94\xfa\xe9\x5a\xe7\x12\x1a\x47"
196         }
197  };
198 @@ -233,8 +233,8 @@ static int test_encrypt_decrypt(int cfd)
199  //      printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n",
200  //                      siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name);
201  
202 -       plaintext = (__u8 *)buf_align(plaintext_raw, siop.alignmask);
203 -       ciphertext = (__u8 *)buf_align(ciphertext_raw, siop.alignmask);
204 +       plaintext = (uint8_t *)buf_align(plaintext_raw, siop.alignmask);
205 +       ciphertext = (uint8_t *)buf_align(ciphertext_raw, siop.alignmask);
206  
207         memset(plaintext, 0x15, DATA_SIZE);
208  
209 @@ -382,8 +382,8 @@ static int test_encrypt_decrypt_error(int cfd, int err)
210  //      printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n",
211  //                      siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name);
212  
213 -       plaintext = (__u8 *)buf_align(plaintext_raw, siop.alignmask);
214 -       ciphertext = (__u8 *)buf_align(ciphertext_raw, siop.alignmask);
215 +       plaintext = (uint8_t *)buf_align(plaintext_raw, siop.alignmask);
216 +       ciphertext = (uint8_t *)buf_align(ciphertext_raw, siop.alignmask);
217  
218         memset(plaintext, 0x15, DATA_SIZE);
219         memcpy(ciphertext, plaintext, DATA_SIZE);
220 diff --git a/tests/cipher.c b/tests/cipher.c
221 index 222f095..fab3de6 100644
222 --- a/tests/cipher.c
223 +++ b/tests/cipher.c
224 @@ -9,7 +9,6 @@
225  #include <unistd.h>
226  #include <fcntl.h>
227  #include <stdint.h>
228 -
229  #include <sys/ioctl.h>
230  #include <crypto/cryptodev.h>
231  #include "testhelper.h"
232 diff --git a/tests/fullspeed.c b/tests/fullspeed.c
233 index c025130..ae873e2 100644
234 --- a/tests/fullspeed.c
235 +++ b/tests/fullspeed.c
236 @@ -24,6 +24,7 @@
237  #include <sys/time.h>
238  #include <sys/types.h>
239  #include <signal.h>
240 +#include <stdint.h>
241  #include <unistd.h>
242  #include <stdint.h>
243  
244 diff --git a/tests/hmac.c b/tests/hmac.c
245 index 3b248f3..8d6492e 100644
246 --- a/tests/hmac.c
247 +++ b/tests/hmac.c
248 @@ -69,7 +69,7 @@ test_crypto(int cfd)
249  
250         cryp.ses = sess.ses;
251         cryp.len = sizeof("what do ya want for nothing?")-1;
252 -       cryp.src = (uint8_t*)"what do ya want for nothing?";
253 +       cryp.src = (uint8_t *)"what do ya want for nothing?";
254         cryp.mac = mac;
255         cryp.op = COP_ENCRYPT;
256         if (ioctl(cfd, CIOCCRYPT, &cryp)) {
257 @@ -92,7 +92,7 @@ test_crypto(int cfd)
258         memset(mac, 0, sizeof(mac));
259  
260         sess.cipher = 0;
261 -       sess.mackey = (uint8_t*)"Jefe";
262 +       sess.mackey = (uint8_t *)"Jefe";
263         sess.mackeylen = 4;
264         sess.mac = CRYPTO_MD5_HMAC;
265         if (ioctl(cfd, CIOCGSESSION, &sess)) {
266 @@ -113,7 +113,7 @@ test_crypto(int cfd)
267  
268         cryp.ses = sess.ses;
269         cryp.len = sizeof("what do ya want for nothing?")-1;
270 -       cryp.src = (uint8_t*)"what do ya want for nothing?";
271 +       cryp.src = (uint8_t *)"what do ya want for nothing?";
272         cryp.mac = mac;
273         cryp.op = COP_ENCRYPT;
274         if (ioctl(cfd, CIOCCRYPT, &cryp)) {
275 @@ -138,7 +138,7 @@ test_crypto(int cfd)
276         sess.keylen = KEY_SIZE;
277         sess.key = data.key;
278         sess.mackeylen = 16;
279 -       sess.mackey = (uint8_t*)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b";
280 +       sess.mackey = (uint8_t *)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b";
281         if (ioctl(cfd, CIOCGSESSION, &sess)) {
282                 perror("ioctl(CIOCGSESSION)");
283                 return 1;
284 @@ -244,7 +244,7 @@ test_extras(int cfd)
285  
286         cryp.ses = sess.ses;
287         cryp.len = sizeof("what do")-1;
288 -       cryp.src = (uint8_t*)"what do";
289 +       cryp.src = (uint8_t *)"what do";
290         cryp.mac = mac;
291         cryp.op = COP_ENCRYPT;
292         cryp.flags = COP_FLAG_UPDATE;
293 @@ -255,7 +255,7 @@ test_extras(int cfd)
294  
295         cryp.ses = sess.ses;
296         cryp.len = sizeof(" ya want for nothing?")-1;
297 -       cryp.src = (uint8_t*)" ya want for nothing?";
298 +       cryp.src = (uint8_t *)" ya want for nothing?";
299         cryp.mac = mac;
300         cryp.op = COP_ENCRYPT;
301         cryp.flags = COP_FLAG_FINAL;
302 -- 
303 2.10.2
304