Quantcast

EVP_CIPHER_CTX array not compiling

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

EVP_CIPHER_CTX array not compiling

Lior Koskas
Hi,

I have a problem with converting my C++ library into OpenSSL v1.1.0.

I'm using CentOS 7 and OpenSSL v1.1.0.
When I'm trying to use EVP_CIPHER_CTX as an array, my code does not compile.
I understand that this is caused by making the structures opaque.

The problem is this line

OTEXT_AES_KEY_INIT(ctx + i, pBufIdx);
The operation ctx+i is not compiling. The error I'm receiving is :

invalid use of incomplete type struct evp_cipher_ctx_st.

static void InitAESKey(AES_KEY_CTX* ctx, BYTE* keybytes, int numkeys)
        {
                BYTE* pBufIdx = keybytes;
                for (int i = 0; i < numkeys; i++)
                {
                        OTEXT_AES_KEY_INIT(ctx + i, pBufIdx);
                        pBufIdx += AES_KEY_BYTES;
                }
        }
While OTEXT_AES_KEY_INIT is macro defined like this:

#define AES_KEY_CTX EVP_CIPHER_CTX
#define OTEXT_AES_KEY_INIT(ctx, buf) { \
        EVP_CIPHER_CTX_init(ctx); \
        EVP_EncryptInit_ex(ctx, EVP_aes_128_ecb(), NULL, buf, ZERO_IV); \
        }


​What I'm doing wrong?


--
Lior           Koskas
Software Engineer

--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: EVP_CIPHER_CTX array not compiling

OpenSSL - User mailing list
>#define OTEXT_AES_KEY_INIT(ctx, buf) { \
>        EVP_CIPHER_CTX_init(ctx); \
>        EVP_EncryptInit_ex(ctx, EVP_aes_128_ecb(), NULL, buf, ZERO_IV); \
>        }

Most of the datatypes are now opaque.  This means you can't have an EVP_CIPHER_CTX object, but instead a pointer to it.  Don't call the init function, call the new function.  And then that has rippling changes in your code.
--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: EVP_CIPHER_CTX array not compiling

Jeffrey Walton-3
On Sun, Apr 23, 2017 at 9:36 AM, Salz, Rich via openssl-users
<[hidden email]> wrote:
>>#define OTEXT_AES_KEY_INIT(ctx, buf) { \
>>        EVP_CIPHER_CTX_init(ctx); \
>>        EVP_EncryptInit_ex(ctx, EVP_aes_128_ecb(), NULL, buf, ZERO_IV); \
>>        }
>
> Most of the datatypes are now opaque.  This means you can't have an EVP_CIPHER_CTX object, but instead a pointer to it.  Don't call the init function, call the new function.  And then that has rippling changes in your code.

Related, see https://wiki.openssl.org/index.php/OpenSSL_1.1.0_Changes.
The page name is kind of boring, but it discusses how to convert from
1.0.2 to 1.1.0. In addition, it provides a small compatibility layer
so a lot of code "just works" for both 1.0.2 and 1.1.0.

We lifted it from Kurt's patch to OpenSSH. OpenSSH is stuck at 1.0.2,
and Kurt provided them with a migration path.

Jeff
--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
Loading...