<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Cobra's bits (Posts about encryption)</title><link>https://cobra.pdes-net.org</link><description></description><atom:link href="https://cobra.pdes-net.org/categories/encryption.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><copyright>Contents © 2024 &lt;a href="mailto:najahannah@gmail.com"&gt;Cobra&lt;/a&gt; 
&lt;a rel="license" href="https://creativecommons.org/licenses/by-nc-sa/4.0/"&gt;
&lt;img alt="Creative Commons License BY-NC-SA"
style="border-width:0; margin-bottom:12px;"
src="../images/by-nc-sa.svg"&gt;&lt;/a&gt;</copyright><lastBuildDate>Mon, 30 Dec 2024 14:50:43 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Let's not encrypt?</title><link>https://cobra.pdes-net.org/posts/lets-not-encrypt.html</link><dc:creator>Cobra</dc:creator><description>&lt;p&gt;This blog is powered by &lt;a class="reference external" href="https://cobra.pdes-net.org/posts/new-server.html"&gt;Hiawatha&lt;/a&gt;, a &lt;a class="reference external" href="https://hiawatha.leisink.net/about/"&gt;light-weight webserver designed for security and ease of use&lt;/a&gt;. Consequently, Hiawatha comes with a script that allows one to easily request certificates from the Let's Encrypt initiative and (in conjunction with a daily cron job) to automagically renew them when the time has come.&lt;/p&gt;
&lt;p&gt;This setup has worked almost flawlessly &lt;a class="reference external" href="https://cobra.pdes-net.org/posts/lets-encrypt.html"&gt;for several years&lt;/a&gt;. In 2021, I've received an information from Let's Encrypt that they would modify (as planned) their chain of trust, requiring corresponding changes in the LE_ISSUERS option in the configuration file of the script designated for requesting or renewing certificates.&lt;/p&gt;
&lt;p&gt;I should have known that this change will happen every three years, but since I didn't receive any mail this time, it never occurred to me that the failure of renewal had this simple reason. Instead, I've searched everywhere for nonexisting error messages until I had run out of ideas. Without any options left, I've asked &lt;a class="reference external" href="https://haui.pdes-net.org/"&gt;Haui&lt;/a&gt; for help, convinced that he would see light where I could see only dark. And it indeed didn't take him long to identify an outdated LE_ISSUERS value in the configuration file as the culprit.&lt;/p&gt;
&lt;p&gt;We can easily look up the common name of the current certificate's issuer:&lt;/p&gt;
&lt;pre class="literal-block"&gt;openssl x509 -in /etc/hiawatha/tls/pdes-net.org.pem -noout -text | grep CN&lt;/pre&gt;
&lt;p&gt;But that won't help if the current certificate is not renewed because of an outdated issuer. The present situation was different in that I've requested new certificates in September as a temporary (HOHOHO) workaround. These new certificates were issued with the new CN of R10, as compared to the old R3 in the configuration file, making it clear that the latter is outdated. It would have been so easy if I hadn't been such a fool and categorically ruled out this possibility. 🫥&lt;/p&gt;
&lt;p&gt;Well, I may get old and useless, but I hope to recall once and for all that the authoritative instance for looking up the current issuer for Let's Encrypt can be found here: &lt;a class="reference external" href="https://letsencrypt.org/certificates/"&gt;https://letsencrypt.org/certificates/&lt;/a&gt;. And if I don't, I'm sure to remember that I can find this information in my own blog. 🫩&lt;/p&gt;</description><category>debian</category><category>encryption</category><category>linux</category><guid>https://cobra.pdes-net.org/posts/lets-not-encrypt.html</guid><pubDate>Mon, 30 Dec 2024 14:24:34 GMT</pubDate></item><item><title>Digital signatures</title><link>https://cobra.pdes-net.org/posts/digital-signatures.html</link><dc:creator>Cobra</dc:creator><description>&lt;p&gt;Our administration now requests all documents to be digitally signed, with a certificate that each employee receives from the DFN. Windows and Mac users employ Acrobat Reader for this purpose, but what software can be used under Linux?&lt;/p&gt;
&lt;p&gt;My first choice was &lt;a class="reference external" href="https://help.libreoffice.org/6.1/he/text/shared/guide/digitalsign_send.html?DbPAR=SHARED"&gt;LibreOffice&lt;/a&gt;, which has offered this functionality already for several years. Signing a pristine pdf works well indeed, apart from the fact that LibeOffice does not create a placeholder for the signature. However, signing a document that has already been signed by Window users turned out to be simply not possible (&lt;a class="reference external" href="https://bugs.documentfoundation.org/show_bug.cgi?id=58442"&gt;here's the 12 years old bug report&lt;/a&gt; – &lt;a class="reference external" href="https://bugs.documentfoundation.org/show_bug.cgi?id=58476"&gt;and here's the inverse one that is just as old&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;The next candidate was &lt;a class="reference external" href="https://faq.tickets.tu-dresden.de/otrs/public.pl?Action=PublicFAQZoom;ItemID=620"&gt;Okular&lt;/a&gt;, the PDF viewer of KDE, which has been &lt;a class="reference external" href="https://datashare.tu-dresden.de/index.php/s/j5BKKyJYZFBzGsB?dir=undefined&amp;amp;openfile=7555731"&gt;sponsored by the University of Dresden to implement this functionality&lt;/a&gt;. But only half-way, it seems to me. I could sign most (but not all) documents, but I couldn't configure the placeholder at all. As the font size in the signature box does not scale with the size of the box, the name of the person signing is often cut off. How difficult can it be to implement such a very basic and obvious requirement?&lt;/p&gt;
&lt;p&gt;Finally, I turned to &lt;a class="reference external" href="https://code-industry.net/masterpdfeditor-help/digital_signatures/"&gt;Master PDF Editor&lt;/a&gt;, which I've occasionally used in the past for annotations when Evince did not yet offer this possibility. I was actually not surprised that this feature-rich PDF editor also offers digital signatures, but I was pleased that the software comes with its own certificate storage and that the signature placeholder is highly configurable. For example, one can configure the placeholder to include one's own analogue signature as a background.&lt;/p&gt;
&lt;p&gt;Alas, using the Master PDF editor without any restrictions requires purchasing a license. The free version is unlimited, but leaves a watermark in documents that have been digitally signed or otherwise altered with the software. The licence is very fairly priced, but as the software is developed in Russia, even asking for one is frowned upon and politically inopportune. Fortunately, nobody has yet complained about the watermark in documents I have  digitally signed. 😈&lt;/p&gt;</description><category>encryption</category><category>linux</category><guid>https://cobra.pdes-net.org/posts/digital-signatures.html</guid><pubDate>Wed, 01 May 2024 12:12:11 GMT</pubDate></item><item><title>A new VPN</title><link>https://cobra.pdes-net.org/posts/a-new-vpn.html</link><dc:creator>Cobra</dc:creator><description>&lt;p&gt;The institute I'm with has offered a VPN solution for its employees for about 15 years. Well, at least for the Windows users of our staff. The Cisco we've used in the first years came with the abysmal 'vpnclient', which I've said one time to be a &lt;a class="reference external" href="https://cobra.pdes-net.org/posts/vpn-how-to-complicate-your-life.html"&gt;clear winner of the worst-software-on-this-planet contest&lt;/a&gt;. It would run only on CentOS and Debian OldStable (meaning Sarge at that time!), and there was no way to get it running in any reliable way on a halfway modern Linux. I've thus ended up by connecting to the VPN via a virtual Windows XP, until I discovered &lt;a class="reference external" href="https://cobra.pdes-net.org/posts/goodbye-windows.html"&gt;openconnect&lt;/a&gt;, which worked perfectly on modern Linux distributions. Still, I was delighted when we finally kicked out the Cisco and got a Checkpoint instead, only to learn that the promised Linux client was still in development. It actually never materialized, but I was content with the browser-based solution they offered. Now the Checkpoint license has expired, and instead of renewing the contract, we've gotten ourselves a Palo Alto firewall – much to my surprise, as Palo Alto is not known for being a bargain. But in any case, we now – after 15 years – have a VPN client that can be installed on a fully updated Arch system and actually works.&lt;/p&gt;
&lt;p&gt;Jonas, a fellow Archer and colleague of mine, figured out the best way how to install the client. I'm' adding his instructions here so I find them when the next version is released. 😄&lt;/p&gt;
&lt;blockquote&gt;
&lt;ol class="arabic simple"&gt;
&lt;li&gt;&lt;p&gt;Install the AUR package 'globalprotect-bin' (which will fail, but gets the necessary 'PKGBUILD' file and 'globalprotect.install' script).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;From /software/VPN/VPN_Client_GlobalProtect get the latest version of the archive with the client binaries for Linux: 'PanGPLinux-u.v.w-...tgz'. From this archive, you only need the files 'GlobalProtect_tar-u.v.w.x-yz.tgz' and 'GlobalProtect_UI_tar-u.v.w.x-yz.tgz'.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Place the two files in the AUR build-folder, e.g. '.cache/yay/globalprotect-bin/'&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Check that in PKGBUILD the correct 'pkgver' (u.v.w.x) and 'pkgrel' (yz) are set. If you need to change these, you also need to adapt the 'sha256sums'.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Run &lt;cite&gt;makepkg -si&lt;/cite&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Start &lt;cite&gt;gpd.service&lt;/cite&gt; using &lt;cite&gt;systemctl enable --now gpd.service&lt;/cite&gt; (check status with &lt;cite&gt;systemctl status gpd&lt;/cite&gt;) and restart the system.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Import the certificate (I had to use an absolute path): &lt;cite&gt;globalprotect import-certificate --location /home/user/...&lt;/cite&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;To update the client to a new version, you need to repeat steps 2–5 and restart the system.&lt;/p&gt;
&lt;p&gt;Now you are ready and you can&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;p&gt;Start the connection using &lt;cite&gt;globalprotect connect --portal vpn.foo.bar.de&lt;/cite&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Disconnect using &lt;cite&gt;globalprotect disconnect&lt;/cite&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Alternatively, run the gui (which then appears in the system tray) using: &lt;cite&gt;globalprotect launch-ui&lt;/cite&gt; and use the connect/disconnect button&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;p&gt;I have little to add to these instructions. I don't recommend the GUI: it is outdated and does not work in a high-dpi environment such as my notebook. But that's fine with me; I like the CLI better anyway. Following my habits, I've just defined aliases for the two commands most frequently used:&lt;/p&gt;
&lt;pre class="literal-block"&gt;alias vpnon='globalprotect connect --portal vpn.foo.bar.de'
alias vpnoff='globalprotect disconnect'&lt;/pre&gt;
&lt;p&gt;Perhaps I will install a minimal virtual Linux guest to run the client and to connect, while still being able to use my other connections in the host system. I'll post an update if I do that. 🤠&lt;/p&gt;</description><category>archlinux</category><category>encryption</category><category>web</category><guid>https://cobra.pdes-net.org/posts/a-new-vpn.html</guid><pubDate>Sun, 21 May 2023 14:32:31 GMT</pubDate></item><item><title>Keep Alive</title><link>https://cobra.pdes-net.org/posts/keep-alive.html</link><dc:creator>Cobra</dc:creator><description>&lt;p&gt;I'm so much used to &lt;a class="reference external" href="https://cobra.pdes-net.org/posts/working-on-the-command-line.html"&gt;mosh&lt;/a&gt; that I'm always surprised by how fast a plain ssh connection runs into a timeout. Or worse into a kind of half-terminated hanging connection with an apparently unresponsive terminal.&lt;/p&gt;
&lt;p&gt;Which is weird, since there's already one measure in place that is intended to avoid this situation: TCPKeepAlive, which is enabled by default. To quote the man page of sshd_config:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;On the other hand, if TCP keepalives are not sent, sessions may hang indefinitely on the server, leaving "ghost" users and consuming server resources. The default is yes (to send TCP keepalive messages), and the server will  notice if the network goes down or the client host crashes.  This avoids infinitely hanging sessions.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;What irritates users most in this situation is the unresponsive terminal, which seems to no longer accept any commands, and won't close unless the ssh connection is terminated by killing the process. But there's no need to kill, as ssh offers several escape sequences that also take care of this case:&lt;/p&gt;
&lt;pre class="literal-block"&gt; ~.  - terminate connection (and any multiplexed sessions)
 ~B  - send a BREAK to the remote system
 ~C  - open a command line
 ~R  - Request rekey (SSH protocol 2 only)
 ~^Z - suspend ssh
 ~#  - list forwarded connections
 ~&amp;amp;  - background ssh (when waiting for connections to terminate)
 ~?  - this message
 ~~  - send the escape character by typing it twice
(Note that escapes are only recognized immediately after newline.)&lt;/pre&gt;
&lt;p&gt;To prevent this thing to ever happen again, two options can be set either on the server or the client.&lt;/p&gt;
&lt;p&gt;On the server side, one can set the following options in /etc/ssh/sshd_config:&lt;/p&gt;
&lt;pre class="literal-block"&gt;TCPKeepAlive no (default yes)
ClientAliveInterval 30
ClientAliveCountMax 240&lt;/pre&gt;
&lt;p&gt;To quote again the man page of sshd_config:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;ClientAliveInterval
Sets a timeout interval in seconds after which if no data has been received from the client, sshd(8) will send a message through the encrypted channel to request a response from the client. The default is 0, indicating that these messages will not be sent to the client.&lt;/p&gt;
&lt;p&gt;ClientAliveCountMax
Sets the number of client alive messages which may be sent without sshd(8) receiving any messages back from the client.  If this threshold is reached while client alive messages are being sent, sshd will disconnect the client, terminating the session. The default value is 3. If ClientAliveInterval is set to 15, and ClientAliveCountMax is left at the default, unresponsive SSH clients will be disconnected after approximately 45 seconds.  Setting a zero ClientAliveCountMax disables connection termination.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;On the client side, corresponding options exist in etc/ssh/ssh_config, but changing them occurs better on a per-user basis in ~/.ssh/config (instead of adding them manually to each connecting &lt;code class="docutils literal"&gt;ssh&lt;/code&gt; call via the &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;-o&lt;/span&gt;&lt;/code&gt; command-line parameter):&lt;/p&gt;
&lt;pre class="literal-block"&gt;TCPKeepAlive no (default yes)
ServerAliveInterval 30
ServerAliveCountMax 240&lt;/pre&gt;
&lt;p&gt;The meaning is the same as above, but the roles are reversed: now, the client sends an alive message to the server every 30 s, and the client drops the connection if it didn't receive an answer from the server within 2 hours.&lt;/p&gt;</description><category>encryption</category><category>linux</category><guid>https://cobra.pdes-net.org/posts/keep-alive.html</guid><pubDate>Thu, 10 Dec 2020 14:22:07 GMT</pubDate></item><item><title>Goldilocks</title><link>https://cobra.pdes-net.org/posts/goldilocks.html</link><dc:creator>Cobra</dc:creator><description>&lt;p&gt;For our webserver, the &lt;code class="docutils literal"&gt;lefh&lt;/code&gt; script provided by Hiawatha, which I run daily via a cron job, guarantees that the certificates for the transport encryption are renewed prior to their expiration. For our &lt;a class="reference external" href="https://cobra.pdes-net.org/posts/inspircd-3.html"&gt;IRC server&lt;/a&gt;, in contrast, I have to do that manually. That might seem like a nuisance, but on the other hand, it gives me the chance to review the current state-of-the-art regarding transport encryption and to bring my configuration to this level. I've previously used &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Curve25519"&gt;ed25519&lt;/a&gt; (which I also choose when generating SSH keys), but &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Curve448"&gt;ed448&lt;/a&gt; seems an even &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Goldilocks_principle"&gt;better choice&lt;/a&gt;.&lt;/p&gt;
&lt;pre class="literal-block"&gt;certtool --generate-privkey --key-type ed448 --sec-param ultra --outfile key.pem
certtool --generate-self-signed --load-privkey key.pem --template cert.cfg --outfile cert.pem
certtool --get-dh-params --sec-param ultra --outfile dhparams.pem&lt;/pre&gt;</description><category>encryption</category><category>linux</category><category>web</category><guid>https://cobra.pdes-net.org/posts/goldilocks.html</guid><pubDate>Sun, 04 Oct 2020 16:00:37 GMT</pubDate></item><item><title>InspIRCd 3</title><link>https://cobra.pdes-net.org/posts/inspircd-3.html</link><dc:creator>Cobra</dc:creator><description>&lt;p&gt;All of a sudden, the PdeS IRC channel wasn't working anymore. As inexplicable as this sudden disruption first appeared to be, as obvious are the reasons in hindsight. What has happened?&lt;/p&gt;
&lt;p&gt;At August 18, apt offered an InspIRCd update, dutifully asking whether I wanted to keep the configuration files. I didn't realize at this moment that the update was in fact the upgrade from version 2 to 3 I had been waiting for since May. As a matter of fact, this update is &lt;a class="reference external" href="https://docs.inspircd.org/3/configuration-changes/"&gt;disruptive&lt;/a&gt; and requires one to carefully review and modify the configuration of InspIRCd. Well, I failed to do that, and I also failed to notice that the InspIRCd service didn't restart after the update.&lt;/p&gt;
&lt;p&gt;Sometimes people jokingly remark that I should work as a system or network admin rather than as a scientist. This incident shows that I'm not qualified for such a job. I'm way too careless.&lt;/p&gt;
&lt;p&gt;In any case, I now had to find the reason for the InspIRCd service to quit. It wasn't too difficult, but a multi-step procedure. The first obstacle was an outdated apparmor profile, which allowed InspIRCd to write in /run, but not in /run/inspircd. That was easily fixed.&lt;/p&gt;
&lt;p&gt;The second was the TLS configuration of our channel. I took the opportunity to renew our certificate and to altogether strengthen the security of the channel, but it took me a while to realize that the identifier in the bind_ssl and sslprofile_name tags has to be one and the same (it isn't in the documentation!).&lt;/p&gt;
&lt;pre class="literal-block"&gt;&amp;lt;bind
          address=""
          port="6697"
          type="clients"
          ssl="pdes"&amp;gt;

&amp;lt;module name="ssl_gnutls"&amp;gt;

&amp;lt;sslprofile
          name="pdes"
          provider="gnutls"
          certfile="cert/cert.pem"
          keyfile="cert/key.pem"
          dhfile="cert/dhparams.pem"
          mindhbits="4096"
          outrecsize="4096"
          hash="sha512"
          requestclientcert="no"
          priority="PFS:+SECURE256:+SECURE128:-VERS-ALL:+VERS-TLS1.3"&amp;gt;&lt;/pre&gt;
&lt;p&gt;Well, the channel is up again, more secure than ever. Fire away. 😅&lt;/p&gt;</description><category>encryption</category><category>info</category><category>web</category><guid>https://cobra.pdes-net.org/posts/inspircd-3.html</guid><pubDate>Sun, 25 Aug 2019 09:43:40 GMT</pubDate></item><item><title>Functions with default values</title><link>https://cobra.pdes-net.org/posts/functions-with-default-values.html</link><dc:creator>Cobra</dc:creator><description>&lt;p&gt;Suppose you would like to have a command generating a secure password for an online service at the command line. You would google for that and find &lt;a class="reference external" href="http://www.howtogeek.com/howto/30184/10-ways-to-generate-a-random-password-from-the-command-line/"&gt;10 ways to generate a random password.&lt;/a&gt; At the end of his article, the author presents the ideal way to generate a secure password:&lt;/p&gt;
&lt;pre class="literal-block"&gt;date | md5sum&lt;/pre&gt;
&lt;p&gt;The author of the article (Lowell Heddings, the founder and CEO of How-To Geek) states:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;I’m sure that some people will complain that it’s not as random as some of the other options, but honestly, it’s random enough if you’re going to be using the whole thing.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Random enough? Sure, the 'whole thing' looks random enough:&lt;/p&gt;
&lt;pre class="literal-block"&gt;9ec463af3db95e8e44de84417d9f408f&lt;/pre&gt;
&lt;p&gt;but the look is deceptive: this is in fact an extremely weak password. To understand why, let's look at the output of the 'date' command:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code bash"&gt;&lt;a id="rest_code_950f188c3c8c4ea69de1f6e2c65f483f-1" name="rest_code_950f188c3c8c4ea69de1f6e2c65f483f-1" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_950f188c3c8c4ea69de1f6e2c65f483f-1"&gt;&lt;/a&gt;↪&lt;span class="w"&gt; &lt;/span&gt;date
&lt;a id="rest_code_950f188c3c8c4ea69de1f6e2c65f483f-2" name="rest_code_950f188c3c8c4ea69de1f6e2c65f483f-2" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_950f188c3c8c4ea69de1f6e2c65f483f-2"&gt;&lt;/a&gt;Sun&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;12&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;May&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;2019&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;04&lt;/span&gt;:33:26&lt;span class="w"&gt; &lt;/span&gt;PM&lt;span class="w"&gt; &lt;/span&gt;CEST
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;We see that without additional parameter (like +"%N"), 'date' gives us one password for each second of the year. How many passwords do we get in this way? Well,&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code bash"&gt;&lt;a id="rest_code_7dfcd06833ab4f779d09395d4632245e-1" name="rest_code_7dfcd06833ab4f779d09395d4632245e-1" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_7dfcd06833ab4f779d09395d4632245e-1"&gt;&lt;/a&gt;&lt;span class="w"&gt; &lt;/span&gt;↪&lt;span class="w"&gt; &lt;/span&gt;date&lt;span class="w"&gt; &lt;/span&gt;+&lt;span class="s2"&gt;"%s"&lt;/span&gt;
&lt;a id="rest_code_7dfcd06833ab4f779d09395d4632245e-2" name="rest_code_7dfcd06833ab4f779d09395d4632245e-2" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_7dfcd06833ab4f779d09395d4632245e-2"&gt;&lt;/a&gt;&lt;span class="m"&gt;1557666649&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;i.e., 1,557,666,649 seconds has passed since 00:00:00, Jan 1, 1970 (&lt;a class="reference external" href="https://en.wikipedia.org/wiki/Unix_time"&gt;Unix epoch time&lt;/a&gt;), and that's how many passwords we get.&lt;/p&gt;
&lt;p&gt;Now, the possibility to &lt;a class="reference external" href="https://en.wikipedia.org/wiki/List_of_websites_founded_before_1995"&gt;order Pizza online&lt;/a&gt; came much later, namely, at August 22nd, 1994.&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code bash"&gt;&lt;a id="rest_code_5a6769dc084248c693e55e32638fff21-1" name="rest_code_5a6769dc084248c693e55e32638fff21-1" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_5a6769dc084248c693e55e32638fff21-1"&gt;&lt;/a&gt;↪&lt;span class="w"&gt; &lt;/span&gt;date&lt;span class="w"&gt; &lt;/span&gt;-d&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;19940822&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;+&lt;span class="s2"&gt;"%s"&lt;/span&gt;
&lt;a id="rest_code_5a6769dc084248c693e55e32638fff21-2" name="rest_code_5a6769dc084248c693e55e32638fff21-2" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_5a6769dc084248c693e55e32638fff21-2"&gt;&lt;/a&gt;&lt;span class="m"&gt;777506400&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;That leaves us with 780,160,249 passwords since this memorable day in 1994 or a complexity of 30 bits, corresponding to a 5-digit password with a character space of 62. Let's get one of these and see how difficult it is to crack:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code bash"&gt;&lt;a id="rest_code_e89933a0486c400294d933a71dab42a9-1" name="rest_code_e89933a0486c400294d933a71dab42a9-1" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_e89933a0486c400294d933a71dab42a9-1"&gt;&lt;/a&gt;↪&lt;span class="w"&gt; &lt;/span&gt;pwgen&lt;span class="w"&gt; &lt;/span&gt;-s&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;5&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;-1
&lt;a id="rest_code_e89933a0486c400294d933a71dab42a9-2" name="rest_code_e89933a0486c400294d933a71dab42a9-2" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_e89933a0486c400294d933a71dab42a9-2"&gt;&lt;/a&gt;p9iCN
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now, even my ancient GTX650Ti with its modest MD5 hashing performance of 1.5 GH/s cracks this password in 5 s (note that an RTX2080 delivers 36 GH/s...):&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code bash"&gt;&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-1" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-1" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-1"&gt;&lt;/a&gt;○&lt;span class="w"&gt; &lt;/span&gt;→&lt;span class="w"&gt; &lt;/span&gt;hashcat&lt;span class="w"&gt; &lt;/span&gt;-O&lt;span class="w"&gt; &lt;/span&gt;-a&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;-m&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;myhashes.hash&lt;span class="w"&gt; &lt;/span&gt;?a?a?a?a?a
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-2" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-2" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-2"&gt;&lt;/a&gt;hashcat&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;v5.1.0&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;starting...
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-3" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-3" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-3"&gt;&lt;/a&gt;
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-4" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-4" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-4"&gt;&lt;/a&gt;OpenCL&lt;span class="w"&gt; &lt;/span&gt;Platform&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="c1"&gt;#1: NVIDIA Corporation&lt;/span&gt;
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-5" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-5" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-5"&gt;&lt;/a&gt;&lt;span class="o"&gt;======================================&lt;/span&gt;
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-6" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-6" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-6"&gt;&lt;/a&gt;-&lt;span class="w"&gt; &lt;/span&gt;Device&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="c1"&gt;#1: GeForce GTX 650 Ti, 243/972 MB allocatable, 4MCU&lt;/span&gt;
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-7" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-7" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-7"&gt;&lt;/a&gt;
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-8" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-8" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-8"&gt;&lt;/a&gt;0b91091d40a8623891367459d5b2a406:p9iCN
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-9" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-9" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-9"&gt;&lt;/a&gt;
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-10" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-10" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-10"&gt;&lt;/a&gt;Session..........:&lt;span class="w"&gt; &lt;/span&gt;hashcat
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-11" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-11" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-11"&gt;&lt;/a&gt;Status...........:&lt;span class="w"&gt; &lt;/span&gt;Cracked
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-12" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-12" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-12"&gt;&lt;/a&gt;Hash.Type........:&lt;span class="w"&gt; &lt;/span&gt;MD5
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-13" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-13" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-13"&gt;&lt;/a&gt;Hash.Target......:&lt;span class="w"&gt; &lt;/span&gt;0b91091d40a8623891367459d5b2a406
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-14" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-14" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-14"&gt;&lt;/a&gt;Time.Started.....:&lt;span class="w"&gt; &lt;/span&gt;Mon&lt;span class="w"&gt; &lt;/span&gt;May&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;13&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;12&lt;/span&gt;:48:58&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;2019&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;5&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;secs&lt;span class="o"&gt;)&lt;/span&gt;
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-15" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-15" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-15"&gt;&lt;/a&gt;Time.Estimated...:&lt;span class="w"&gt; &lt;/span&gt;Mon&lt;span class="w"&gt; &lt;/span&gt;May&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;13&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;12&lt;/span&gt;:49:03&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;2019&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;secs&lt;span class="o"&gt;)&lt;/span&gt;
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-16" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-16" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-16"&gt;&lt;/a&gt;Guess.Mask.......:&lt;span class="w"&gt; &lt;/span&gt;?a?a?a?a?a&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="m"&gt;5&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-17" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-17" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-17"&gt;&lt;/a&gt;Guess.Queue......:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;/1&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;100&lt;/span&gt;.00%&lt;span class="o"&gt;)&lt;/span&gt;
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-18" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-18" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-18"&gt;&lt;/a&gt;Speed.#1.........:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;514&lt;/span&gt;.0&lt;span class="w"&gt; &lt;/span&gt;MH/s&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;6&lt;/span&gt;.21ms&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;@&lt;span class="w"&gt; &lt;/span&gt;Accel:64&lt;span class="w"&gt; &lt;/span&gt;Loops:47&lt;span class="w"&gt; &lt;/span&gt;Thr:1024&lt;span class="w"&gt; &lt;/span&gt;Vec:2
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-19" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-19" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-19"&gt;&lt;/a&gt;Recovered........:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;/1&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;100&lt;/span&gt;.00%&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;Digests,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;/1&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;100&lt;/span&gt;.00%&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;Salts
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-20" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-20" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-20"&gt;&lt;/a&gt;Progress.........:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;2328363008&lt;/span&gt;/7737809375&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;30&lt;/span&gt;.09%&lt;span class="o"&gt;)&lt;/span&gt;
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-21" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-21" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-21"&gt;&lt;/a&gt;Rejected.........:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;/2328363008&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;.00%&lt;span class="o"&gt;)&lt;/span&gt;
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-22" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-22" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-22"&gt;&lt;/a&gt;Restore.Point....:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;24379392&lt;/span&gt;/81450625&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;29&lt;/span&gt;.93%&lt;span class="o"&gt;)&lt;/span&gt;
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-23" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-23" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-23"&gt;&lt;/a&gt;Restore.Sub.#1...:&lt;span class="w"&gt; &lt;/span&gt;Salt:0&lt;span class="w"&gt; &lt;/span&gt;Amplifier:0-47&lt;span class="w"&gt; &lt;/span&gt;Iteration:0-47
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-24" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-24" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-24"&gt;&lt;/a&gt;Candidates.#1....:&lt;span class="w"&gt; &lt;/span&gt;s3v&lt;span class="se"&gt;\,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;-&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;RPuJG
&lt;a id="rest_code_d0cb206325a44b76bb9e48066f6d8821-25" name="rest_code_d0cb206325a44b76bb9e48066f6d8821-25" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_d0cb206325a44b76bb9e48066f6d8821-25"&gt;&lt;/a&gt;Hardware.Mon.#1..:&lt;span class="w"&gt; &lt;/span&gt;Temp:&lt;span class="w"&gt; &lt;/span&gt;44c&lt;span class="w"&gt; &lt;/span&gt;Fan:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;33&lt;/span&gt;%
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;But actually, it's even worse: instead of cracking the hash one can easily precompute all possible values of the 'date | md5sum' command, and thus create a dictionary containing these “passwords”. I could start right away:&lt;/p&gt;
&lt;pre class="literal-block"&gt;for (( time=777506400; time&amp;lt;=1557666649; time++ )); do date -d@$time | md5sum | tr -d "-"; done &amp;gt; lowell_heddings_passwords.txt&lt;/pre&gt;
&lt;p&gt;On my desktop with its Xeon E3 v2, this command computes one million passwords in about half an hour, i.e, I'd need about 17 days for computing all passwords back to 1994. Writing a corresponding program running on the GPU would cut this down to seconds. Note that the resulting list of “random enough” passwords is static, i.e., it is indeed a dictionary, and not even a particularly large one.&lt;/p&gt;
&lt;p&gt;Lowell Heddings himself mentions several alternative ways to generate a password in &lt;a class="reference external" href="http://www.howtogeek.com/howto/30184/10-ways-to-generate-a-random-password-from-the-command-line/"&gt;his article&lt;/a&gt; before turning to the worst possible solution. But if we desire cryptographically secure solutions, even apparently innocuous commands are beset with difficulties, as pointed out by, for example, the &lt;a class="reference external" href="https://forums.freebsd.org/threads/44826/"&gt;carpetsmoker&lt;/a&gt; (better carpets than mattresses). In the end, it all boils down to the following three choices that are available on virtually any Linux installation. If we limit ourselves to a character space of 62:&lt;/p&gt;
&lt;pre class="literal-block"&gt;cat /dev/urandom | base64 | tr -d /=+ | head -c 25; echo
openssl rand -base64 25 | tr -d /=+ | head -c 25; echo
gpg2 --armor --gen-random 1 25 | tr -d /=+ | head -c 25; echo&lt;/pre&gt;
&lt;p&gt;If we insist of having almost all printable characters (which often calls for trouble):&lt;/p&gt;
&lt;pre class="literal-block"&gt;cat /dev/urandom | base91 | head -c 25
openssl rand 25 | base91 | head -c 25; echo
gpg2 --gen-random 1 25 | base91 | head -c 25; echo&lt;/pre&gt;
&lt;p&gt;One could, in principle, also utilize dedicated &lt;a class="reference external" href="https://cobra.pdes-net.org/posts/password-generators.html"&gt;password generators&lt;/a&gt;, such as Theodore Tso's 'pwgen', Adel I. Mirzazhanov's 'apg', or haui's 'hpg':&lt;/p&gt;
&lt;pre class="literal-block"&gt;pwgen -s 25
apg -a 1 -M ncl -m 25 -x 25
hpg --alphanum 25&lt;/pre&gt;
&lt;p&gt;All of these ways are cryptographically equivalent in the sense that the entropy of the passwords generated by either of them asymptotically approaches the theoretical value ($\log_2(62) \approx 5.954$ bits per character) when you average over many (10,000,000 or more). In the present context (functions with default values) the generators do not offer any advantage, but only add unnecessary complexity.&lt;/p&gt;
&lt;p&gt;Now, whatever you chose as your favorite, you don't want to memorize the command or rely on the history of your favorite shell. One could define an alias with the password length as parameter, but I prefer to use a function for this case to have a default length of 25 characters with the option to change this value:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code bash"&gt;&lt;a id="rest_code_c6c02adce70744e3ae42b7b905112f7d-1" name="rest_code_c6c02adce70744e3ae42b7b905112f7d-1" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_c6c02adce70744e3ae42b7b905112f7d-1"&gt;&lt;/a&gt;↪&lt;span class="w"&gt; &lt;/span&gt;pw62
&lt;a id="rest_code_c6c02adce70744e3ae42b7b905112f7d-2" name="rest_code_c6c02adce70744e3ae42b7b905112f7d-2" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_c6c02adce70744e3ae42b7b905112f7d-2"&gt;&lt;/a&gt;mPcSU1c3lBTC7gChJ4MBw1sZW
&lt;a id="rest_code_c6c02adce70744e3ae42b7b905112f7d-3" name="rest_code_c6c02adce70744e3ae42b7b905112f7d-3" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_c6c02adce70744e3ae42b7b905112f7d-3"&gt;&lt;/a&gt;
&lt;a id="rest_code_c6c02adce70744e3ae42b7b905112f7d-4" name="rest_code_c6c02adce70744e3ae42b7b905112f7d-4" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_c6c02adce70744e3ae42b7b905112f7d-4"&gt;&lt;/a&gt;↪&lt;span class="w"&gt; &lt;/span&gt;pw62&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;8&lt;/span&gt;
&lt;a id="rest_code_c6c02adce70744e3ae42b7b905112f7d-5" name="rest_code_c6c02adce70744e3ae42b7b905112f7d-5" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_c6c02adce70744e3ae42b7b905112f7d-5"&gt;&lt;/a&gt;Yjs6NhYM
&lt;a id="rest_code_c6c02adce70744e3ae42b7b905112f7d-6" name="rest_code_c6c02adce70744e3ae42b7b905112f7d-6" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_c6c02adce70744e3ae42b7b905112f7d-6"&gt;&lt;/a&gt;
&lt;a id="rest_code_c6c02adce70744e3ae42b7b905112f7d-7" name="rest_code_c6c02adce70744e3ae42b7b905112f7d-7" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_c6c02adce70744e3ae42b7b905112f7d-7"&gt;&lt;/a&gt;↪&lt;span class="w"&gt; &lt;/span&gt;pw62&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;32&lt;/span&gt;
&lt;a id="rest_code_c6c02adce70744e3ae42b7b905112f7d-8" name="rest_code_c6c02adce70744e3ae42b7b905112f7d-8" href="https://cobra.pdes-net.org/posts/functions-with-default-values.html#rest_code_c6c02adce70744e3ae42b7b905112f7d-8"&gt;&lt;/a&gt;cfn4KKugWHhOBF8qn6SO5Rj7uC2LksnK
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here's how to implement this functionality for the three major shells. Note the very elegant way with which a default value can be implemented within the bash. &lt;strong&gt;Update:&lt;/strong&gt; haui reminded me that the zsh is a drop-in replacement for the bash and thus of course implements all bash variable substitution, particularly ${var:-default}. Hence, we can use the same syntax for the bash and the zsh, and only the fish needs the comparatively clumsy construct shown below. 😎&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;bash&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="literal-block"&gt;function pw62
{
cat /dev/urandom | base64 | tr -d /=+ | head -c ${1:-25}; echo
}&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;fish&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="literal-block"&gt;function pw62
if set -q $argv
set length 25
else
set length $argv
end

cat /dev/urandom | base64 | tr -d /=+ | head -c $length; echo

end&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;zsh&lt;/strong&gt; (alternative to the bash syntax)&lt;/p&gt;
&lt;pre class="literal-block"&gt;function pw62()
{
if [ "$1" != "" ]
then
integer length=$1
else
integer length=25
fi

cat /dev/urandom | base64 | tr -d /=+ | head -c $length; echo
}&lt;/pre&gt;</description><category>encryption</category><category>linux</category><category>mathematics</category><guid>https://cobra.pdes-net.org/posts/functions-with-default-values.html</guid><pubDate>Sat, 25 May 2019 20:36:59 GMT</pubDate></item><item><title>The fastest search, or: find your password</title><link>https://cobra.pdes-net.org/posts/the-fastest-search-or-find-your-password.html</link><dc:creator>Cobra</dc:creator><description>&lt;p&gt;A couple of weeks ago, &lt;a class="reference external" href="https://www.wired.com/story/collection-leak-usernames-passwords-billions/"&gt;a monstrous set of login data was passed around in the dark web&lt;/a&gt;. Now known as collections #1 – #5, the files contain an estimated 2.2 billion of unique email address/password combinations. And that means cracked passwords, mind you, not only hashes.&lt;/p&gt;
&lt;p&gt;Some of my account data have been leaked ages ago by Adobe and Dropbox (at that time, I believed in simple – &lt;a class="reference external" href="https://cobra.pdes-net.org/posts/passwords.html"&gt;8-digit&lt;/a&gt; – passwords for test accounts). Incidentally, I had already deleted these accounts when the breach became public.&lt;/p&gt;
&lt;p&gt;Currently, all of my accounts are secured by an at least 25-digit random password with an actual &lt;a class="reference external" href="https://cobra.pdes-net.org/posts/password-hysteria.html"&gt;entropy&lt;/a&gt; not lower than 100 bits, which is essentially impossible to brute force even from unsalted SHA1 hashes. Hence, none of my accounts should show up in the collections mentioned above. If one did, it would show that the password had been saved in plain text, and I would react correspondingly by deleting this account.&lt;/p&gt;
&lt;p&gt;The most comprehensive list of password hashes (including collection #1) has been assembled by &lt;a class="reference external" href="https://haveibeenpwned.com/"&gt;Troy Hunt&lt;/a&gt;. We can download and search this list very easily as shown in the following.&lt;/p&gt;
&lt;pre class="literal-block"&gt;$ cd /hdd/Downloads/pwned
$ wget https://downloads.pwnedpasswords.com/passwords/pwned-passwords-sha1-ordered-by-hash-v4.7z
$ cp pwned-passwords-sha1-ordered-by-hash-v4.7z /ssd/temp/pwned
$ cd /ssd/temp/pwned/
$ unp ppwned-passwords-sha1-ordered-by-hash-v4.7z
$ wc -l &amp;lt;pwned-passwords-sha1-ordered-by-hash-v4.txt
551509767
$ awk -F: '{ SUM += $2 } END { print SUM }' pwned-passwords-sha1-ordered-by-hash-v4.txt
3344070078&lt;/pre&gt;
&lt;p&gt;551 million passwords, and 3.344 billion accounts: holy cow. What's the fastest way to search for a single string in such a huge file? C't 5/2019 has actually &lt;a class="reference external" href="https://www.heise.de/select/ct/2019/5/1551437903574108"&gt;an entire article on this issue&lt;/a&gt;, complete with a &lt;a class="reference external" href="https://github.com/pinae/HaveIBeenPwnedOffline"&gt;github repository&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Pina Merkert points out that grep, the standard tool for searching text files under Linux, does not exploit the fact that Troy Hunt offers the download also in a version where the passwords are ordered by hash (that's the version I've downloaded above). The &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Linear_search"&gt;linear search&lt;/a&gt; performed by grep is indeed rather slow:&lt;/p&gt;
&lt;pre class="literal-block"&gt;$ time echo -n "111111" | sha1sum | awk '{print toupper($1)}' | grep -f - pwned-passwords-sha1-ordered-by-hash-v4.txt
3D4F2BF07DC1BE38B20CD6E46949A1071F9D0E3D:3093220

real    0m48.227s
user    0m30.939s
sys     0m5.752s&lt;/pre&gt;
&lt;p&gt;The possibility to order the data allows a &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Binary_search_algorithm"&gt;binary search&lt;/a&gt; to be performed, which is potentially orders of magnitude faster – O(log[n]) vs. O(n) – than a linear search. Pina's python script is indeed dramatically faster:&lt;/p&gt;
&lt;pre class="literal-block"&gt;$ time ./binary_search.py '111111'
Searching for hash 3D4F2BF07DC1BE38B20CD6E46949A1071F9D0E3D of password "111111".
Password found at byte  5824044773: "3D4F2BF07DC1BE38B20CD6E46949A1071F9D0E3D:3093220"
Your password "111111" was in 3093220 leaks or hacked databases! Please change it immediately.

real    0m0.042s
user    0m0.035s
sys     0m0.007s&lt;/pre&gt;
&lt;p&gt;But my one-liner is four times faster than her 57-line script: 😉&lt;/p&gt;
&lt;pre class="literal-block"&gt;$ time look $(echo -n "111111" | sha1sum | awk '{print toupper($1)}') pwned-passwords-sha1-ordered-by-hash-v4.txt
3D4F2BF07DC1BE38B20CD6E46949A1071F9D0E3D:3093220

real    0m0.011s
user    0m0.009s
sys     0m0.005s&lt;/pre&gt;
&lt;p&gt;'Look', by the way, is a binary search tool, part of the util-linux package and thus present on any Linux installation (and also on the Windows subsystem for Linux, I guess). Unfortunately, several distributions (such as Debian and Ubuntu) manage to ship a &lt;a class="reference external" href="https://bugs.launchpad.net/ubuntu/+source/bsdmainutils/+bug/510613"&gt;broken version&lt;/a&gt; of look since about 10 years. There's an &lt;a class="reference external" href="https://github.com/stuartraetaylor/bsdmainutils-look"&gt;unofficial patched version&lt;/a&gt; available on GitHub if you'd like to try.&lt;/p&gt;
&lt;p&gt;With the help of 'look', one can also very easily go through lists of passwords – let's take these completely arbitrary examples:&lt;/p&gt;
&lt;pre class="literal-block"&gt;less topten.dat

123456
123456789
qwerty
password
111111
12345678
abc123
1234567
password1
12345

$ time while read -r password; do look $(echo -n "$password" | sha1sum | awk '{print toupper($1)}') pwned-passwords-sha1-ordered-by-hash-v4.txt; done &amp;lt;topten.dat

7C4A8D09CA3762AF61E59520943DC26494F8941B:23174662
F7C3BC1D808E04732ADF679965CCC34CA7AE3441:7671364
B1B3773A05C0ED0176787A4F1574FF0075F7521E:3810555
5BAA61E4C9B93F3F0682250B6CF8331B7EE68FD8:3645804
3D4F2BF07DC1BE38B20CD6E46949A1071F9D0E3D:3093220
7C222FB2927D828AF22F592134E8932480637C0D:2889079
6367C48DD193D56EA7B0BAAD25B19455E529F5EE:2834058
20EABE5D64B0E216796E834F52D61FD0B70332FC:2484157
E38AD214943DAAD1D64C102FAEC29DE4AFE9DA3D:2401761
8CB2237D0679CA88DB6464EAC60DA96345513964:2333232

real    0m0.053s
user    0m0.048s
sys     0m0.023s&lt;/pre&gt;
&lt;p&gt;If you ever had a shred of doubt that humanity has a glorious future, look at these 10 ingenious passwords, which secure the 54 million accounts of our most brilliant minds!&lt;/p&gt;</description><category>encryption</category><category>linux</category><guid>https://cobra.pdes-net.org/posts/the-fastest-search-or-find-your-password.html</guid><pubDate>Thu, 21 Feb 2019 19:03:37 GMT</pubDate></item><item><title>Living in your own private Idaho</title><link>https://cobra.pdes-net.org/posts/living-in-your-own-private-idaho.html</link><dc:creator>Cobra</dc:creator><description>&lt;p&gt;&lt;a class="reference external" href="https://www.golem.de"&gt;Golem&lt;/a&gt; published an &lt;a class="reference external" href="https://www.golem.de/news/e-mail-verschluesselung-90-prozent-des-enigmail-codes-sind-von-mir-1811-137612.html"&gt;interview&lt;/a&gt; with &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Enigmail"&gt;Enigmail&lt;/a&gt; developer Patrick Brunschwig (the following quotes were translated by &lt;a class="reference external" href="https://www.deepl.com/translator"&gt;DeepL):&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;“Then I took a look at the different tools that existed. I didn't like Evolution that much and Mozilla was still in its infancy. Nevertheless, we used it.”&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;a class="reference external" href="http://www.mutt.org/"&gt;All mail clients suck. This one just sucks less.&lt;/a&gt; 😉&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;“What's really important is that PGP is integrated directly into the tools. At K-9 I have to install Openkeychain first, at Thunderbird I have to install Enigmail and then GnuPG. Just this step, to have PGP directly, without addon and without additional software installation in the tool, would simplify a lot of things.”&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Well, I had PGP “directly” for the past 15 years. It's a matter of choosing the right tool for the job. 😉 I never had to install GnuPG manually (in fact, it's a core package in many distributions: the package managers depend on it since the packages are PGP signed!), and both &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Kontact"&gt;KMail&lt;/a&gt; and &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Evolution_(software)"&gt;Evolution&lt;/a&gt; support PGP right out of the box. &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Mutt_(email_client)"&gt;Mutt&lt;/a&gt; as well, by the way. 😉 The lack of a native support is only one reason to avoid Thunderbird and its &lt;a class="reference external" href="https://www.heise.de/select/ct/2018/22/1540539470577258"&gt;shaky&lt;/a&gt; PGP integration via an addon. There are &lt;a class="reference external" href="https://support.mozilla.org/en-US/kb/maildir-thunderbird"&gt;others&lt;/a&gt; that are more basic in nature.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;"Which more modern mail clients are there? There aren't that many that are still widespread. It's true that Thunderbird isn't very modern, but there are very, very few really modern mail clients. I don't know of any real alternative."&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;That's either ill informed or deliberately misleading. It's ok to dislike programs on a subjective basis, but one shouldn't entirely lose an objective stance. Of course there are alternatives to Thunderbird (and with native PGP support), for all operating systems. Windows: &lt;a class="reference external" href="https://www.emclient.com/?lang=en"&gt;eM Client&lt;/a&gt;, &lt;a class="reference external" href="https://www.everdesk.com/"&gt;EverDesk&lt;/a&gt;, and of course, &lt;a class="reference external" href="https://www.ritlabs.com/en/"&gt;The Bat!&lt;/a&gt; (the best E-Mail program ever, period). MacOS: &lt;a class="reference external" href="https://canarymail.io/"&gt;Canary Mail&lt;/a&gt;. And Linux: &lt;a class="reference external" href="https://www.kde.org/applications/internet/kmail/"&gt;KMail&lt;/a&gt;, &lt;a class="reference external" href="https://help.gnome.org/users/evolution/stable/mail-encryption.html.en"&gt;Evolution&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Admittedly, the latter two are not exactly “modern”, although I'm not sure what that is supposed to mean. If “modern” refers to the interface, there's &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Geary_(software)"&gt;Geary,&lt;/a&gt; which was initially released 2012 and has recently become quite popular, having been adopted by the Gnome project and being the default mailer in &lt;a class="reference external" href="https://elementary.io/"&gt;ElementaryOS.&lt;/a&gt; Geary features a modern interface and a modern feature set: it does neither support POP3 nor PGP. Even more modern is &lt;a class="reference external" href="https://getmailspring.com/"&gt;Mailspring&lt;/a&gt;, the successor of &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Nylas_Mail"&gt;Nylas Mail:&lt;/a&gt; it's based on Electron and thus weighs 280 MB, its interface is très chic and themable, and it requires a Customer ID to synchronize mails over the different devices modern people have. It doesn't need to bother with PGP, as there's no need for that in the modern, &lt;a class="reference external" href="https://de.wikipedia.org/wiki/Post-Privacy"&gt;post-privacy&lt;/a&gt; world.&lt;/p&gt;
&lt;p&gt;But I'm being sarcastic, and that's not entirely fair, since there are also developments on the other end of the spectrum. The icelandic &lt;a class="reference external" href="https://www.mailpile.is/"&gt;Mailpile,&lt;/a&gt; for example, has privacy as its top priority, and invented an entirely new concept for that: a local webmailer. I would actually consider to use it on my notebook wouldn't the interface be the most dilettantishly designed one I have seen since &lt;a class="reference external" href="http://oneterabyteofkilobyteage.tumblr.com/"&gt;Geocities&lt;/a&gt;.&lt;/p&gt;</description><category>encryption</category><category>thoughts</category><guid>https://cobra.pdes-net.org/posts/living-in-your-own-private-idaho.html</guid><pubDate>Mon, 26 Nov 2018 19:55:59 GMT</pubDate></item><item><title>Let's encrypt</title><link>https://cobra.pdes-net.org/posts/lets-encrypt.html</link><dc:creator>Cobra</dc:creator><description>&lt;p&gt;Ever since I've set up the &lt;a class="reference external" href="https://cobra.pdes-net.org/posts/new-server.html"&gt;new server&lt;/a&gt; for this blog, I've wanted to make the switch from plain HTTP to TLS-encrypted HTTPS (if you think HTTPS is for online shops and banks only, &lt;a class="reference external" href="https://https.cio.gov/faq/"&gt;think&lt;/a&gt; &lt;a class="reference external" href="https://cheapsslsecurity.com/blog/http-vs-https-do-you-really-need-https/"&gt;again&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;This transition turned out to be much easier than I thought. Hiawatha, our web server of choice, comes with a script that takes care of registering the site at &lt;a class="reference external" href="https://letsencrypt.org/"&gt;Let's Encrypt&lt;/a&gt; and requesting certificates for the associated domain(s). Chris Wadge, the maintainer of Hiawatha for Debian, provided an excellent &lt;a class="reference external" href="https://dotbalm.org/lets-encrypt-with-hiawatha/"&gt;tutorial&lt;/a&gt; guiding through the few steps necessary to configure Hiawatha for serving HTTPS content.&lt;/p&gt;
&lt;p&gt;Since I had to configure vhosts for the certificates anyway, I took the opportunity to set up some proper subdomains. For example, this blog can now be reached at &lt;a class="reference external" href="https://cobra.pdes-net.org"&gt;https://cobra.pdes-net.org&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;After a bit of tweaking (setting HSTS to one year), the security rating of our site is flawless:&lt;/p&gt;
&lt;img alt="../images/qualys.png" class="align-center" src="https://cobra.pdes-net.org/images/qualys.png"&gt;</description><category>encryption</category><category>info</category><category>web</category><guid>https://cobra.pdes-net.org/posts/lets-encrypt.html</guid><pubDate>Sat, 17 Feb 2018 12:47:02 GMT</pubDate></item></channel></rss>