<?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 — ERROR: 2 way SSL with EC keys]]></title>
		<link>https://www.wolfssl.com/forums/topic603-error-2-way-ssl-with-ec-keys.html</link>
		<atom:link href="https://www.wolfssl.com/forums/feed-rss-topic603.xml" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in ERROR: 2 way SSL with EC keys.]]></description>
		<lastBuildDate>Mon, 01 Dec 2014 03:55:19 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: ERROR: 2 way SSL with EC keys]]></title>
			<link>https://www.wolfssl.com/forums/post1847.html#p1847</link>
			<description><![CDATA[<p>Hi Amit,</p><p>just throw my thought, hope it helps. </p><p>Could you have test using below example codes?<br />It&#039;s trying to load ECC key pairs, then decode -&gt; export private key.<br />the private key will be exported to derKey, and length is derKeySz.</p><p>========= Examples ==============<br /> ecc_key priKey;<br /> int derKeySz;<br /> FILE* priFile;<br /> byte tmp[TWOK_BUF];<br /> word32&nbsp; idx = 0;<br /> int ret;</p><p> priFile= fopen(xxx.key, &quot;rb&quot;);<br />&nbsp; &nbsp; if (!priFile)<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\r\nLoad Private Key fail.&quot;);<br />&nbsp; &nbsp; &nbsp; &nbsp; return;<br />&nbsp; &nbsp; }</p><p>&nbsp; &nbsp; derKeySz = fread(tmp, 1, TWOK_BUF, priFile);<br />&nbsp; &nbsp; fclose(priFile);</p><p>&nbsp; &nbsp; ret = EccPrivateKeyDecode(tmp, &amp;idx, &amp;priKey, (word32)derKeySz);<br />&nbsp; &nbsp; if (ret != 0) {<br />&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\r\nEccPrivateKeyDecode fail.&quot;);<br />&nbsp; &nbsp; &nbsp; &nbsp; return;<br />&nbsp; &nbsp; }</p><p>&nbsp; &nbsp; ret = ecc_export_private_only (&amp;priKey, derKey, &amp;derKeySz);</p><p>&nbsp; &nbsp; if (ret != 0)<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; printf (&quot;&lt;%s&gt; Fail!\n&quot;, __func__);<br />&nbsp; &nbsp; &nbsp; &nbsp; return;<br />&nbsp; &nbsp; }</p>]]></description>
			<author><![CDATA[null@example.com (52eason)]]></author>
			<pubDate>Mon, 01 Dec 2014 03:55:19 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post1847.html#p1847</guid>
		</item>
		<item>
			<title><![CDATA[Re: ERROR: 2 way SSL with EC keys]]></title>
			<link>https://www.wolfssl.com/forums/post1831.html#p1831</link>
			<description><![CDATA[<p>Chris: Its the same error with your key:</p><p>openssl ec -in ecc-key.pem -outform DER | xxd -i<br />read EC key<br />writing EC key<br />&nbsp; 0x30, 0x77, 0x02, 0x01, 0x01, 0x04, 0x20, 0x45, 0xb6, 0x69, 0x02, 0x73,<br />&nbsp; 0x9c, 0x6c, 0x85, 0xa1, 0x38, 0x5b, 0x72, 0xe8, 0xe8, 0xc7, 0xac, 0xc4,<br />&nbsp; 0x03, 0x8d, 0x53, 0x35, 0x04, 0xfa, 0x6c, 0x28, 0xdc, 0x34, 0x8d, 0xe1,<br />&nbsp; 0xa8, 0x09, 0x8c, 0xa0, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d,<br />&nbsp; 0x03, 0x01, 0x07, 0xa1, 0x44, 0x03, 0x42, 0x00, 0x04, 0xbb, 0x33, 0xac,<br />&nbsp; 0x4c, 0x27, 0x50, 0x4a, 0xc6, 0x4a, 0xa5, 0x04, 0xc3, 0x3c, 0xde, 0x9f,<br />&nbsp; 0x36, 0xdb, 0x72, 0x2d, 0xce, 0x94, 0xea, 0x2b, 0xfa, 0xcb, 0x20, 0x09,<br />&nbsp; 0x39, 0x2c, 0x16, 0xe8, 0x61, 0x02, 0xe9, 0xaf, 0x4d, 0xd3, 0x02, 0x93,<br />&nbsp; 0x9a, 0x31, 0x5b, 0x97, 0x92, 0x21, 0x7f, 0xf0, 0xcf, 0x18, 0xda, 0x91,<br />&nbsp; 0x11, 0x02, 0x34, 0x86, 0xe8, 0x20, 0x58, 0x33, 0x0b, 0x80, 0x34, 0x89,<br />&nbsp; 0xd8</p><p>CyaSSL Leaving AddCA, return 0<br />CyaSSL Entering CyaSSL_CTX_use_PrivateKey_buffer<br />CyaSSL Entering GetMyVersion<br />CyaSSL Entering GetMyVersion<br />Error loading ClientKey , ret = -4</p><p>Here are Steps used to generate key and created buffer array with xxd:</p><p>generate pvt key:</p><p>openssl ecparam -name secp384r1&nbsp; &nbsp;-genkey -noout -out ca-root.key</p><p>generate cert:<br />openssl req -new -x509 -key ca-root.key -out&nbsp; ca-root..crt&nbsp; -days 3650 -subj /CN=somecn.com/emailAddress=myemail.com</p><p>openssl x509 -in ca-root.crt&nbsp; -outform DER | xxd -i</p><p>openssl ec -in ca-root.key -outform DER | xxd -i</p><p>read EC key<br />writing EC key<br />&nbsp; 0x30, 0x81, 0xa4, 0x02, 0x01, 0x01, 0x04, 0x30, 0xf3, 0x8c, 0x4b, 0x19,<br />&nbsp; 0x8c, 0x45, 0x05, 0x69, 0xdc, 0xaf, 0x4e, 0xce, 0xb8, 0x59, 0x75, 0x65,<br />&nbsp; 0xb4, 0x3b, 0xbe, 0xa3, 0x84, 0x5b, 0xc1, 0x3b, 0x5b, 0xe7, 0x5a, 0x18,<br />&nbsp; 0x33, 0x1d, 0xd2, 0x55, 0x54, 0x3c, 0x16, 0xd8, 0x96, 0xc8, 0x98, 0x1a,<br />&nbsp; 0x21, 0xaf, 0x6f, 0x38, 0x77, 0x60, 0x03, 0x51, 0xa0, 0x07, 0x06, 0x05,<br />&nbsp; 0x2b, 0x81, 0x04, 0x00, 0x22, 0xa1, 0x64, 0x03, 0x62, 0x00, 0x04, 0x3c,<br />&nbsp; 0xc0, 0x1c, 0xe8, 0xc8, 0x6c, 0x27, 0x58, 0xad, 0x07, 0xf5, 0x9c, 0xe9,<br />&nbsp; 0x8f, 0x8b, 0xdb, 0x2f, 0xca, 0x74, 0x27, 0xfd, 0x22, 0xcd, 0xdd, 0x2e,<br />&nbsp; 0x01, 0xb5, 0x8a, 0xb9, 0x51, 0x45, 0x6d, 0x38, 0x03, 0x57, 0x67, 0xa1,<br />&nbsp; 0x43, 0x4a, 0xb0, 0x4e, 0x1c, 0xd9, 0x21, 0xdd, 0x14, 0xe6, 0xfd, 0x6b,<br />&nbsp; 0xb7, 0xd0, 0x2f, 0xba, 0xc4, 0x77, 0x9c, 0xb7, 0x73, 0xcb, 0x85, 0x6f,<br />&nbsp; 0x8f, 0x66, 0x7c, 0x01, 0x82, 0xd0, 0xed, 0x10, 0xd0, 0x58, 0xa4, 0x9d,<br />&nbsp; 0xed, 0x0e, 0x9d, 0x40, 0x9a, 0x6d, 0xc0, 0x9b, 0x0d, 0x9b, 0x33, 0xfa,<br />&nbsp; 0x9d, 0x4b, 0x77, 0x26, 0x2c, 0xe4, 0x05, 0xc1, 0xc4, 0xda, 0x6b</p>]]></description>
			<author><![CDATA[null@example.com (amitsehgal)]]></author>
			<pubDate>Thu, 13 Nov 2014 23:42:05 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post1831.html#p1831</guid>
		</item>
		<item>
			<title><![CDATA[Re: ERROR: 2 way SSL with EC keys]]></title>
			<link>https://www.wolfssl.com/forums/post1829.html#p1829</link>
			<description><![CDATA[<p>Hi Amit,</p><p>Can you show how you generated your test key?&nbsp; And if you could send the test key to us, that would be helpful as well.</p><p>We have successfully tested loading our own ECC key (./certs/ecc-key.der) in buffer form with CyaSSL_CTX_use_PrivateKey_buffer().&nbsp; Have you tried loading our test key?</p><p>Thanks,<br />Chris</p>]]></description>
			<author><![CDATA[null@example.com (chrisc)]]></author>
			<pubDate>Thu, 13 Nov 2014 23:32:12 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post1829.html#p1829</guid>
		</item>
		<item>
			<title><![CDATA[ERROR: 2 way SSL with EC keys]]></title>
			<link>https://www.wolfssl.com/forums/post1828.html#p1828</link>
			<description><![CDATA[<p>I have tried creating EC certs and keys with curve secp384r1 &amp; prime256v1 mbed M3 for embedded SSL.&nbsp; I&#039;m getting error while loading key as below. Can someone throw some light on it ?</p><p>-4 means invalid file. But doesn;t seems so as i have used same process for RSA and it does load key.</p><p>CyaSSL_CTX_use_PrivateKey_buffer(ctx, CAKey, sizeof(CAKey), SSL_FILETYPE_ASN1);</p><p>Thanks,<br />Amit<br />CYASSL logs:<br />--------------<br />Getting Cert Name<br />Got Subject Name<br />CyaSSL Entering GetAlgoId<br />Got Key<br />ECDSA cert signature<br />CyaSSL Entering CyaSSL_CTX_use_PrivateKey_buffer<br />CyaSSL Entering GetMyVersion<br />[color=&quot;red&quot;]Error loading ClientKey , ret = -4[/color]</p>]]></description>
			<author><![CDATA[null@example.com (amitsehgal)]]></author>
			<pubDate>Thu, 13 Nov 2014 20:34:40 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post1828.html#p1828</guid>
		</item>
	</channel>
</rss>
