<?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 — Trouble loading EC .pem files]]></title>
		<link>https://www.wolfssl.com/forums/topic1363-trouble-loading-ec-pem-files.html</link>
		<atom:link href="https://www.wolfssl.com/forums/feed-rss-topic1363.xml" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Trouble loading EC .pem files.]]></description>
		<lastBuildDate>Tue, 07 May 2019 22:51:12 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Trouble loading EC .pem files]]></title>
			<link>https://www.wolfssl.com/forums/post4587.html#p4587</link>
			<description><![CDATA[<p>Hi @I_AM_MAD,</p><p>A typical private ECC key PEM formatted file would look like this:</p><div class="codebox"><pre><code>ASN1 OID: prime256v1
-----BEGIN EC PARAMETERS-----
BggqhkjOPQMBBw==
-----END EC PARAMETERS-----
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIPjPkmu9HijxqKuhI08ydBiIUK1+x+yS+I+XTa9WiWXHoAoGCCqGSM49
AwEHoUQDQgAEVb/0D0RQmj3Om7fwxU31cHvU7CSOGYDsWkyiJANiLJva76I1EkOE
dhbGVpUGzAGpvfZ1GkL3vamyNiJfx11/tA==
-----END EC PRIVATE KEY-----</code></pre></div><p>It looks like the ec params are missing from your PEM.</p><p>Here is an example of how we generate our test keys:</p><p>EDIT: (Apologies, I sent the wrong script snippet the other day, script updated below)</p><div class="codebox"><pre><code>#!/bin/sh                                                  
openssl ecparam -out ecc-key.pem -name prime256v1 -genkey</code></pre></div><p>Warm Regards,</p><p>K</p>]]></description>
			<author><![CDATA[null@example.com (Kaleb J. Himes)]]></author>
			<pubDate>Tue, 07 May 2019 22:51:12 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post4587.html#p4587</guid>
		</item>
		<item>
			<title><![CDATA[Re: Trouble loading EC .pem files]]></title>
			<link>https://www.wolfssl.com/forums/post4585.html#p4585</link>
			<description><![CDATA[<p>Oops, I appeared to have slipped some stuff in that I was debugging. The code is actually<br />iReturn = wolfSSL_CTX_use_certificate_file( xWolfSSL_ServerContext, &quot;/www/public_256_ecc.pem&quot;, SSL_FILETYPE_PEM );<br />&nbsp; &nbsp; &nbsp; if(iReturn != SSL_SUCCESS)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CONSOLE_LOG(&quot;server-cert.pem, %d\n&quot;, iReturn);</p><p>&nbsp; &nbsp; &nbsp; iReturn = wolfSSL_CTX_use_PrivateKey_file( xWolfSSL_ServerContext, &quot;/www/private_256_ecc.pem&quot;, SSL_FILETYPE_PEM );<br />&nbsp; &nbsp; &nbsp; if(iReturn != SSL_SUCCESS)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CONSOLE_LOG(&quot;server-key.pem, %d\n&quot;, iReturn);</p><p>(PEM not ASN1), which is the code producing this error.</p>]]></description>
			<author><![CDATA[null@example.com (I_AM_MAD)]]></author>
			<pubDate>Tue, 07 May 2019 19:16:45 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post4585.html#p4585</guid>
		</item>
		<item>
			<title><![CDATA[Trouble loading EC .pem files]]></title>
			<link>https://www.wolfssl.com/forums/post4584.html#p4584</link>
			<description><![CDATA[<p>Currently I am using a wolfssl on a microcontroller. I got it working with RSA, but took about 15 seconds to handshake (I have no divider in my cpu). I am switching to ecc to see if it speeds things up. I generated two pem files with openssl for this and I get errors when trying to load them. My settings are:</p><p>#define FREERTOS<br />#define WOLFSSL_LWIP<br />#define NO_WOLFSSL_DIR<br />#define HCC_SAFEFLASH<br />#define NO_STDIO_FILESYSTEM<br />#define NO_WOLFSSL_SMALL_STACK<br />#define WOLFSSL_STATIC_MEMORY<br />#define USE_FAST_MATH<br />#define TFM_TIMING_RESISTANT<br />#define ECC_TIMING_RESISTANT<br />#define WOLFSSL_STATIC_RSA<br />#define WC_NO_HARDEN<br />#define NO_WOLFSSL_CLIENT<br />#define NO_RSA<br />#define HAVE_ECC<br />#define TFM_ECC256<br />#define NO_SHA<br />#define NO_OLD_TLS<br />#define HAVE_HKDF<br />#define HAVE_ECC_ENCRYPT<br />#define WOLFSSL_CERT_GEN<br />#define ECC_DECODE_EXTRA<br />#define HAVE_HASHDRBG<br />#define CUSTOM_RAND_GENERATE</p><p>My pem files look like this:<br />(openssl ecparam -genkey -name prime256v1 -noout -out private.pem)<br />-----BEGIN EC PRIVATE KEY-----<br />MHcCAQEEIFJ+TI+kYZ0LhNdONR0xZsnBZOmQ+tP31mAT+TAnXb8+oAoGCCqGSM49<br />AwEHoUQDQgAERHc9yck7wB8OCWBLBPv5V223IGhwi8uxxPKgqxKL9mOhyCGTdLw6<br />D3eYb9D3mzeR0Qu6YM3//lgX/pubAYNmYw==<br />-----END EC PRIVATE KEY-----<br />(openssl ec -in private.pem -pubout -out public.pem)<br />-----BEGIN PUBLIC KEY-----<br />MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAERHc9yck7wB8OCWBLBPv5V223IGhw<br />i8uxxPKgqxKL9mOhyCGTdLw6D3eYb9D3mzeR0Qu6YM3//lgX/pubAYNmYw==<br />-----END PUBLIC KEY-----</p><p>The error I get is:<br />Couldn&#039;t find PEM header <br />and an error code of -162<br />My code to load looks like this:</p><p>&nbsp; &nbsp;iReturn = wolfSSL_Init();<br />&nbsp; &nbsp;if(iReturn != SSL_SUCCESS)<br />&nbsp; &nbsp; &nbsp; CONSOLE_LOG(&quot;wolfSSL_Init failed, %d\n&quot;, iReturn);</p><p>&nbsp; &nbsp;xWolfSSL_ServerContext = wolfSSL_CTX_new( wolfTLSv1_2_server_method() );<br />&nbsp; &nbsp;if( xWolfSSL_ServerContext != NULL )<br />&nbsp; &nbsp;{<br />&nbsp; &nbsp; &nbsp; iReturn = wolfSSL_CTX_use_certificate_file( xWolfSSL_ServerContext, &quot;/www/public_256_ecc.pem&quot;, SSL_FILETYPE_ASN1 );<br />&nbsp; &nbsp; &nbsp; if(iReturn != SSL_SUCCESS)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CONSOLE_LOG(&quot;server-cert.pem, %d\n&quot;, iReturn);</p><p>&nbsp; &nbsp; &nbsp; iReturn = wolfSSL_CTX_use_PrivateKey_file( xWolfSSL_ServerContext, &quot;/www/private_256_ecc.pem&quot;, SSL_FILETYPE_ASN1 );<br />&nbsp; &nbsp; &nbsp; if(iReturn != SSL_SUCCESS)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CONSOLE_LOG(&quot;server-key.pem, %d\n&quot;, iReturn);<br />&nbsp; &nbsp;}<br />&nbsp; &nbsp;else<br />&nbsp; &nbsp; &nbsp; CONSOLE_LOG(&quot;xWolfSSL_ServerContext is NULL\n&quot;);</p>]]></description>
			<author><![CDATA[null@example.com (I_AM_MAD)]]></author>
			<pubDate>Tue, 07 May 2019 19:00:25 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post4584.html#p4584</guid>
		</item>
	</channel>
</rss>
