<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[wolfSSL - Embedded SSL Library — OpenSSL compatibility]]></title>
		<link>https://www.wolfssl.com/forums/topic1899-openssl-compatibility.html</link>
		<atom:link href="https://www.wolfssl.com/forums/feed-rss-topic1899.xml" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in OpenSSL compatibility.]]></description>
		<lastBuildDate>Mon, 05 Sep 2022 22:16:44 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: OpenSSL compatibility]]></title>
			<link>https://www.wolfssl.com/forums/post6734.html#p6734</link>
			<description><![CDATA[<p>Hello kareem,</p><p>Thanks for all the help.</p><p>Since I don&#039;t have the access to the EC_GROUP_get0_generator function I wanted to load the generator point from a fixed structure. I saw that wolfssl has the support for only wolfSSL_EC_POINT_oct2point so I used Openssl and saved the generator point as an octet and tried to use the following code to load it into EC_POINT and print coordinates<br /></p><div class="codebox"><pre><code>        EC_POINT *G;
    unsigned char buf[] = {0x02, 0x79, 0xbe, 0x66, 0x7e, 0xf9, 0xdc, 0xbb, 0xac, 0x55, 0xa0, 0x62, 0x95, 0xce, 0x87, 0x0b, 0x07, 0x02, 0x9b, 0xfc, 0xdb, 0x2d, 0xce, 0x28, 0xd9, 0x59, 0xf2, 0x81, 0x5b, 0x16, 0xf8, 0x17, 0x98};
    size_t octets_len = 33;
    G = EC_POINT_new(group);
    EC_POINT_oct2point(group, G, buf, octets_len, ctx);
    if (!G) {
        fprintf(stderr, &quot;Failed to get the generator from octet.\n&quot;);
    }      
    BIGNUM *x = BN_new();
    BIGNUM *y = BN_new();
    EC_POINT_get_affine_coordinates_GFp(group, G, x, y, NULL);
    BN_print_fp(stdout, x);
    putc(&#039;\n&#039;, stdout);
    BN_print_fp(stdout, y);
    putc(&#039;\n&#039;, stdout);  </code></pre></div><p>this particular piece of code works with openssl but here it just prints<br />00<br />00<br />for x and y. <br />the debug log shows the following:</p><p>wolfSSL Entering wolfSSL_EC_POINT_oct2point<br />wolfSSL Entering wolfSSL_ECPoint_d2i<br />wc_ecc_import_point_der_ex failed</p><p>Does this needs some additional enabling of options?</p>]]></description>
			<author><![CDATA[null@example.com (juvebogdan)]]></author>
			<pubDate>Mon, 05 Sep 2022 22:16:44 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post6734.html#p6734</guid>
		</item>
		<item>
			<title><![CDATA[Re: OpenSSL compatibility]]></title>
			<link>https://www.wolfssl.com/forums/post6732.html#p6732</link>
			<description><![CDATA[<div class="quotebox"><cite>kareem_wolfssl wrote:</cite><blockquote><p>Hello,</p><p>Your ECC key is using a Koblitz curve which we do not enable support for by default.<br />Please add --enable-ecccustcurves=all to your configure line, rebuild wolfSSL and let me know if you still see any issues.</p><p>Thanks,<br />Kareem</p></blockquote></div><p>It works now. Thank you very much.</p>]]></description>
			<author><![CDATA[null@example.com (juvebogdan)]]></author>
			<pubDate>Sun, 04 Sep 2022 20:11:20 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post6732.html#p6732</guid>
		</item>
		<item>
			<title><![CDATA[Re: OpenSSL compatibility]]></title>
			<link>https://www.wolfssl.com/forums/post6729.html#p6729</link>
			<description><![CDATA[<p>Hello,</p><p>Your ECC key is using a Koblitz curve which we do not enable support for by default.<br />Please add --enable-ecccustcurves=all to your configure line, rebuild wolfSSL and let me know if you still see any issues.</p><p>Thanks,<br />Kareem</p>]]></description>
			<author><![CDATA[null@example.com (kareem_wolfssl)]]></author>
			<pubDate>Mon, 29 Aug 2022 22:56:29 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post6729.html#p6729</guid>
		</item>
		<item>
			<title><![CDATA[Re: OpenSSL compatibility]]></title>
			<link>https://www.wolfssl.com/forums/post6726.html#p6726</link>
			<description><![CDATA[<div class="quotebox"><cite>kareem_wolfssl wrote:</cite><blockquote><p>Happy to help.</p><p>What error code is wolfSSL_PEM_read_PrivateKey returning?&nbsp; Can you provide the private key you are trying to load, and the code you are using?&nbsp; Feel free to email us at support [AT] wolfssl [DOT] com if this is sensitive info.</p><p>Thanks,<br />Kareem</p></blockquote></div><p>Hi Kareem. I am still having an issue with reading PEM file using function PEM_read_PrivateKey. I went through the source code and used that like this:</p><div class="codebox"><pre><code>    int err = 0;
    WOLFSSL_EVP_PKEY* ret = NULL;
    WOLFSSL_BIO* bio = NULL;
    bio = wolfSSL_BIO_new(wolfSSL_BIO_s_file());
    err = bio == NULL;
    if(err == 0) {
        printf(&quot;step 1 \n&quot;);
    }
    if (err == 0) {
        err = wolfSSL_BIO_set_fp(bio, file, BIO_NOCLOSE) != WOLFSSL_SUCCESS;
        printf(&quot;step 2 \n&quot;);
    }
    if (err == 0) {
        ret = wolfSSL_PEM_read_bio_PrivateKey(bio, NULL, NULL, NULL);
        printf(&quot;step 3 \n&quot;);
    }

    if (bio != NULL) {
        wolfSSL_BIO_free(bio);
    }
    printf(&quot;final step&quot;);

    if (!ret) {
        //ERR_dump_errors_fp(stdout);
        fprintf(stderr, &quot;Error reading private key file.\n&quot;);
        return NULL;
    }</code></pre></div><p>So this is the source code of wolfSSL_PEM_read_PrivateKey and i get to final step print but I still have nothing in ret variable.<br />Is there something I am doing wrong here? This code works fine with openssl. the pem file is provided in above message. Can you help with this? <br />Thank you</p>]]></description>
			<author><![CDATA[null@example.com (juvebogdan)]]></author>
			<pubDate>Mon, 29 Aug 2022 20:36:03 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post6726.html#p6726</guid>
		</item>
		<item>
			<title><![CDATA[Re: OpenSSL compatibility]]></title>
			<link>https://www.wolfssl.com/forums/post6678.html#p6678</link>
			<description><![CDATA[<p>Hello,</p><p>I am not able to see any errors. What i am doing is the following:</p><div class="codebox"><pre><code>    EVP_PKEY *pk = wolfSSL_PEM_read_PrivateKey(file, NULL, NULL, NULL);

    if (!pk) {
        fprintf(stderr, &quot;Error reading private key file.\n&quot;);
        return NULL;
    }</code></pre></div><p>I uploaded the file i am using. I generated the file using this CLI command:<br />openssl ecparam -name secp256k1 -genkey -noout -out ca_key.pem</p><p>As i said when i use the file server-key.pem that i found in /certs directory of wolfssl github it works fine. I can upload that one as well if needed.</p><p>Thanks</p>]]></description>
			<author><![CDATA[null@example.com (juvebogdan)]]></author>
			<pubDate>Mon, 25 Jul 2022 19:43:51 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post6678.html#p6678</guid>
		</item>
		<item>
			<title><![CDATA[Re: OpenSSL compatibility]]></title>
			<link>https://www.wolfssl.com/forums/post6677.html#p6677</link>
			<description><![CDATA[<p>Happy to help.</p><p>What error code is wolfSSL_PEM_read_PrivateKey returning?&nbsp; Can you provide the private key you are trying to load, and the code you are using?&nbsp; Feel free to email us at support [AT] wolfssl [DOT] com if this is sensitive info.</p><p>Thanks,<br />Kareem</p>]]></description>
			<author><![CDATA[null@example.com (kareem_wolfssl)]]></author>
			<pubDate>Mon, 25 Jul 2022 19:28:26 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post6677.html#p6677</guid>
		</item>
		<item>
			<title><![CDATA[Re: OpenSSL compatibility]]></title>
			<link>https://www.wolfssl.com/forums/post6676.html#p6676</link>
			<description><![CDATA[<p>Thanks for the help. </p><p>I am having issues with the wolfSSL_PEM_read_PrivateKey function. I am unable to load EC Private key. I see that tests in source code load &quot;./certs/server-key.pem&quot; which is RSA private key in Pem format. And this works but EC private key doesnt. Is it possible to load EC Private key?</p><p>I would also add that these two lines of code do not work for me. There has to be something i am doing wrong</p><div class="codebox"><pre><code>if(NULL == (ca_key = EC_KEY_new_by_curve_name(NID_secp256k1)))
        goto ERROR;

    if(1 != EC_KEY_generate_key(ca_key)) goto ERROR;</code></pre></div><p>EC_KEY_generate_key returns 0. I have no errors printed to console.</p><p>thanks</p>]]></description>
			<author><![CDATA[null@example.com (juvebogdan)]]></author>
			<pubDate>Sun, 24 Jul 2022 12:33:26 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post6676.html#p6676</guid>
		</item>
		<item>
			<title><![CDATA[Re: OpenSSL compatibility]]></title>
			<link>https://www.wolfssl.com/forums/post6674.html#p6674</link>
			<description><![CDATA[<p>Happy to help.</p><p>For wolfSSL_EC_KEY_dup, you&#039;ll need OpenSSL all enabled as well, so you&#039;ll need to add --enable-opensslall to your ./configure line.<br />wolfSSL_EC_POINT_is_on_curve requires USE_ECC_B_PARAM.&nbsp; Add CFLAGS=&#039;-DUSE_ECC_B_PARAM&#039; to your configure line.</p><p>We don&#039;t currently support EC_GROUP_get0_generator or PEM_write_PrivateKey.&nbsp; You will need to replace these functions, or send a request to support AT wolfssl DOT com if you&#039;d like to see these added to our compatibility layer.<br />I also wanted to note we provide wolfEngine, for full OpenSSL compatibility: <a href="https://github.com/wolfSSL/wolfEngine">https://github.com/wolfSSL/wolfEngine</a>&nbsp; But we do recommend using our OpenSSL compatibility layer when possible.</p>]]></description>
			<author><![CDATA[null@example.com (kareem_wolfssl)]]></author>
			<pubDate>Thu, 21 Jul 2022 21:05:38 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post6674.html#p6674</guid>
		</item>
		<item>
			<title><![CDATA[Re: OpenSSL compatibility]]></title>
			<link>https://www.wolfssl.com/forums/post6668.html#p6668</link>
			<description><![CDATA[<p>Thanks for your help.</p><p>I installed and compiled this one wolfssl-5.4.0.zip .</p><p>I used the following command ./configure --enable-opensslextra</p><p>and this is my Makefile:</p><div class="codebox"><pre><code>CFLAGS=-c -g -O0 -Wextra -Wall -pedantic -std=gnu99 -lwolfssl
LDFLAGS=-lwolfssl
SOURCES=$(wildcard *.c)
OBJECTS=$(SOURCES:.c=.o)
EXEC=ecqv
CC=gcc

all: $(SOURCES) $(EXEC)

$(EXEC): $(OBJECTS)
    $(CC) -o $@ $(OBJECTS) $(LDFLAGS)

.c.o:
    $(CC) $(CFLAGS) $&lt; -o $@

clean:
    rm -f *.o $(EXEC)</code></pre></div><p>And this was my openssl one:</p><div class="codebox"><pre><code>CFLAGS=-c -g -O0 -Wextra -Wall -pedantic -std=gnu99 `pkg-config --cflags openssl`
LDFLAGS=`pkg-config --libs openssl`
SOURCES=$(wildcard *.c)
OBJECTS=$(SOURCES:.c=.o)
EXEC=ecqv
CC=gcc

all: $(SOURCES) $(EXEC)

$(EXEC): $(OBJECTS)
    $(CC) -o $@ $(OBJECTS) $(LDFLAGS)

.c.o:
    $(CC) $(CFLAGS) $&lt; -o $@

clean:
    rm -f *.o $(EXEC)</code></pre></div><p>I am using Ubuntu 20.04.4 LTS but as a subsytem on Windows.</p><p>Thanks</p>]]></description>
			<author><![CDATA[null@example.com (juvebogdan)]]></author>
			<pubDate>Wed, 20 Jul 2022 22:30:21 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post6668.html#p6668</guid>
		</item>
		<item>
			<title><![CDATA[Re: OpenSSL compatibility]]></title>
			<link>https://www.wolfssl.com/forums/post6665.html#p6665</link>
			<description><![CDATA[<p>Hello,</p><p>Which version of wolfSSL are you using?&nbsp; If you aren&#039;t using our latest release (5.4.0), try upgrading and let me know if it helps.<br />How are you building wolfSSL?&nbsp; Can you share your build settings (user_settings.h or ./configure line)?<br />Your includes look correct, make sure you have &lt;wolfssl/options.h&gt; included before all other wolfssl headers in all files using these headers.</p><p>Thanks,<br />Kareem</p>]]></description>
			<author><![CDATA[null@example.com (kareem_wolfssl)]]></author>
			<pubDate>Wed, 20 Jul 2022 17:54:49 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post6665.html#p6665</guid>
		</item>
		<item>
			<title><![CDATA[OpenSSL compatibility]]></title>
			<link>https://www.wolfssl.com/forums/post6664.html#p6664</link>
			<description><![CDATA[<p>Hello all,</p><p>I am begginer user with wolfssl. I already have my openssl app that works and i wanted to port it to wolfssl. I am having issues with a couple of things that i am having troubles with. Building my code gives me the following errors:</p><p>undefined reference to `wolfSSL_EC_KEY_dup&#039;<br />undefined reference to `EC_GROUP_get0_generator&#039;<br />undefined reference to `wolfSSL_EC_POINT_is_on_curve&#039;<br />undefined reference to `PEM_write_PrivateKey&#039;</p><p>I assume these without wolfSSL prefix do not exist? <br />Also some of these warning seem strange to me. Like this:<br /></p><div class="codebox"><pre><code>note: expected ‘WOLFSSL_EC_GROUP *’ {aka ‘struct WOLFSSL_EC_GROUP *’} but argument is of type ‘const EC_GROUP *’ {aka ‘const struct WOLFSSL_EC_GROUP *’}
  217 | int wolfSSL_EC_KEY_set_group(WOLFSSL_EC_KEY *key, WOLFSSL_EC_GROUP *group);</code></pre></div><p>My includes are setup like this:<br />#include &lt;stdio.h&gt;<br />#include &lt;string.h&gt;<br />#include &lt;unistd.h&gt;<br />#include &lt;errno.h&gt;<br />#include &lt;wolfssl/options.h&gt;<br />#include &lt;wolfssl/openssl/ssl.h&gt;<br />#include &lt;wolfssl/openssl/ec.h&gt;<br />#include &lt;wolfssl/openssl/bn.h&gt;<br />#include &lt;wolfssl/openssl/bio.h&gt;<br />#include &lt;wolfssl/openssl/ecdh.h&gt;<br />#include &lt;wolfssl/openssl/objects.h&gt;<br />#include &lt;wolfssl/openssl/rand.h&gt;<br />#include &lt;wolfssl/openssl/pem.h&gt;<br />#include &lt;wolfssl/openssl/evp.h&gt;</p><p>Do you have any advice on how to proceed? <br />Thank you</p>]]></description>
			<author><![CDATA[null@example.com (juvebogdan)]]></author>
			<pubDate>Wed, 20 Jul 2022 17:41:53 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post6664.html#p6664</guid>
		</item>
	</channel>
</rss>
