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
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.
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.
15 Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com>
17 tests/async_hmac.c | 12 ++++++------
18 tests/cipher-aead.c | 10 +++++-----
19 tests/cipher-gcm.c | 40 ++++++++++++++++++++--------------------
21 tests/fullspeed.c | 1 +
22 tests/hmac.c | 12 ++++++------
23 6 files changed, 38 insertions(+), 38 deletions(-)
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)
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?";
36 cryp.op = COP_ENCRYPT;
38 @@ -88,7 +88,7 @@ test_crypto(int cfd)
39 memset(mac, 0, sizeof(mac));
42 - sess.mackey = (uint8_t*)"Jefe";
43 + sess.mackey = (uint8_t *)"Jefe";
45 sess.mac = CRYPTO_MD5_HMAC;
46 if (ioctl(cfd, CIOCGSESSION, &sess)) {
47 @@ -98,7 +98,7 @@ test_crypto(int cfd)
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?";
54 cryp.op = COP_ENCRYPT;
56 @@ -127,7 +127,7 @@ test_crypto(int cfd)
57 sess.keylen = KEY_SIZE;
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)");
65 @@ -206,7 +206,7 @@ test_extras(int cfd)
68 cryp.len = sizeof("what do")-1;
69 - cryp.src = (uint8_t*)"what do";
70 + cryp.src = (uint8_t *)"what do";
72 cryp.op = COP_ENCRYPT;
73 cryp.flags = COP_FLAG_UPDATE;
74 @@ -216,7 +216,7 @@ test_extras(int cfd)
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?";
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)
89 sess.mac = CRYPTO_SHA1_HMAC;
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";
94 if (ioctl(cfd, CIOCGSESSION, &sess)) {
95 perror("ioctl(CIOCGSESSION)");
96 @@ -271,7 +271,7 @@ test_encrypt_decrypt(int cfd)
98 sess.mac = CRYPTO_SHA1_HMAC;
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";
103 if (ioctl(cfd, CIOCGSESSION, &sess)) {
104 perror("ioctl(CIOCGSESSION)");
105 @@ -329,7 +329,7 @@ test_encrypt_decrypt(int cfd)
107 sess.mac = CRYPTO_SHA1_HMAC;
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";
112 if (ioctl(cfd, CIOCGSESSION, &sess)) {
113 perror("ioctl(CIOCGSESSION)");
114 @@ -420,7 +420,7 @@ test_encrypt_decrypt_error(int cfd, int err)
116 sess.mac = CRYPTO_SHA1_HMAC;
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";
121 if (ioctl(cfd, CIOCGSESSION, &sess)) {
122 perror("ioctl(CIOCGSESSION)");
123 @@ -477,7 +477,7 @@ test_encrypt_decrypt_error(int cfd, int err)
125 sess.mac = CRYPTO_SHA1_HMAC;
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";
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 {
138 struct aes_gcm_vectors_st aes_gcm_vectors[] = {
142 "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
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",
154 + .iv = (uint8_t *)"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
156 "\xab\x6e\x47\xd4\x2c\xec\x13\xbd\xf5\x3a\x67\xb2\x12\x57\xbd\xdf"
161 "\xfe\xff\xe9\x92\x86\x65\x73\x1c\x6d\x6a\x8f\x94\x67\x30\x83\x08",
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"
179 "\xfe\xff\xe9\x92\x86\x65\x73\x1c\x6d\x6a\x8f\x94\x67\x30\x83\x08",
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",
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",
193 + .iv = (uint8_t *)"\xca\xfe\xba\xbe\xfa\xce\xdb\xad\xde\xca\xf8\x88",
195 "\x5b\xc9\x4f\xbc\x32\x21\xa5\xdb\x94\xfa\xe9\x5a\xe7\x12\x1a\x47"
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);
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);
207 memset(plaintext, 0x15, DATA_SIZE);
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);
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);
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
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
237 #include <sys/time.h>
238 #include <sys/types.h>
244 diff --git a/tests/hmac.c b/tests/hmac.c
245 index 3b248f3..8d6492e 100644
248 @@ -69,7 +69,7 @@ test_crypto(int cfd)
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?";
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));
261 - sess.mackey = (uint8_t*)"Jefe";
262 + sess.mackey = (uint8_t *)"Jefe";
264 sess.mac = CRYPTO_MD5_HMAC;
265 if (ioctl(cfd, CIOCGSESSION, &sess)) {
266 @@ -113,7 +113,7 @@ test_crypto(int cfd)
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?";
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;
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)");
284 @@ -244,7 +244,7 @@ test_extras(int cfd)
287 cryp.len = sizeof("what do")-1;
288 - cryp.src = (uint8_t*)"what do";
289 + cryp.src = (uint8_t *)"what do";
291 cryp.op = COP_ENCRYPT;
292 cryp.flags = COP_FLAG_UPDATE;
293 @@ -255,7 +255,7 @@ test_extras(int cfd)
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?";
300 cryp.op = COP_ENCRYPT;
301 cryp.flags = COP_FLAG_FINAL;