Use uint8_t type for all variables with this problem and avoid casting from char in assignments. With uint8_t we also convey the information that we're using small numbers rather than strings.
Although cryptodev.h uses the synonym type __u8, we use uint8_t for consistency with other files in tests directory and also because it is a standard POSIX type. Signed-off-by: Cristian Stoica <cristian.sto...@nxp.com> --- tests/async_cipher.c | 28 +++++++++++----------- tests/async_hmac.c | 12 +++++----- tests/cipher-aead-srtp.c | 38 ++++++++++++++--------------- tests/cipher-aead.c | 46 +++++++++++++++++------------------ tests/cipher-gcm.c | 62 ++++++++++++++++++++++++------------------------ tests/cipher.c | 28 +++++++++++----------- tests/cipher_comp.c | 12 +++++----- tests/fullspeed.c | 3 ++- tests/hash_comp.c | 8 +++---- tests/hmac.c | 12 +++++----- 10 files changed, 124 insertions(+), 125 deletions(-) diff --git a/tests/async_cipher.c b/tests/async_cipher.c index 273a471..7a184e5 100644 --- a/tests/async_cipher.c +++ b/tests/async_cipher.c @@ -9,7 +9,7 @@ #include <string.h> #include <unistd.h> #include <fcntl.h> - +#include <stdint.h> #include <sys/ioctl.h> #include <crypto/cryptodev.h> @@ -27,10 +27,10 @@ static int debug = 0; static int test_crypto(int cfd) { - char plaintext_raw[DATA_SIZE + 63], *plaintext; - char ciphertext_raw[DATA_SIZE + 63], *ciphertext; - char iv[BLOCK_SIZE]; - char key[KEY_SIZE]; + uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; + uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; + uint8_t iv[BLOCK_SIZE]; + uint8_t key[KEY_SIZE]; struct session_op sess; #ifdef CIOCGSESSINFO @@ -128,15 +128,15 @@ test_crypto(int cfd) static int test_aes(int cfd) { - char plaintext1_raw[BLOCK_SIZE + 63], *plaintext1; - char ciphertext1[BLOCK_SIZE] = { 0xdf, 0x55, 0x6a, 0x33, 0x43, 0x8d, 0xb8, 0x7b, 0xc4, 0x1b, 0x17, 0x52, 0xc5, 0x5e, 0x5e, 0x49 }; - char iv1[BLOCK_SIZE]; - char key1[KEY_SIZE] = { 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - char plaintext2_data[BLOCK_SIZE] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00 }; - char plaintext2_raw[BLOCK_SIZE + 63], *plaintext2; - char ciphertext2[BLOCK_SIZE] = { 0xb7, 0x97, 0x2b, 0x39, 0x41, 0xc4, 0x4b, 0x90, 0xaf, 0xa7, 0xb2, 0x64, 0xbf, 0xba, 0x73, 0x87 }; - char iv2[BLOCK_SIZE]; - char key2[KEY_SIZE]; + uint8_t plaintext1_raw[BLOCK_SIZE + 63], *plaintext1; + uint8_t ciphertext1[BLOCK_SIZE] = { 0xdf, 0x55, 0x6a, 0x33, 0x43, 0x8d, 0xb8, 0x7b, 0xc4, 0x1b, 0x17, 0x52, 0xc5, 0x5e, 0x5e, 0x49 }; + uint8_t iv1[BLOCK_SIZE]; + uint8_t key1[KEY_SIZE] = { 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + uint8_t plaintext2_data[BLOCK_SIZE] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00 }; + uint8_t plaintext2_raw[BLOCK_SIZE + 63], *plaintext2; + uint8_t ciphertext2[BLOCK_SIZE] = { 0xb7, 0x97, 0x2b, 0x39, 0x41, 0xc4, 0x4b, 0x90, 0xaf, 0xa7, 0xb2, 0x64, 0xbf, 0xba, 0x73, 0x87 }; + uint8_t iv2[BLOCK_SIZE]; + uint8_t key2[KEY_SIZE]; struct session_op sess1, sess2; #ifdef CIOCGSESSINFO diff --git a/tests/async_hmac.c b/tests/async_hmac.c index 57ec108..014b8ed 100644 --- a/tests/async_hmac.c +++ b/tests/async_hmac.c @@ -61,7 +61,7 @@ test_crypto(int cfd) cryp.ses = sess.ses; cryp.len = sizeof("what do ya want for nothing?")-1; - cryp.src = "what do ya want for nothing?"; + cryp.src = (uint8_t *)"what do ya want for nothing?"; cryp.mac = mac; cryp.op = COP_ENCRYPT; @@ -88,7 +88,7 @@ test_crypto(int cfd) memset(mac, 0, sizeof(mac)); sess.cipher = 0; - sess.mackey = (uint8_t*)"Jefe"; + sess.mackey = (uint8_t *)"Jefe"; sess.mackeylen = 4; sess.mac = CRYPTO_MD5_HMAC; if (ioctl(cfd, CIOCGSESSION, &sess)) { @@ -98,7 +98,7 @@ test_crypto(int cfd) cryp.ses = sess.ses; cryp.len = sizeof("what do ya want for nothing?")-1; - cryp.src = "what do ya want for nothing?"; + cryp.src = (uint8_t *)"what do ya want for nothing?"; cryp.mac = mac; cryp.op = COP_ENCRYPT; @@ -127,7 +127,7 @@ test_crypto(int cfd) sess.keylen = KEY_SIZE; sess.key = data.key; sess.mackeylen = 16; - sess.mackey = (uint8_t*)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; + sess.mackey = (uint8_t *)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; if (ioctl(cfd, CIOCGSESSION, &sess)) { perror("ioctl(CIOCGSESSION)"); return 1; @@ -206,7 +206,7 @@ test_extras(int cfd) cryp.ses = sess.ses; cryp.len = sizeof("what do")-1; - cryp.src = "what do"; + cryp.src = (uint8_t *)"what do"; cryp.mac = mac; cryp.op = COP_ENCRYPT; cryp.flags = COP_FLAG_UPDATE; @@ -216,7 +216,7 @@ test_extras(int cfd) cryp.ses = sess.ses; cryp.len = sizeof(" ya want for nothing?")-1; - cryp.src = " ya want for nothing?"; + cryp.src = (uint8_t *)" ya want for nothing?"; cryp.mac = mac; cryp.op = COP_ENCRYPT; cryp.flags = COP_FLAG_FINAL; diff --git a/tests/cipher-aead-srtp.c b/tests/cipher-aead-srtp.c index 75fb825..578d2f7 100644 --- a/tests/cipher-aead-srtp.c +++ b/tests/cipher-aead-srtp.c @@ -78,13 +78,13 @@ int i; static int test_crypto(int cfd) { - char plaintext_raw[DATA_SIZE + 63], *plaintext; - char ciphertext_raw[DATA_SIZE + 63], *ciphertext; - char iv[BLOCK_SIZE]; - char key[KEY_SIZE]; - unsigned char sha1mac[20]; - unsigned char tag[20]; - unsigned char mackey[] = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; + uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; + uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; + uint8_t iv[BLOCK_SIZE]; + uint8_t key[KEY_SIZE]; + uint8_t sha1mac[20]; + uint8_t tag[20]; + uint8_t mackey[] = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; int mackey_len = 16; struct session_op sess; @@ -226,12 +226,12 @@ test_crypto(int cfd) static int test_encrypt_decrypt(int cfd) { - char plaintext_raw[DATA_SIZE + 63], *plaintext; - char ciphertext_raw[DATA_SIZE + 63], *ciphertext; - char iv[BLOCK_SIZE]; - char key[KEY_SIZE]; - unsigned char tag[20]; - unsigned char mackey[] = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; + uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; + uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; + uint8_t iv[BLOCK_SIZE]; + uint8_t key[KEY_SIZE]; + uint8_t tag[20]; + uint8_t mackey[] = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; int mackey_len = 16; struct session_op sess; @@ -368,12 +368,12 @@ test_encrypt_decrypt(int cfd) static int test_encrypt_decrypt_error(int cfd, int err) { - char plaintext_raw[DATA_SIZE + 63], *plaintext; - char ciphertext_raw[DATA_SIZE + 63], *ciphertext; - char iv[BLOCK_SIZE]; - char key[KEY_SIZE]; - unsigned char tag[20]; - unsigned char mackey[] = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; + uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; + uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; + uint8_t iv[BLOCK_SIZE]; + uint8_t key[KEY_SIZE]; + uint8_t tag[20]; + uint8_t mackey[] = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; int mackey_len = 16; struct session_op sess; diff --git a/tests/cipher-aead.c b/tests/cipher-aead.c index 837b521..305b720 100644 --- a/tests/cipher-aead.c +++ b/tests/cipher-aead.c @@ -90,12 +90,12 @@ int i; static int test_crypto(int cfd) { - char plaintext_raw[DATA_SIZE + 63], *plaintext; - char ciphertext_raw[DATA_SIZE + 63], *ciphertext; - char iv[BLOCK_SIZE]; - char key[KEY_SIZE]; - char auth[AUTH_SIZE]; - unsigned char sha1mac[20]; + uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; + uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; + uint8_t iv[BLOCK_SIZE]; + uint8_t key[KEY_SIZE]; + uint8_t auth[AUTH_SIZE]; + uint8_t sha1mac[20]; int pad, i; struct session_op sess; @@ -118,7 +118,7 @@ test_crypto(int cfd) sess.mac = CRYPTO_SHA1_HMAC; sess.mackeylen = 16; - sess.mackey = (uint8_t*)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; + sess.mackey = (uint8_t *)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; if (ioctl(cfd, CIOCGSESSION, &sess)) { perror("ioctl(CIOCGSESSION)"); @@ -243,12 +243,12 @@ test_crypto(int cfd) static int test_encrypt_decrypt(int cfd) { - char plaintext_raw[DATA_SIZE + 63], *plaintext; - char ciphertext_raw[DATA_SIZE + 63], *ciphertext; - char iv[BLOCK_SIZE]; - char key[KEY_SIZE]; - char auth[AUTH_SIZE]; - unsigned char sha1mac[20]; + uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; + uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; + uint8_t iv[BLOCK_SIZE]; + uint8_t key[KEY_SIZE]; + uint8_t auth[AUTH_SIZE]; + uint8_t sha1mac[20]; int enc_len; struct session_op sess; @@ -271,7 +271,7 @@ test_encrypt_decrypt(int cfd) sess.mac = CRYPTO_SHA1_HMAC; sess.mackeylen = 16; - sess.mackey = (uint8_t*)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; + sess.mackey = (uint8_t *)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; if (ioctl(cfd, CIOCGSESSION, &sess)) { perror("ioctl(CIOCGSESSION)"); @@ -329,7 +329,7 @@ test_encrypt_decrypt(int cfd) sess.key = key; sess.mac = CRYPTO_SHA1_HMAC; sess.mackeylen = 16; - sess.mackey = (uint8_t*)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; + sess.mackey = (uint8_t *)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; if (ioctl(cfd, CIOCGSESSION, &sess)) { perror("ioctl(CIOCGSESSION)"); @@ -392,12 +392,12 @@ test_encrypt_decrypt(int cfd) static int test_encrypt_decrypt_error(int cfd, int err) { - char plaintext_raw[DATA_SIZE + 63], *plaintext; - char ciphertext_raw[DATA_SIZE + 63], *ciphertext; - char iv[BLOCK_SIZE]; - char key[KEY_SIZE]; - char auth[AUTH_SIZE]; - unsigned char sha1mac[20]; + uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; + uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; + uint8_t iv[BLOCK_SIZE]; + uint8_t key[KEY_SIZE]; + uint8_t auth[AUTH_SIZE]; + uint8_t sha1mac[20]; int enc_len; struct session_op sess; @@ -420,7 +420,7 @@ test_encrypt_decrypt_error(int cfd, int err) sess.mac = CRYPTO_SHA1_HMAC; sess.mackeylen = 16; - sess.mackey = (uint8_t*)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; + sess.mackey = (uint8_t *)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; if (ioctl(cfd, CIOCGSESSION, &sess)) { perror("ioctl(CIOCGSESSION)"); @@ -477,7 +477,7 @@ test_encrypt_decrypt_error(int cfd, int err) sess.key = key; sess.mac = CRYPTO_SHA1_HMAC; sess.mackeylen = 16; - sess.mackey = (uint8_t*)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; + sess.mackey = (uint8_t *)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; if (ioctl(cfd, CIOCGSESSION, &sess)) { perror("ioctl(CIOCGSESSION)"); diff --git a/tests/cipher-gcm.c b/tests/cipher-gcm.c index e444afa..36c827a 100644 --- a/tests/cipher-gcm.c +++ b/tests/cipher-gcm.c @@ -46,45 +46,45 @@ struct aes_gcm_vectors_st { struct aes_gcm_vectors_st aes_gcm_vectors[] = { { - .key = + .key = (uint8_t *) "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", .auth = NULL, .auth_size = 0, - .plaintext = + .plaintext = (uint8_t *) "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", .plaintext_size = 16, - .ciphertext = + .ciphertext = (uint8_t *) "\x03\x88\xda\xce\x60\xb6\xa3\x92\xf3\x28\xc2\xb9\x71\xb2\xfe\x78", - .iv = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", - .tag = + .iv = (uint8_t *)"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", + .tag = (uint8_t *) "\xab\x6e\x47\xd4\x2c\xec\x13\xbd\xf5\x3a\x67\xb2\x12\x57\xbd\xdf" }, { - .key = + .key = (uint8_t *) "\xfe\xff\xe9\x92\x86\x65\x73\x1c\x6d\x6a\x8f\x94\x67\x30\x83\x08", .auth = NULL, .auth_size = 0, - .plaintext = + .plaintext = (uint8_t *) "\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", .plaintext_size = 64, - .ciphertext = + .ciphertext = (uint8_t *) "\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", - .iv = "\xca\xfe\xba\xbe\xfa\xce\xdb\xad\xde\xca\xf8\x88", - .tag = "\x4d\x5c\x2a\xf3\x27\xcd\x64\xa6\x2c\xf3\x5a\xbd\x2b\xa6\xfa\xb4" + .iv = (uint8_t *)"\xca\xfe\xba\xbe\xfa\xce\xdb\xad\xde\xca\xf8\x88", + .tag = (uint8_t *)"\x4d\x5c\x2a\xf3\x27\xcd\x64\xa6\x2c\xf3\x5a\xbd\x2b\xa6\xfa\xb4" }, { - .key = + .key = (uint8_t *) "\xfe\xff\xe9\x92\x86\x65\x73\x1c\x6d\x6a\x8f\x94\x67\x30\x83\x08", - .auth = + .auth = (uint8_t *) "\xfe\xed\xfa\xce\xde\xad\xbe\xef\xfe\xed\xfa\xce\xde\xad\xbe\xef\xab\xad\xda\xd2", .auth_size = 20, - .plaintext = + .plaintext = (uint8_t *) "\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", .plaintext_size = 60, - .ciphertext = + .ciphertext = (uint8_t *) "\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", - .iv = "\xca\xfe\xba\xbe\xfa\xce\xdb\xad\xde\xca\xf8\x88", - .tag = + .iv = (uint8_t *)"\xca\xfe\xba\xbe\xfa\xce\xdb\xad\xde\xca\xf8\x88", + .tag = (uint8_t *) "\x5b\xc9\x4f\xbc\x32\x21\xa5\xdb\x94\xfa\xe9\x5a\xe7\x12\x1a\x47" } }; @@ -95,7 +95,7 @@ struct aes_gcm_vectors_st aes_gcm_vectors[] = { static int test_crypto(int cfd) { int i; - int8_t tmp[128]; + uint8_t tmp[128]; struct session_op sess; struct crypt_auth_op cao; @@ -192,11 +192,11 @@ static int test_crypto(int cfd) */ static int test_encrypt_decrypt(int cfd) { - char plaintext_raw[DATA_SIZE + 63], *plaintext; - char ciphertext_raw[DATA_SIZE + 63], *ciphertext; - char iv[BLOCK_SIZE]; - char key[KEY_SIZE]; - char auth[AUTH_SIZE]; + uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; + uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; + uint8_t iv[BLOCK_SIZE]; + uint8_t key[KEY_SIZE]; + uint8_t auth[AUTH_SIZE]; int enc_len; struct session_op sess; @@ -233,8 +233,8 @@ static int test_encrypt_decrypt(int cfd) // printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); - plaintext = (char *)buf_align(plaintext_raw, siop.alignmask); - ciphertext = (char *)buf_align(ciphertext_raw, siop.alignmask); + plaintext = (uint8_t *)buf_align(plaintext_raw, siop.alignmask); + ciphertext = (uint8_t *)buf_align(ciphertext_raw, siop.alignmask); memset(plaintext, 0x15, DATA_SIZE); @@ -333,11 +333,11 @@ static int test_encrypt_decrypt(int cfd) static int test_encrypt_decrypt_error(int cfd, int err) { - char plaintext_raw[DATA_SIZE + 63], *plaintext; - char ciphertext_raw[DATA_SIZE + 63], *ciphertext; - char iv[BLOCK_SIZE]; - char key[KEY_SIZE]; - char auth[AUTH_SIZE]; + uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; + uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; + uint8_t iv[BLOCK_SIZE]; + uint8_t key[KEY_SIZE]; + uint8_t auth[AUTH_SIZE]; int enc_len; struct session_op sess; @@ -382,8 +382,8 @@ static int test_encrypt_decrypt_error(int cfd, int err) // printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); - plaintext = (char *)buf_align(plaintext_raw, siop.alignmask); - ciphertext = (char *)buf_align(ciphertext_raw, siop.alignmask); + plaintext = (uint8_t *)buf_align(plaintext_raw, siop.alignmask); + ciphertext = (uint8_t *)buf_align(ciphertext_raw, siop.alignmask); memset(plaintext, 0x15, DATA_SIZE); memcpy(ciphertext, plaintext, DATA_SIZE); diff --git a/tests/cipher.c b/tests/cipher.c index 7248404..fab3de6 100644 --- a/tests/cipher.c +++ b/tests/cipher.c @@ -8,7 +8,7 @@ #include <string.h> #include <unistd.h> #include <fcntl.h> - +#include <stdint.h> #include <sys/ioctl.h> #include <crypto/cryptodev.h> #include "testhelper.h" @@ -22,10 +22,10 @@ static int debug = 0; static int test_crypto(int cfd) { - char plaintext_raw[DATA_SIZE + 63], *plaintext; - char ciphertext_raw[DATA_SIZE + 63], *ciphertext; - char iv[BLOCK_SIZE]; - char key[KEY_SIZE]; + uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; + uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; + uint8_t iv[BLOCK_SIZE]; + uint8_t key[KEY_SIZE]; struct session_op sess; #ifdef CIOCGSESSINFO @@ -144,15 +144,15 @@ test_crypto(int cfd) static int test_aes(int cfd) { - char plaintext1_raw[BLOCK_SIZE + 63], *plaintext1; - char ciphertext1[BLOCK_SIZE] = { 0xdf, 0x55, 0x6a, 0x33, 0x43, 0x8d, 0xb8, 0x7b, 0xc4, 0x1b, 0x17, 0x52, 0xc5, 0x5e, 0x5e, 0x49 }; - char iv1[BLOCK_SIZE]; - char key1[KEY_SIZE] = { 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - char plaintext2_data[BLOCK_SIZE] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00 }; - char plaintext2_raw[BLOCK_SIZE + 63], *plaintext2; - char ciphertext2[BLOCK_SIZE] = { 0xb7, 0x97, 0x2b, 0x39, 0x41, 0xc4, 0x4b, 0x90, 0xaf, 0xa7, 0xb2, 0x64, 0xbf, 0xba, 0x73, 0x87 }; - char iv2[BLOCK_SIZE]; - char key2[KEY_SIZE]; + uint8_t plaintext1_raw[BLOCK_SIZE + 63], *plaintext1; + uint8_t ciphertext1[BLOCK_SIZE] = { 0xdf, 0x55, 0x6a, 0x33, 0x43, 0x8d, 0xb8, 0x7b, 0xc4, 0x1b, 0x17, 0x52, 0xc5, 0x5e, 0x5e, 0x49 }; + uint8_t iv1[BLOCK_SIZE]; + uint8_t key1[KEY_SIZE] = { 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + uint8_t plaintext2_data[BLOCK_SIZE] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00 }; + uint8_t plaintext2_raw[BLOCK_SIZE + 63], *plaintext2; + uint8_t ciphertext2[BLOCK_SIZE] = { 0xb7, 0x97, 0x2b, 0x39, 0x41, 0xc4, 0x4b, 0x90, 0xaf, 0xa7, 0xb2, 0x64, 0xbf, 0xba, 0x73, 0x87 }; + uint8_t iv2[BLOCK_SIZE]; + uint8_t key2[KEY_SIZE]; struct session_op sess; #ifdef CIOCGSESSINFO diff --git a/tests/cipher_comp.c b/tests/cipher_comp.c index d85e5e7..dbf9977 100644 --- a/tests/cipher_comp.c +++ b/tests/cipher_comp.c @@ -24,12 +24,12 @@ static int test_crypto(int cfd, struct session_op *sess, int datalen) { - char *data, *encrypted; - char *encrypted_comp; + uint8_t *data, *encrypted; + uint8_t *encrypted_comp; - char iv_in[BLOCK_SIZE]; - char iv[BLOCK_SIZE]; - char iv_comp[BLOCK_SIZE]; + uint8_t iv_in[BLOCK_SIZE]; + uint8_t iv[BLOCK_SIZE]; + uint8_t iv_comp[BLOCK_SIZE]; struct crypt_op cryp; @@ -90,7 +90,7 @@ main(int argc, char **argv) { int fd; struct session_op sess; - unsigned char key[KEY_SIZE]; + uint8_t key[KEY_SIZE]; int datalen = BLOCK_SIZE; int datalen_end = MAX_DATALEN; int i; diff --git a/tests/fullspeed.c b/tests/fullspeed.c index 611859d..4e97965 100644 --- a/tests/fullspeed.c +++ b/tests/fullspeed.c @@ -24,6 +24,7 @@ #include <sys/time.h> #include <sys/types.h> #include <signal.h> +#include <stdint.h> #include <unistd.h> #include <crypto/cryptodev.h> @@ -74,7 +75,7 @@ static void value2human(int si, double bytes, double time, double* data, double* int encrypt_data(int algo, void* keybuf, int key_size, int fdc, int chunksize) { struct crypt_op cop; - char *buffer, iv[32]; + uint8_t *buffer, iv[32]; static int val = 23; struct timeval start, end; double total = 0; diff --git a/tests/hash_comp.c b/tests/hash_comp.c index 39f30af..73f85ed 100644 --- a/tests/hash_comp.c +++ b/tests/hash_comp.c @@ -30,11 +30,9 @@ static void printhex(unsigned char *buf, int buflen) static int test_crypto(int cfd, struct session_op *sess, int datalen) { - unsigned char *data; - - unsigned char mac[AALG_MAX_RESULT_LEN]; - - unsigned char mac_comp[AALG_MAX_RESULT_LEN]; + uint8_t *data; + uint8_t mac[AALG_MAX_RESULT_LEN]; + uint8_t mac_comp[AALG_MAX_RESULT_LEN]; struct crypt_op cryp; diff --git a/tests/hmac.c b/tests/hmac.c index 2611c78..8d6492e 100644 --- a/tests/hmac.c +++ b/tests/hmac.c @@ -69,7 +69,7 @@ test_crypto(int cfd) cryp.ses = sess.ses; cryp.len = sizeof("what do ya want for nothing?")-1; - cryp.src = "what do ya want for nothing?"; + cryp.src = (uint8_t *)"what do ya want for nothing?"; cryp.mac = mac; cryp.op = COP_ENCRYPT; if (ioctl(cfd, CIOCCRYPT, &cryp)) { @@ -92,7 +92,7 @@ test_crypto(int cfd) memset(mac, 0, sizeof(mac)); sess.cipher = 0; - sess.mackey = (uint8_t*)"Jefe"; + sess.mackey = (uint8_t *)"Jefe"; sess.mackeylen = 4; sess.mac = CRYPTO_MD5_HMAC; if (ioctl(cfd, CIOCGSESSION, &sess)) { @@ -113,7 +113,7 @@ test_crypto(int cfd) cryp.ses = sess.ses; cryp.len = sizeof("what do ya want for nothing?")-1; - cryp.src = "what do ya want for nothing?"; + cryp.src = (uint8_t *)"what do ya want for nothing?"; cryp.mac = mac; cryp.op = COP_ENCRYPT; if (ioctl(cfd, CIOCCRYPT, &cryp)) { @@ -138,7 +138,7 @@ test_crypto(int cfd) sess.keylen = KEY_SIZE; sess.key = data.key; sess.mackeylen = 16; - sess.mackey = (uint8_t*)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; + sess.mackey = (uint8_t *)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; if (ioctl(cfd, CIOCGSESSION, &sess)) { perror("ioctl(CIOCGSESSION)"); return 1; @@ -244,7 +244,7 @@ test_extras(int cfd) cryp.ses = sess.ses; cryp.len = sizeof("what do")-1; - cryp.src = "what do"; + cryp.src = (uint8_t *)"what do"; cryp.mac = mac; cryp.op = COP_ENCRYPT; cryp.flags = COP_FLAG_UPDATE; @@ -255,7 +255,7 @@ test_extras(int cfd) cryp.ses = sess.ses; cryp.len = sizeof(" ya want for nothing?")-1; - cryp.src = " ya want for nothing?"; + cryp.src = (uint8_t *)" ya want for nothing?"; cryp.mac = mac; cryp.op = COP_ENCRYPT; cryp.flags = COP_FLAG_FINAL; -- 2.7.3 _______________________________________________ Cryptodev-linux-devel mailing list Cryptodev-linux-devel@gna.org https://mail.gna.org/listinfo/cryptodev-linux-devel