{"id":160,"date":"2019-02-25T14:00:22","date_gmt":"2019-02-25T13:00:22","guid":{"rendered":"https:\/\/www.summonte.com\/home\/?p=160"},"modified":"2019-02-25T14:00:22","modified_gmt":"2019-02-25T13:00:22","slug":"curve-ellittiche-in-pratica","status":"publish","type":"post","link":"https:\/\/www.summonte.com\/home\/2019_02_25-curve-ellittiche-in-pratica\/","title":{"rendered":"Curve Ellittiche in pratica"},"content":{"rendered":"\n<p>Ciao, <\/p>\n\n\n\n<p>di seguito un semplice esempio di come utilizzare le curve ellittiche tramite il classico strumento openssl e i nostri classici amici Alice e Bob.<\/p>\n\n\n\n<p>Alice e Bob generano le proprie chiavi pubbliche e private ti tipo ellittico<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h4 class=\"wp-block-heading\" style=\"text-align:center\">Creazione Chiavi<\/h4>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>Alice:<\/p><cite>openssl genpkey -algorithm \u00a0X25519 -out alice_privkey.pem <br>openssl pkey -in alice_privkey.pem -pubout -out alice_pubkey.pem <\/cite><\/blockquote>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>Bob:<\/p><cite>openssl genpkey -algorithm \u00a0X25519 -out bob_privkey.pem<br>openssl pkey -in bob_privkey.pem -pubout -out bob_pubkey.pem <\/cite><\/blockquote>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" style=\"text-align:center\">Cifra<\/h2>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>Alice:<\/p><cite><strong><em>Alice genera una chiave EC temporanea e ne deriva un segreto usando la chiave pubblica di Bob<\/em><\/strong><br><br>openssl genpkey -algorithm  X25519 -out temp_privkey.pem<br>openssl pkeyutl -der<em>i<\/em>ve -inkey temp_privkey.pem -peerkey bob_pubkey.pem | base64 -w0 > secret.txt<br><br><strong><em>(Attenzione, openssl tratta i dati da console come stringhe. Per evitare problemi di 0x00 presenti nella chiave, la convertiamo in base64)<\/em><\/strong><br><br><strong><em>Alice cifra il file per Bob con il segreto ottenuto<\/em><\/strong><br>openssl enc -aes-256-cbc -in Testo.txt -out Testo.txt.enc -pass file:secret.txt <br><br> <strong><em>Alice genera la parte pubblica della chiave temporanea dalla quale Bob otterr\u00e0 il segreto<\/em><\/strong><br><br>openssl ecparam -in temp_privkey.pem -pubout -out temp_pubkey.pem<br><br> <strong><em>Alice invia a Bob il file cifrato Testo.txt.enc e la chiave pubblica temp_pubkey.pem<\/em><\/strong> <\/cite><\/blockquote>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" style=\"text-align:center\">Decifra<\/h2>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>Bob:<\/p><cite><strong><em>Bob usa la sua chiave privata &#8221; bob_privkey.pem &#8221; e la chiave pubblica ricevuta &#8221; temp_pubkey.pem &#8221; per derivare il segreto<\/em><\/strong><br><br>openssh pkeyutl -derive -inkey bob_privkey.pem -peerkey temp_pubkey.pem | base64 -w0 > secret.txt<br><br> <strong><em>Bob decifra il testo cifrato<\/em><\/strong><br><br>openssl enc -d -aes-256-cbc -in Testo.txt.enc -out Testo.txt -pass file:secret.txt<\/cite><\/blockquote>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ciao, di seguito un semplice esempio di come utilizzare le curve ellittiche tramite il classico strumento openssl e i nostri classici amici Alice e Bob. Alice e Bob generano le proprie chiavi pubbliche e private ti tipo ellittico Creazione Chiavi Alice: openssl genpkey -algorithm \u00a0X25519 -out alice_privkey.pem openssl pkey -in alice_privkey.pem -pubout -out alice_pubkey.pem Bob: &hellip; <a href=\"https:\/\/www.summonte.com\/home\/2019_02_25-curve-ellittiche-in-pratica\/\" class=\"more-link\">Continua la lettura di <span class=\"screen-reader-text\">Curve Ellittiche in pratica<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-160","post","type-post","status-publish","format-standard","hentry","category-senza-categoria"],"_links":{"self":[{"href":"https:\/\/www.summonte.com\/home\/wp-json\/wp\/v2\/posts\/160","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.summonte.com\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.summonte.com\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.summonte.com\/home\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.summonte.com\/home\/wp-json\/wp\/v2\/comments?post=160"}],"version-history":[{"count":1,"href":"https:\/\/www.summonte.com\/home\/wp-json\/wp\/v2\/posts\/160\/revisions"}],"predecessor-version":[{"id":161,"href":"https:\/\/www.summonte.com\/home\/wp-json\/wp\/v2\/posts\/160\/revisions\/161"}],"wp:attachment":[{"href":"https:\/\/www.summonte.com\/home\/wp-json\/wp\/v2\/media?parent=160"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.summonte.com\/home\/wp-json\/wp\/v2\/categories?post=160"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.summonte.com\/home\/wp-json\/wp\/v2\/tags?post=160"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}