lib/libdmsg: Fix compile warnings on Linux distros
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Tue, 3 Sep 2019 07:58:42 +0000 (16:58 +0900)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Tue, 3 Sep 2019 08:02:51 +0000 (17:02 +0900)
--
crypto.c:210: warning: pointer targets in passing argument 5 of 'EVP_EncryptInit_ex' differ in signedness
/usr/include/openssl/evp.h:586: note: expected 'const unsigned char *' but argument is of type 'char *'
crypto.c:216: warning: pointer targets in passing argument 2 of 'EVP_EncryptUpdate' differ in signedness
/usr/include/openssl/evp.h:588: note: expected 'unsigned char *' but argument is of type 'char *'
crypto.c:216: warning: pointer targets in passing argument 4 of 'EVP_EncryptUpdate' differ in signedness
/usr/include/openssl/evp.h:588: note: expected 'const unsigned char *' but argument is of type 'char *'
crypto.c:221: warning: pointer targets in passing argument 2 of 'EVP_EncryptFinal' differ in signedness
/usr/include/openssl/evp.h:591: note: expected 'unsigned char *' but argument is of type 'char *'
...

lib/libdmsg/crypto.c

index e009486..24d1f08 100644 (file)
@@ -118,10 +118,10 @@ dmsg_crypto_gcm_init(dmsg_ioq_t *ioq, char *key, int klen,
 
        if (enc)
                ok = EVP_EncryptInit_ex(&ioq->ctx, EVP_aes_256_gcm(), NULL,
-                                       key, NULL);
+                                       (unsigned char*)key, NULL);
        else
                ok = EVP_DecryptInit_ex(&ioq->ctx, EVP_aes_256_gcm(), NULL,
-                                       key, NULL);
+                                       (unsigned char*)key, NULL);
        if (!ok)
                goto fail;
 
@@ -203,17 +203,19 @@ dmsg_crypto_gcm_encrypt_chunk(dmsg_ioq_t *ioq, char *ct, char *pt,
        *out_size = 0;
 
        /* Re-initialize with new IV (but without redoing the key schedule) */
-       ok = EVP_EncryptInit_ex(&ioq->ctx, NULL, NULL, NULL, ioq->iv);
+       ok = EVP_EncryptInit_ex(&ioq->ctx, NULL, NULL, NULL,
+               (unsigned char*)ioq->iv);
        if (!ok)
                goto fail;
 
        u_len = 0;      /* safety */
-       ok = EVP_EncryptUpdate(&ioq->ctx, ct, &u_len, pt, in_size);
+       ok = EVP_EncryptUpdate(&ioq->ctx, (unsigned char*)ct, &u_len,
+               (unsigned char*)pt, in_size);
        if (!ok)
                goto fail;
 
        f_len = 0;      /* safety */
-       ok = EVP_EncryptFinal_ex(&ioq->ctx, ct + u_len, &f_len);
+       ok = EVP_EncryptFinal_ex(&ioq->ctx, (unsigned char*)ct + u_len, &f_len);
        if (!ok)
                goto fail;
 
@@ -254,7 +256,8 @@ dmsg_crypto_gcm_decrypt_chunk(dmsg_ioq_t *ioq, char *ct, char *pt,
        *consume_size = 0;
 
        /* Re-initialize with new IV (but without redoing the key schedule) */
-       ok = EVP_DecryptInit_ex(&ioq->ctx, NULL, NULL, NULL, ioq->iv);
+       ok = EVP_DecryptInit_ex(&ioq->ctx, NULL, NULL, NULL,
+               (unsigned char*)ioq->iv);
        if (!ok) {
                ioq->error = DMSG_IOQ_ERROR_ALGO;
                goto fail_out;
@@ -268,11 +271,12 @@ dmsg_crypto_gcm_decrypt_chunk(dmsg_ioq_t *ioq, char *ct, char *pt,
                goto fail_out;
        }
 
-       ok = EVP_DecryptUpdate(&ioq->ctx, pt, &u_len, ct, out_size);
+       ok = EVP_DecryptUpdate(&ioq->ctx, (unsigned char*)pt, &u_len,
+               (unsigned char*)ct, out_size);
        if (!ok)
                goto fail;
 
-       ok = EVP_DecryptFinal_ex(&ioq->ctx, pt + u_len, &f_len);
+       ok = EVP_DecryptFinal_ex(&ioq->ctx, (unsigned char*)pt + u_len, &f_len);
        if (!ok)
                goto fail;