{"id":119,"date":"2005-04-18T02:31:49","date_gmt":"2005-04-17T23:31:49","guid":{"rendered":"https:\/\/void.gr\/kargig\/blog\/2005\/04\/18\/usb-key-encryption-frenzy\/"},"modified":"2006-10-11T22:27:45","modified_gmt":"2006-10-11T19:27:45","slug":"usb-key-encryption-frenzy","status":"publish","type":"post","link":"https:\/\/www.void.gr\/kargig\/blog\/2005\/04\/18\/usb-key-encryption-frenzy\/","title":{"rendered":"Usb key encryption frenzy, loopfile encryption"},"content":{"rendered":"<p>It&#8217;s time for something more serious now, time to play with encrypted partitions and loop devices storing the keys on the usb key.<\/p>\n<p>Following the excellent <a href=\"http:\/\/loop-aes.sourceforge.net\/loop-AES.README\">loop-AES.README<\/a> I created an encrypted loop file that is encrypted with some random keys which are stored inside a file&#8230;and that file is encrypted with gpg and stored inside my usb stick. Confused ? Here it goes&#8230;<\/p>\n<p>&#8220;Create 65 random encryption keys and encrypt those keys using gpg.&#8221;<br \/>\n<code># head -c 2925 \/dev\/urandom | uuencode -m - | head -n 66 | tail -n 65| gpg --symmetric -a >\/mnt\/usb-key\/keyfile.gpg<\/code><\/p>\n<p>Time for the loop file creation. An example of a 100Mb file follows:<br \/>\n<code>#  dd if=\/dev\/urandom of=\/my-encrypted-loop.aes bs=1k count=100000<\/code><\/p>\n<p>Then encrypt the loop file using our previously generated keys. From losetup man page:<\/p>\n<blockquote><p>      -K gpgkey<br \/>\n              Password  is piped to gpg so that gpg can decrypt file gpgkey which<br \/>\n              contains the real keys that are used to  encrypt  loop  device.  If<br \/>\n              decryption  requires  public\/private keys and gpghome is not speci-<br \/>\n              fied, all users use their own gpg public\/private  keys  to  decrypt<br \/>\n              gpgkey.  Decrypted  gpgkey  should contain 1 or 64 or 65 keys, each<br \/>\n              key at least 20 characters and separated by newline.  If  decrypted<br \/>\n              gpgkey contains 64 or 65 keys, then loop device is put to multi-key<br \/>\n              mode. In multi-key mode first key is used for first sector,  second<br \/>\n              key for second sector, and so on.  65th key, if present, is used as<br \/>\n              additional input to MD5 IV computation.\n<\/p><\/blockquote>\n<p>So&#8230;<br \/>\n<code># losetup -K \/mnt\/usb\/keyfile.gpg -e AES256 \/dev\/loop3 \/home\/kargig\/mytest<br \/>\n# losetup -d \/dev\/loop3<br \/>\n<\/code><\/p>\n<p>Now add this to \/etc\/fstab:<br \/>\n<code>\/my-encrypted-loop.aes \/mnt\/private ext3 defaults,noauto,user,loop=\/dev\/loop3,encryption=AES256,gpgkey=\/mnt\/usb-key\/keyfile.gpg 0 0<br \/>\n<\/code><\/p>\n<p>now try this in order to check if the fstab entry is working and to format the loopfile:<br \/>\n<code># losetup -F \/dev\/loop3<br \/>\n# mke2fs -j \/dev\/loop3<br \/>\n# losetup -d \/dev\/loop3<br \/>\n<\/code><\/p>\n<p>If everything is fine&#8230;you can just try this:<\/p>\n<p><code>mount \/mnt\/private<\/code><\/p>\n<p>And you should be asked for your gpg passphrase \ud83d\ude42 If you don&#8217;t have your usb key mounted, the loop file(or partition) won&#8217;t be mountable. BACKUP your keyfile.gpg!!!<\/p>\n<p>What if you want to change your password ? Simply do this to decrypt the gpg file and re-encrypt it with a new password:<br \/>\n<code># gpg -d \/mnt\/usb-key\/keyfile.gpg  > \/mnt\/usb-key\/clearkeys.txt<br \/>\n# cat \/mnt\/usb-key\/clearkeys.txt | gpg --symmetric -a  > \/mnt\/usb-key\/newkeyfile.gpg<br \/>\n(now make sure the keyfile.gpg and newkeyfile.gpg differs, if yes it means that the gpg password was changed...move on)<br \/>\n# mv \/mnt\/usb-key\/newkeyfile.gpg \/mnt\/usb-key\/keyfile.gpg<br \/>\n# rm -f \/mnt\/usb-key\/clearkeys.txt<br \/>\n<\/code><br \/>\n(thanks to metown for pointing at some errors at the previous post)<\/p>\n<p>What&#8217;s left to be done now is make it work like the pam_usb module, ie create a set of scripts(or programs?) so that when I want to mount the encrypted partition it will automatically check the usb key to find a private key to check it against the &#8220;partition&#8217;s public key&#8221; so there won&#8217;t be a need for typing a passphrase. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s time for something more serious now, time to play with encrypted partitions and loop devices storing the keys on the usb key. Following the excellent loop-AES.README I created an encrypted loop file that is encrypted with some random keys which are stored inside a file&#8230;and that file is encrypted with gpg and stored inside [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ep_exclude_from_search":false,"footnotes":""},"categories":[1,3],"tags":[],"class_list":["post-119","post","type-post","status-publish","format-standard","hentry","category-general","category-linux"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.3 - aioseo.com -->\n\t<meta name=\"description\" content=\"It&#039;s time for something more serious now, time to play with encrypted partitions and loop devices storing the keys on the usb key. Following the excellent loop-AES.README I created an encrypted loop file that is encrypted with some random keys which are stored inside a file...and that file is encrypted with gpg and stored inside\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"kargig\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/www.void.gr\/kargig\/blog\/2005\/04\/18\/usb-key-encryption-frenzy\/\" \/>\n\t\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.3\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.void.gr\\\/kargig\\\/blog\\\/2005\\\/04\\\/18\\\/usb-key-encryption-frenzy\\\/#article\",\"name\":\"Usb key encryption frenzy, loopfile encryption | Into.the.Void.\",\"headline\":\"Usb key encryption frenzy, loopfile encryption\",\"author\":{\"@id\":\"https:\\\/\\\/www.void.gr\\\/kargig\\\/blog\\\/author\\\/site-admin\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.void.gr\\\/kargig\\\/blog\\\/#organization\"},\"datePublished\":\"2005-04-18T02:31:49+03:00\",\"dateModified\":\"2006-10-11T22:27:45+03:00\",\"inLanguage\":\"en-US\",\"commentCount\":6,\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.void.gr\\\/kargig\\\/blog\\\/2005\\\/04\\\/18\\\/usb-key-encryption-frenzy\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.void.gr\\\/kargig\\\/blog\\\/2005\\\/04\\\/18\\\/usb-key-encryption-frenzy\\\/#webpage\"},\"articleSection\":\"General, Linux\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.void.gr\\\/kargig\\\/blog\\\/2005\\\/04\\\/18\\\/usb-key-encryption-frenzy\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.void.gr\\\/kargig\\\/blog\\\/#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.void.gr\\\/kargig\\\/blog\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.void.gr\\\/kargig\\\/blog\\\/category\\\/general\\\/#listItem\",\"name\":\"General\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.void.gr\\\/kargig\\\/blog\\\/category\\\/general\\\/#listItem\",\"position\":2,\"name\":\"General\",\"item\":\"https:\\\/\\\/www.void.gr\\\/kargig\\\/blog\\\/category\\\/general\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.void.gr\\\/kargig\\\/blog\\\/2005\\\/04\\\/18\\\/usb-key-encryption-frenzy\\\/#listItem\",\"name\":\"Usb key encryption frenzy, loopfile encryption\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.void.gr\\\/kargig\\\/blog\\\/#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.void.gr\\\/kargig\\\/blog\\\/2005\\\/04\\\/18\\\/usb-key-encryption-frenzy\\\/#listItem\",\"position\":3,\"name\":\"Usb key encryption frenzy, loopfile encryption\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.void.gr\\\/kargig\\\/blog\\\/category\\\/general\\\/#listItem\",\"name\":\"General\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.void.gr\\\/kargig\\\/blog\\\/#organization\",\"name\":\"Into.the.Void.\",\"description\":\"Into The Void\",\"url\":\"https:\\\/\\\/www.void.gr\\\/kargig\\\/blog\\\/\",\"sameAs\":[\"https:\\\/\\\/x.com\\\/kargig\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.void.gr\\\/kargig\\\/blog\\\/author\\\/site-admin\\\/#author\",\"url\":\"https:\\\/\\\/www.void.gr\\\/kargig\\\/blog\\\/author\\\/site-admin\\\/\",\"name\":\"kargig\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.void.gr\\\/kargig\\\/blog\\\/2005\\\/04\\\/18\\\/usb-key-encryption-frenzy\\\/#webpage\",\"url\":\"https:\\\/\\\/www.void.gr\\\/kargig\\\/blog\\\/2005\\\/04\\\/18\\\/usb-key-encryption-frenzy\\\/\",\"name\":\"Usb key encryption frenzy, loopfile encryption | Into.the.Void.\",\"description\":\"It's time for something more serious now, time to play with encrypted partitions and loop devices storing the keys on the usb key. Following the excellent loop-AES.README I created an encrypted loop file that is encrypted with some random keys which are stored inside a file...and that file is encrypted with gpg and stored inside\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.void.gr\\\/kargig\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.void.gr\\\/kargig\\\/blog\\\/2005\\\/04\\\/18\\\/usb-key-encryption-frenzy\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.void.gr\\\/kargig\\\/blog\\\/author\\\/site-admin\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.void.gr\\\/kargig\\\/blog\\\/author\\\/site-admin\\\/#author\"},\"datePublished\":\"2005-04-18T02:31:49+03:00\",\"dateModified\":\"2006-10-11T22:27:45+03:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.void.gr\\\/kargig\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.void.gr\\\/kargig\\\/blog\\\/\",\"name\":\"Into.the.Void.\",\"description\":\"Into The Void\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.void.gr\\\/kargig\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Usb key encryption frenzy, loopfile encryption | Into.the.Void.","description":"It's time for something more serious now, time to play with encrypted partitions and loop devices storing the keys on the usb key. Following the excellent loop-AES.README I created an encrypted loop file that is encrypted with some random keys which are stored inside a file...and that file is encrypted with gpg and stored inside","canonical_url":"https:\/\/www.void.gr\/kargig\/blog\/2005\/04\/18\/usb-key-encryption-frenzy\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.void.gr\/kargig\/blog\/2005\/04\/18\/usb-key-encryption-frenzy\/#article","name":"Usb key encryption frenzy, loopfile encryption | Into.the.Void.","headline":"Usb key encryption frenzy, loopfile encryption","author":{"@id":"https:\/\/www.void.gr\/kargig\/blog\/author\/site-admin\/#author"},"publisher":{"@id":"https:\/\/www.void.gr\/kargig\/blog\/#organization"},"datePublished":"2005-04-18T02:31:49+03:00","dateModified":"2006-10-11T22:27:45+03:00","inLanguage":"en-US","commentCount":6,"mainEntityOfPage":{"@id":"https:\/\/www.void.gr\/kargig\/blog\/2005\/04\/18\/usb-key-encryption-frenzy\/#webpage"},"isPartOf":{"@id":"https:\/\/www.void.gr\/kargig\/blog\/2005\/04\/18\/usb-key-encryption-frenzy\/#webpage"},"articleSection":"General, Linux"},{"@type":"BreadcrumbList","@id":"https:\/\/www.void.gr\/kargig\/blog\/2005\/04\/18\/usb-key-encryption-frenzy\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/www.void.gr\/kargig\/blog\/#listItem","position":1,"name":"Home","item":"https:\/\/www.void.gr\/kargig\/blog\/","nextItem":{"@type":"ListItem","@id":"https:\/\/www.void.gr\/kargig\/blog\/category\/general\/#listItem","name":"General"}},{"@type":"ListItem","@id":"https:\/\/www.void.gr\/kargig\/blog\/category\/general\/#listItem","position":2,"name":"General","item":"https:\/\/www.void.gr\/kargig\/blog\/category\/general\/","nextItem":{"@type":"ListItem","@id":"https:\/\/www.void.gr\/kargig\/blog\/2005\/04\/18\/usb-key-encryption-frenzy\/#listItem","name":"Usb key encryption frenzy, loopfile encryption"},"previousItem":{"@type":"ListItem","@id":"https:\/\/www.void.gr\/kargig\/blog\/#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/www.void.gr\/kargig\/blog\/2005\/04\/18\/usb-key-encryption-frenzy\/#listItem","position":3,"name":"Usb key encryption frenzy, loopfile encryption","previousItem":{"@type":"ListItem","@id":"https:\/\/www.void.gr\/kargig\/blog\/category\/general\/#listItem","name":"General"}}]},{"@type":"Organization","@id":"https:\/\/www.void.gr\/kargig\/blog\/#organization","name":"Into.the.Void.","description":"Into The Void","url":"https:\/\/www.void.gr\/kargig\/blog\/","sameAs":["https:\/\/x.com\/kargig"]},{"@type":"Person","@id":"https:\/\/www.void.gr\/kargig\/blog\/author\/site-admin\/#author","url":"https:\/\/www.void.gr\/kargig\/blog\/author\/site-admin\/","name":"kargig"},{"@type":"WebPage","@id":"https:\/\/www.void.gr\/kargig\/blog\/2005\/04\/18\/usb-key-encryption-frenzy\/#webpage","url":"https:\/\/www.void.gr\/kargig\/blog\/2005\/04\/18\/usb-key-encryption-frenzy\/","name":"Usb key encryption frenzy, loopfile encryption | Into.the.Void.","description":"It's time for something more serious now, time to play with encrypted partitions and loop devices storing the keys on the usb key. Following the excellent loop-AES.README I created an encrypted loop file that is encrypted with some random keys which are stored inside a file...and that file is encrypted with gpg and stored inside","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/www.void.gr\/kargig\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/www.void.gr\/kargig\/blog\/2005\/04\/18\/usb-key-encryption-frenzy\/#breadcrumblist"},"author":{"@id":"https:\/\/www.void.gr\/kargig\/blog\/author\/site-admin\/#author"},"creator":{"@id":"https:\/\/www.void.gr\/kargig\/blog\/author\/site-admin\/#author"},"datePublished":"2005-04-18T02:31:49+03:00","dateModified":"2006-10-11T22:27:45+03:00"},{"@type":"WebSite","@id":"https:\/\/www.void.gr\/kargig\/blog\/#website","url":"https:\/\/www.void.gr\/kargig\/blog\/","name":"Into.the.Void.","description":"Into The Void","inLanguage":"en-US","publisher":{"@id":"https:\/\/www.void.gr\/kargig\/blog\/#organization"}}]}},"aioseo_meta_data":{"post_id":"119","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"created":"2022-01-04 12:02:20","updated":"2026-10-21 09:07:52","focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.void.gr\/kargig\/blog\/\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.void.gr\/kargig\/blog\/category\/general\/\" title=\"General\">General<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tUsb key encryption frenzy, loopfile encryption\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/www.void.gr\/kargig\/blog\/"},{"label":"General","link":"https:\/\/www.void.gr\/kargig\/blog\/category\/general\/"},{"label":"Usb key encryption frenzy, loopfile encryption","link":"https:\/\/www.void.gr\/kargig\/blog\/2005\/04\/18\/usb-key-encryption-frenzy\/"}],"views":5514,"_links":{"self":[{"href":"https:\/\/www.void.gr\/kargig\/blog\/wp-json\/wp\/v2\/posts\/119","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.void.gr\/kargig\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.void.gr\/kargig\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.void.gr\/kargig\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.void.gr\/kargig\/blog\/wp-json\/wp\/v2\/comments?post=119"}],"version-history":[{"count":0,"href":"https:\/\/www.void.gr\/kargig\/blog\/wp-json\/wp\/v2\/posts\/119\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.void.gr\/kargig\/blog\/wp-json\/wp\/v2\/media?parent=119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.void.gr\/kargig\/blog\/wp-json\/wp\/v2\/categories?post=119"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.void.gr\/kargig\/blog\/wp-json\/wp\/v2\/tags?post=119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}