<div dir="ltr"><div class="gmail_default" style="font-size:small">I checked the evp.h file in the path <span style="font-size:12.8px">/usr/</span><wbr style="font-size:12.8px"><span style="font-size:12.8px">local/include and indeed it's not contain any gcm functions.</span></div><div class="gmail_default" style="font-size:small">I installed openssl via yum install openssl-devel in the past.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 3 May 2017 at 17:32, Matt Caswell <span dir="ltr"><<a href="mailto:matt@openssl.org" target="_blank">matt@openssl.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
<br>
On 03/05/17 15:19, Lior Koskas wrote:<br>
> Thank you for your answer.<br>
><br>
> I made all the changes and the code isn't compiling.<br>
><br>
> I'm using cmake in order to build the code.<br>
><br>
> my CMakeLists.txt contains this line in order to include openssl headers:<br>
><br>
> INCLUDE_DIRECTORIES(/usr/<wbr>include/openssl/ /usr/local/include/openssl/)<br>
<br>
</span>Where did you install OpenSSL? By default OpenSSL 1.1.0 will install to<br>
/usr/local, and the headers will be in /usr/local/include. The final<br>
"openssl" directory name in the path to the individual header files<br>
should not be included in the include directory path.<br>
<br>
My guess is that you are picking up the system openssl headers rather<br>
than the ones from your 1.1.0 installation.<br>
<br>
Most likely this needs to be:<br>
<br>
INCLUDE_DIRECTORIES(/usr/<wbr>local/include)<br>
<br>
But it does depend on options that you gave to config when you compiled<br>
OpenSSL (also I don't use cmake so I could be wrong).<br>
<span class=""><br>
<br>
><br>
> The constructor of my code is :<br>
><br>
> HashEncrypt::HashEncrypt(const unsigned char *key, const unsigned char<br>
> *iv, size_t ivSizeBytes)<br>
> {<br>
>     // copy the 128-bit key<br>
>     memcpy(_key, key, 16);<br>
><br>
>     //copy the iv:<br>
>     EVP_CIPHER_CTX *_ctx;<br>
>     _iv = new unsigned char[ivSizeBytes];<br>
>     memcpy(_iv, iv, ivSizeBytes);<br>
><br>
>     //EVP_CIPHER_CTX_init(&_ctx);<br>
>     _ctx = EVP_CIPHER_CTX_new();<br>
><br>
>     EVP_EncryptInit_ex(_ctx, EVP_aes_128_gcm(), NULL, NULL, NULL);<br>
><br>
>     EVP_CIPHER_CTX_ctrl(_ctx, EVP_CTRL_GCM_SET_IVLEN, ivSizeBytes, NULL);<br>
><br>
>     EVP_EncryptInit_ex(_ctx, NULL, NULL, _key, _iv);<br>
<br>
</span>You need a call to EVP_CIPHER_CTX_free(_ctx) at the end too...plus check<br>
the return values from these function calls for errors.<br>
<span class="HOEnZb"><font color="#888888"><br>
Matt<br>
</font></span><span class="im HOEnZb"><br>
><br>
> }<br>
><br>
> What I'm missing?<br>
><br>
><br>
><br>
><br>
> On 3 May 2017 at 12:57, Matt Caswell <<a href="mailto:matt@openssl.org">matt@openssl.org</a><br>
</span><div class="HOEnZb"><div class="h5">> <mailto:<a href="mailto:matt@openssl.org">matt@openssl.org</a>>> wrote:<br>
><br>
><br>
><br>
>     On 03/05/17 10:33, Lior Koskas wrote:<br>
>     >  I viewed the file and the definition exists.<br>
>     > I also checked that I'm picking the correct version.<br>
>     ><br>
>     > My problem is this line : EVP_EncryptInit_ex(&_ctx, EVP_aes_128_gcm(),<br>
>     > NULL, NULL, NULL);<br>
>     ><br>
>     > I also tried to change the code to this two lines :<br>
>     > EVP_CIPHER *EVP evp_gcm = EVP_aes_128_gcm();<br>
><br>
>     You have one too many "EVP"'s in there. It should be:<br>
><br>
>     const EVP_CIPHER *evp_gcm = EVP_aes_128_gcm();<br>
><br>
>     Although, that really shouldn't be necessary and your original version<br>
>     looks ok. What doesn't look quite right is the "&_ctx" bit. In 1.1.0 an<br>
>     EVP_CIPHER_CTX is an opaque type. You cannot allocate concrete instances<br>
>     of it directly.<br>
><br>
>     Where previously you might have had:<br>
><br>
>     EVP_CIPHER_CTX _ctx;<br>
><br>
>     EVP_CIPHER_CTX_init(&_ctx);<br>
>     EVP_EncryptInit_ex(&_ctx, EVP_aes_128_gcm(), NULL, NULL, NULL);<br>
><br>
><br>
>     You now need to do:<br>
><br>
>     EVP_CIPHER_CTX *_ctx;<br>
><br>
>     _ctx = EVP_CIPHER_CTX_new();<br>
>     EVP_EncryptInit_ex(_ctx, EVP_aes_128_gcm(), NULL, NULL, NULL);<br>
><br>
>     ...<br>
>     EVP_CIPHER_CTX_free(_ctx);<br>
><br>
><br>
>     I have omitted error checking code for brevity.<br>
><br>
>     Matt<br>
><br>
><br>
>     > EVP_EncryptInit_ex(&_ctx, evp_gcm, NULL, NULL, NULL);<br>
>     ><br>
>     > After the change I got this error : expected initializer before ‘evp_gcm’<br>
>     ><br>
>     > What am I doing wrong?<br>
>     ><br>
>     > On 3 May 2017 at 12:07, Matt Caswell <<a href="mailto:matt@openssl.org">matt@openssl.org</a> <mailto:<a href="mailto:matt@openssl.org">matt@openssl.org</a>><br>
</div></div><div class="HOEnZb"><div class="h5">>     > <mailto:<a href="mailto:matt@openssl.org">matt@openssl.org</a> <mailto:<a href="mailto:matt@openssl.org">matt@openssl.org</a>>>> wrote:<br>
>     ><br>
>     ><br>
>     ><br>
>     >     On 03/05/17 09:43, Lior Koskas wrote:<br>
>     >     > Hi,<br>
>     >     ><br>
>     >     > I'm using EVP_aes_128_gcm and have problem with compiling it<br>
>     with<br>
>     >     > OpenSSL 1.1.0 (earlier versions are compiling).<br>
>     >     > Although I included <openssl/evp.h> I got this error : error:<br>
>     >     > ‘EVP_aes_128_gcm’ was not declared in this scope.<br>
>     >     ><br>
>     >     > I'm using CentOS 7.3.<br>
>     >     ><br>
>     >     > Which file I need to include in order to compile<br>
>     EVP_aes_128_gcm ?<br>
>     ><br>
>     >     It's still declared in evp.h:<br>
>     ><br>
>     >     const EVP_CIPHER *EVP_aes_128_gcm(void);<br>
>     ><br>
>     >     Perhaps you are not picking up the version of evp.h that you think<br>
>     >     you are?<br>
>     ><br>
>     >     Matt<br>
>     ><br>
>     >     --<br>
>     >     openssl-users mailing list<br>
>     >     To unsubscribe:<br>
>     >     <a href="https://mta.openssl.org/mailman/listinfo/openssl-users" rel="noreferrer" target="_blank">https://mta.openssl.org/<wbr>mailman/listinfo/openssl-users</a><br>
>     <<a href="https://mta.openssl.org/mailman/listinfo/openssl-users" rel="noreferrer" target="_blank">https://mta.openssl.org/<wbr>mailman/listinfo/openssl-users</a><wbr>><br>
>     >     <<a href="https://mta.openssl.org/mailman/listinfo/openssl-users" rel="noreferrer" target="_blank">https://mta.openssl.org/<wbr>mailman/listinfo/openssl-users</a><br>
>     <<a href="https://mta.openssl.org/mailman/listinfo/openssl-users" rel="noreferrer" target="_blank">https://mta.openssl.org/<wbr>mailman/listinfo/openssl-users</a><wbr>>><br>
>     ><br>
>     ><br>
>     ><br>
>     ><br>
>     > --<br>
>     > Lior           Koskas<br>
>     > Software Engineer<br>
>     ><br>
>     ><br>
>     --<br>
>     openssl-users mailing list<br>
>     To unsubscribe:<br>
>     <a href="https://mta.openssl.org/mailman/listinfo/openssl-users" rel="noreferrer" target="_blank">https://mta.openssl.org/<wbr>mailman/listinfo/openssl-users</a><br>
>     <<a href="https://mta.openssl.org/mailman/listinfo/openssl-users" rel="noreferrer" target="_blank">https://mta.openssl.org/<wbr>mailman/listinfo/openssl-users</a><wbr>><br>
><br>
><br>
><br>
><br>
> --<br>
> Lior           Koskas<br>
> Software Engineer<br>
><br>
><br>
--<br>
openssl-users mailing list<br>
To unsubscribe: <a href="https://mta.openssl.org/mailman/listinfo/openssl-users" rel="noreferrer" target="_blank">https://mta.openssl.org/<wbr>mailman/listinfo/openssl-users</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Lior           Koskas</div><div>Software Engineer</div></div></div></div></div></div>
</div>