<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://www.ethernut.de/nutwiki/index.php?action=history&amp;feed=atom&amp;title=Nut_TLS</id>
		<title>Nut TLS - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://www.ethernut.de/nutwiki/index.php?action=history&amp;feed=atom&amp;title=Nut_TLS"/>
		<link rel="alternate" type="text/html" href="http://www.ethernut.de/nutwiki/index.php?title=Nut_TLS&amp;action=history"/>
		<updated>2026-04-28T22:51:32Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.26.2</generator>

	<entry>
		<id>http://www.ethernut.de/nutwiki/index.php?title=Nut_TLS&amp;diff=206&amp;oldid=prev</id>
		<title>Harald: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="http://www.ethernut.de/nutwiki/index.php?title=Nut_TLS&amp;diff=206&amp;oldid=prev"/>
				<updated>2016-10-27T16:02:59Z</updated>
		
		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;tr style='vertical-align: top;' lang='en'&gt;
				&lt;td colspan='1' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='1' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 16:02, 27 October 2016&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan='2' style='text-align: center;' lang='en'&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Harald</name></author>	</entry>

	<entry>
		<id>http://www.ethernut.de/nutwiki/index.php?title=Nut_TLS&amp;diff=205&amp;oldid=prev</id>
		<title>Bg at 14:24, 10 July 2013</title>
		<link rel="alternate" type="text/html" href="http://www.ethernut.de/nutwiki/index.php?title=Nut_TLS&amp;diff=205&amp;oldid=prev"/>
				<updated>2013-07-10T14:24:38Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This is a first attempt to describe how to test the new Nut/OS TLS implementation.&lt;br /&gt;
&lt;br /&gt;
 Note: Currently only the server side of TLS 1.2 is implemented.&lt;br /&gt;
 TLS 1.2 is the most recent (August 2008) version of Transport Layer Security.&lt;br /&gt;
 Although the standard is released a few years ago, Browser developers started&lt;br /&gt;
 implementing it just quite recently, so it is not wide spread.&lt;br /&gt;
&lt;br /&gt;
Our implementation was tested with:&lt;br /&gt;
* GnuTLS&lt;br /&gt;
* IE 8(?)&lt;br /&gt;
* Opera 12.02 (Linux &amp;amp; Windows)&lt;br /&gt;
&lt;br /&gt;
 Note: The current implementation is quite slow (it takes about 11.7 seconds on the AT91SAM7X) to do&lt;br /&gt;
 the RSA computations for the handshake. So be a little bit patient with the connection process.&lt;br /&gt;
&lt;br /&gt;
 Note: This only works for ARM Controllers, AVR are (currently) not supported (the note above may be a reason ''why'').&lt;br /&gt;
&lt;br /&gt;
In Opera and IE you have to explicitly enable TLS 1.2 in the security settings (usually under &amp;quot;advanced settings&amp;quot; or similar).&lt;br /&gt;
&lt;br /&gt;
You also have to install the recent version of arm-crypto-lib (from Das Labor) (link to the instruction will be inserted when instructions are written).&lt;br /&gt;
&lt;br /&gt;
To build and test the Test-Server (from 'tls' in the application directory) you may follow the following instructions.&lt;br /&gt;
&lt;br /&gt;
 Note: The instructions are currently for GNU/Linux systems only. They might work with Windows or Mac OS X but it is not tested.&lt;br /&gt;
 The develop/testing machine runs on a current ArchLinux installation.&lt;br /&gt;
&lt;br /&gt;
= Prepare =&lt;br /&gt;
We will create a special directory for our experiments, let us call it ''nuttls_test_space''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=konsole&amp;gt;&lt;br /&gt;
mkdir nuttls_test_space&lt;br /&gt;
cd nuttls_test_space&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here we create two more directorys, one for nutos and one for the crypto library &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=konsole&amp;gt;&lt;br /&gt;
mkdir nut cryptolib&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Build Crypto-Lib =&lt;br /&gt;
&lt;br /&gt;
== Step 1 - get the source ==&lt;br /&gt;
&amp;lt;pre class=konsole&amp;gt;&lt;br /&gt;
cd cryptolib&lt;br /&gt;
git clone git://das-labor.org/users/bg/arm-crypto-lib .&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This may take some time (it has to download ~260MiB of data).&lt;br /&gt;
&lt;br /&gt;
== Step 2 - configure ==&lt;br /&gt;
Normally there should be nothing to configure.&lt;br /&gt;
But you should check that the build options defined in ''Makefile_sys_conf.inc'' and ''Makefile_arm7tdmi_conf.inc'' match the build options for Nut/OS (especially the ABI).&lt;br /&gt;
&lt;br /&gt;
== Step 3 - build ==&lt;br /&gt;
It should be as easy as running:&lt;br /&gt;
&amp;lt;pre class=konsole&amp;gt;&lt;br /&gt;
make -f Makefile_arm7tdmi lib&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You should now have a library (''bin/arm7tdmi_generic/lib/libcrypto.a'').&lt;br /&gt;
&lt;br /&gt;
== Step 4 - install ==&lt;br /&gt;
First you have to install the library. Therefore copy the file ''bin/arm7tdmi_generic/lib/libcrypto.a'' into the library directory of your toolchain (for example ''/usr/arm-elf/lib/'' on my system) and change the permissions so that your user can read it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=konsole&amp;gt;&lt;br /&gt;
sudo cp bin/arm7tdmi_generic/lib/libcrypto.a /usr/arm-elf/lib/ &amp;lt;br&amp;gt;&lt;br /&gt;
chmod 664 /usr/arm-elf/lib/libcrypto.a&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next you have to install the header-files. You can use the script ''install_headers.sh'' but have to adjust the ''PREFIX'' variable (line 3) to match the header directory of your toolchain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=konsole&amp;gt;&lt;br /&gt;
sudo sh install_headers.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Build Nut/OS and Testserver =&lt;br /&gt;
&lt;br /&gt;
== Step 1 - get the source ==&lt;br /&gt;
Then we check out the current nuttls-development-tree&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=konsole&amp;gt;&lt;br /&gt;
cd nut &amp;lt;br&amp;gt;&lt;br /&gt;
svn co https://ethernut.svn.sourceforge.net/svnroot/ethernut/branches/devnut_tls .&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2 - configure the source ==&lt;br /&gt;
If you have not installed nutconf or qnutconf before you should do it now. [[http://www.ethernut.de/nutwiki/Nut/OS_installation_on_Linux_%28Debain%29|This]] may shows you how.&lt;br /&gt;
&lt;br /&gt;
So we are still in our ''nut'' directory (you should avoid to confuse it with the ''nut'' directory we just got with our check-out). &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=konsole&amp;gt;&lt;br /&gt;
nutconf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Will start the graphical configuration interface. It will ask you for your configuration file and you should select the one matching your board (current tests run on an ''AT91SAM7X-EK'', if you are lucky enough to have this board you may directly select ''tls_at91sam7x-ek.conf'').&lt;br /&gt;
&lt;br /&gt;
You should at least adjust the ''Main Thread Stack Size'' to 2048 bytes (the RSA computation takes a lot of stack).&lt;br /&gt;
 Nut/OS Components -&amp;gt; RTOS Kernel -&amp;gt; Multithreading -&amp;gt; Main Thread Stack Size -&amp;gt; 2048&lt;br /&gt;
&lt;br /&gt;
You may adjust other items, like your compiler, libc, ...&lt;br /&gt;
&lt;br /&gt;
For our purposes we set the ''nut build directory'' to ''nut_build'' and the ''application'' (sample) directory to ''nut_app'' in the &amp;quot;Settings Menu&amp;quot; ( Edit -&amp;gt; Settings).&lt;br /&gt;
&lt;br /&gt;
Now you have to build Nut/OS:&lt;br /&gt;
&lt;br /&gt;
 Build -&amp;gt; Build Nut/OS&lt;br /&gt;
&lt;br /&gt;
And create the app directory:&lt;br /&gt;
 &lt;br /&gt;
 Build -&amp;gt; Create Sample Directory&lt;br /&gt;
&lt;br /&gt;
== Step 3 - build the TLS Test-Server ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=konsole&amp;gt;&lt;br /&gt;
cd nut_app/tls &amp;lt;br&amp;gt;&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You now should have working binaries. You may be able to use&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=konsole&amp;gt;&lt;br /&gt;
make burn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to flash your binary to your board. This did not work for me, so if you have an ''AT91SAM7X-EK'' you may instead run&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=konsole&amp;gt;&lt;br /&gt;
sh flash.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Testing the Test-Server =&lt;br /&gt;
First you have to identify which IP-Address is assigned to your board by the DHCP-Server.&lt;br /&gt;
To get this information you may query your DHCP-Server, or get it from the Debug output from your board (you did connect the UART/RS232 interface to the debug port, didn't you?).&lt;br /&gt;
&lt;br /&gt;
You should see the following output (or at least quite a similar one, since this changes during development):&lt;br /&gt;
&amp;lt;pre class=konsole&amp;gt; &amp;lt;nowiki&amp;gt;&lt;br /&gt;
Nut/OS 4.10.0.0&lt;br /&gt;
TLS Server Sample 0.1.0&lt;br /&gt;
Configure eth0...OK&lt;br /&gt;
Run 'gnutls-cli 192.168.192.243 443' to connect to this server&lt;br /&gt;
Register UROM file system...OK.&lt;br /&gt;
&lt;br /&gt;
spawning thread: tls_0&lt;br /&gt;
&lt;br /&gt;
Waiting for a tls client...&lt;br /&gt;
spawning thread: tls_1&lt;br /&gt;
&lt;br /&gt;
Waiting for a tls client...&lt;br /&gt;
spawning thread: tls_2&lt;br /&gt;
&lt;br /&gt;
Waiting for a tls client...&lt;br /&gt;
&amp;lt;/nowiki&amp;gt; &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here our address is 192.168.192.243, this will be different on your board.&lt;br /&gt;
&lt;br /&gt;
Now you can add a hostname for this IP-Address to your machines configuration&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=konsole&amp;gt;&lt;br /&gt;
sudo echo &amp;lt;board-ip&amp;gt; nuttls_test_system &amp;gt;&amp;gt; /etc/hosts&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is now time to connect via TLS. I recommend using the command-line utility from GnuTLS:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=konsole&amp;gt;&lt;br /&gt;
gnutls-cli --x509cafile cert/nuttls_test_system.cert nuttls_test_system&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=konsole&amp;gt; &amp;lt;nowiki&amp;gt;&lt;br /&gt;
Now the following should appear on your terminal:&lt;br /&gt;
Processed 1 CA certificate(s).&lt;br /&gt;
Resolving 'nuttls_test_system'...&lt;br /&gt;
Connecting to '192.168.192.243:443'...&lt;br /&gt;
- Peer's certificate is trusted&lt;br /&gt;
- The hostname in the certificate matches 'nuttls_test_system'.&lt;br /&gt;
- Session ID: E4:0E:C7:B0&lt;br /&gt;
- Certificate type: X.509&lt;br /&gt;
- Got a certificate list of 1 certificates.&lt;br /&gt;
- Certificate[0] info:&lt;br /&gt;
 - subject `C=DE,O=egnite GmbH,ST=NRW,CN=Daniel Otte', issuer `C=DE,O=egnite GmbH,ST=NRW,CN=Daniel Otte', &lt;br /&gt;
   RSA key 512 bits, signed using RSA-SHA256, activated `  2012-06-18 17:09:27 UTC', &lt;br /&gt;
   expires `2013-06-18 17:09:27 UTC', SHA-1 fingerprint `6ff3f09462e388468f96eaef941baf95c169be83'&lt;br /&gt;
	Public Key Id:&lt;br /&gt;
		4b16eff5669cf1ed071cc55eb3e52953fc23c5e6&lt;br /&gt;
	Public key's random art:&lt;br /&gt;
		+--[ RSA  512]----+&lt;br /&gt;
		|              o. |&lt;br /&gt;
		|               B=|&lt;br /&gt;
		|        .     =+B|&lt;br /&gt;
		|         o   +.E+|&lt;br /&gt;
		|        S . ..=..|&lt;br /&gt;
		|       o o . oo+.|&lt;br /&gt;
		|        . .   *.o|&lt;br /&gt;
		|             o ..|&lt;br /&gt;
		|                o|&lt;br /&gt;
		+-----------------+ &lt;br /&gt;
&lt;br /&gt;
- Version: TLS1.2&lt;br /&gt;
- Key Exchange: RSA&lt;br /&gt;
- Cipher: AES-128-CBC&lt;br /&gt;
- MAC: SHA256&lt;br /&gt;
- Compression: NULL&lt;br /&gt;
- Handshake was completed &lt;br /&gt;
&lt;br /&gt;
- Simple Client Mode:&lt;br /&gt;
&amp;lt;/nowiki&amp;gt; &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You have now opened a direct connection to the board (it a little bit like telnet).&lt;br /&gt;
You can now start an HTTP-Request (note the blank line afte the GET ... line)&lt;br /&gt;
&amp;lt;pre class=konsole&amp;gt;&lt;br /&gt;
GET / HTTP&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Server should respond with&lt;br /&gt;
&amp;lt;pre class=konsole&amp;gt; &amp;lt;nowiki&amp;gt;&lt;br /&gt;
HTTP/1.1 200 Ok&lt;br /&gt;
Server: Ethernut 4.10.0.0&lt;br /&gt;
Content-Type: text/html&lt;br /&gt;
Content-Length: 59&lt;br /&gt;
Connection: close&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Works&amp;lt;/h1&amp;gt; &lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt; &amp;lt;/pre&amp;gt;&lt;br /&gt;
And then it should close the connection.&lt;br /&gt;
&lt;br /&gt;
= Generating your own certificate =&lt;br /&gt;
 For this steps you currently need a working C-Compiler (gcc is used in the examples) and a working ruby environment.&lt;br /&gt;
&lt;br /&gt;
You may be interested in getting your own certificate on the board. There are many good tutorials how to set up a PKI so we will not go to much into detail here.&lt;br /&gt;
So for now we assume you have a RSA certificate in DER form and a matching key in text form as shown in the example below (created with certtool from gnuTLS):&lt;br /&gt;
&amp;lt;pre class=konsole&amp;gt; &amp;lt;nowiki&amp;gt;&lt;br /&gt;
Public Key Info:&lt;br /&gt;
        Public Key Algorithm: RSA&lt;br /&gt;
        Key Security Level: Low&lt;br /&gt;
&lt;br /&gt;
modulus:&lt;br /&gt;
        00:c4:04:46:32:2b:18:eb:56:d4:01:7a:4e:db:b7:&lt;br /&gt;
        50:05:34:65:64:07:26:86:b8:d0:2b:d9:d5:3d:35:&lt;br /&gt;
        d8:4e:77:f8:6b:21:9a:be:a5:6f:4c:ef:82:1c:58:&lt;br /&gt;
        36:7a:f1:ba:81:1e:32:8c:d4:5c:dc:df:6e:13:b6:&lt;br /&gt;
        dc:d9:49:0a:25:&lt;br /&gt;
public exponent:&lt;br /&gt;
        01:00:01:&lt;br /&gt;
private exponent:&lt;br /&gt;
        00:c2:a4:0f:e4:3f:41:66:67:78:eb:e2:bc:ad:96:&lt;br /&gt;
        b0:c2:0a:4e:67:ee:65:c6:3f:7c:8f:1e:a6:8d:3a:&lt;br /&gt;
        8b:89:15:fd:8d:11:aa:f8:ad:a7:cf:5c:c7:86:11:&lt;br /&gt;
        83:cc:f8:37:16:14:a5:3e:53:8b:ce:c4:42:46:bf:&lt;br /&gt;
        7f:b0:11:d7:bd:&lt;br /&gt;
prime1:&lt;br /&gt;
        00:c4:97:6d:6a:04:19:0c:69:b0:16:63:74:73:d2:&lt;br /&gt;
        cf:21:2c:00:47:6e:4c:88:a0:8b:d6:69:25:e2:82:&lt;br /&gt;
        00:ce:db:&lt;br /&gt;
prime2:&lt;br /&gt;
        00:ff:40:60:d2:35:bb:a0:18:fa:2a:aa:65:bc:d5:&lt;br /&gt;
        35:65:fb:c0:f6:20:4b:33:65:a2:97:43:d7:04:7b:&lt;br /&gt;
        e6:5a:ff:&lt;br /&gt;
coefficient:&lt;br /&gt;
        00:9a:2b:48:98:ac:76:06:a4:05:f6:c6:ec:0f:70:&lt;br /&gt;
        c8:47:44:98:0f:1f:ec:26:61:f7:04:2c:7f:2d:55:&lt;br /&gt;
        b6:ce:67:&lt;br /&gt;
exp1:&lt;br /&gt;
        54:c6:4b:fb:6c:9a:f4:9c:5a:bf:bc:d1:89:e4:bd:&lt;br /&gt;
        47:3b:b7:3f:16:54:50:92:92:da:b9:eb:09:5b:30:&lt;br /&gt;
        48:03:&lt;br /&gt;
exp2:&lt;br /&gt;
        31:8c:9b:be:f2:b3:53:66:c5:d9:56:6e:9d:73:7e:&lt;br /&gt;
        04:28:14:d3:32:7d:a6:a2:8a:27:77:01:dc:5a:f8:&lt;br /&gt;
        e2:9d:&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/nowiki&amp;gt; &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The next step is compiling the cert-merge tool in the directory ''cert'':&lt;br /&gt;
&amp;lt;pre class=konsole&amp;gt;&lt;br /&gt;
cd cert&lt;br /&gt;
gcc -o cert-merge cert-merge.c&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You are now able to create new certificate-binary-blobs. If ''nuttls_test_system.cert.der'' is your DER-certificate you can use&lt;br /&gt;
&amp;lt;pre class=konsole&amp;gt;&lt;br /&gt;
./cert-merge nuttls_test_system.cert.tls nuttls_test_system.cert.der&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
to create a binary blob for the nutTLS system. To include this blob you may like to create an elf-file like this:&lt;br /&gt;
&amp;lt;pre class=konsole&amp;gt;&lt;br /&gt;
 arm-elf-objcopy --rename-section .data=.rodata,alloc,load,readonly,data,contents \&lt;br /&gt;
                 -I binary -O elf32-littlearm nuttls_test_system.cert.tls \&lt;br /&gt;
                 nuttls_test_system.cert.tls.elf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now you should have ''nuttls_test_system.cert.tls.elf'' ready for linking into your project. If you changed the input file name for the elf-file you should adjust the Macros ''CERT_BLOB_START'', ''CERT_BLOB_END'' and ''CERT_BLOB_SIZE'' in tls_handshake.c as they are based on the file name.&lt;br /&gt;
&lt;br /&gt;
What is left is inclusion of the key. The key is transformed into C-source-code by ''convert-key.rb''. ''convert-key.rb'' is a ruby script which transforms a RSA key given in the text form shown above into C-code. If your key file is named ''nuttls_test_system.key'', you may use the following command:&lt;br /&gt;
&amp;lt;pre class=konsole&amp;gt;&lt;br /&gt;
ruby convert-key.rb nuttls_test_system.key &amp;gt; server.key.c&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you copy both new created files (''nuttls_test_system.cert.tls.elf'' and ''server.key.c'') in the projects directory and recreate the project:&lt;br /&gt;
&amp;lt;pre class=konsole&amp;gt;&lt;br /&gt;
make clean all&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You should have a working binary with your certificate.&lt;/div&gt;</summary>
		<author><name>Bg</name></author>	</entry>

	</feed>