<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>pgp &#8211; Virtually Fun</title>
	<atom:link href="https://virtuallyfun.com/category/pgp/feed/" rel="self" type="application/rss+xml" />
	<link>https://virtuallyfun.com</link>
	<description>Fun with Virtualization</description>
	<lastBuildDate>Sat, 12 Jun 2021 18:16:23 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>
	<item>
		<title>A mildly annoying 32bit adventure, also happy 30th PGP!</title>
		<link>https://virtuallyfun.com/2021/06/12/a-mildly-annoying-32bit-adventure-also-happy-30th-pgpg/</link>
					<comments>https://virtuallyfun.com/2021/06/12/a-mildly-annoying-32bit-adventure-also-happy-30th-pgpg/#comments</comments>
		
		<dc:creator><![CDATA[neozeed]]></dc:creator>
		<pubDate>Sat, 12 Jun 2021 02:55:45 +0000</pubDate>
				<category><![CDATA[encryption]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[pgp]]></category>
		<category><![CDATA[x64]]></category>
		<guid isPermaLink="false">https://virtuallyfun.com/wordpress/?p=11140</guid>

					<description><![CDATA[It&#8217;s been 30 years since the initial launch of PGP! Hard to believe what a firestorm it ignited i the 1990&#8217;s and the real pity of how the crypto field is just as baffling and confusing to people today as &#8230; <a href="https://virtuallyfun.com/2021/06/12/a-mildly-annoying-32bit-adventure-also-happy-30th-pgpg/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">It&#8217;s been 30 years since the initial launch of PGP!  Hard to believe what a firestorm it ignited i the 1990&#8217;s and the real pity of how the crypto field is just as baffling and confusing to people today as it was back then.</p>



<p class="wp-block-paragraph">It&#8217;s crazy how crypto went from being an obtuse tool, to suddenly being in the hands of normal people with a public web of trust, and widely available source.  And of course it was that widely available source that led to the first real people of trying to geofence on the internet, and it was naturally impossible to contain, even in the era before VPN&#8217;s people were able to circumvent any and all <em>&#8220;protections&#8221;</em> and download away.  Strong cryptography went from being something considered &#8216;weapons grade&#8217; and thusly requiring a munitions license to produce and distribute to suddenly being available to the world at large.</p>



<p class="wp-block-paragraph"><a href="https://www.wired.com/1995/03/the-continuing-investigation-of-phil-zimmermann/">Investigations were launched</a>, agencies contacted, and in spite of it all people had signing parities to exchange public keys, and sign the trust building the web.  Try as some people may have demanded &#8216;back door access&#8217; or black box crypto chips, the cat was out of the bag, and all you needed was a C compiler and a zip file small enough to easily fit on a low density 5 1/4&#8243; diskette.  It is 1991 after all, and there is still a sizable amount of XT/AT class machines out there, along with the 68000 Amiga/Atari/Macintosh (upgraded QL&#8217;s? 128kb really isn&#8217;t enough).</p>



<p class="wp-block-paragraph">PGP 1.0 is from another era, originally written in the late 80&#8217;s cleaned up and released in 1991 where mass produced 64bit machines were still a bit off, and thusly PGP 1.0 really supports 16bit &amp; 32bit OS&#8217;s.  For the purpose of this &#8216;revival&#8217; I went with the Unix port, the aptly named <a rel="noreferrer noopener" href="https://vpsland.superglobalmegacorp.com/install/encryption/pgp/unix_pgp10.tar.gz" target="_blank">unix_pgp10.tar.gz</a>.  And from the MS-DOS version I extracted the test data to make sure it works in the file <a rel="noreferrer noopener" href="https://vpsland.superglobalmegacorp.com/install/encryption/pgp/pgp10-test-data.tar.gz" target="_blank">pgp10-test-data.tar.gz</a></p>



<pre class="wp-block-preformatted">$ file pgp
 pgp: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=cd9ecbf51fab24abbb7153a2cc04bb01bbf2ae91, not stripped
$ ./pgp testfile.ctx
 Pretty Good Privacy 1.0 - RSA public key cryptography for the masses.
 (c) Copyright 1990 Philip Zimmermann, Phil's Pretty Good Software.  5 Jun 91
 File is encrypted.  Secret key is required to read it.
 Key for user ID: Bond, James (007)
 288-bit key, Key ID A27A1F, created Sat Oct 19 23:56:24 3006391
 You need a pass phrase to unlock your RSA secret key.
 Enter pass phrase:</pre>



<p class="wp-block-paragraph">While it was simple enough to build, sadly on x64 WSL instance it doesn&#8217;t work.  There is no pass phrase for the test data.</p>



<p class="wp-block-paragraph">Normally I have one of usual two choices a) try to fix PGP to be 64bit friendly or b) run it under a 32bit environment.  Normally I would do b, but I went digging into some porting strategies for the a choice and ran into this totally underused tech <a rel="noreferrer noopener" href="https://sites.google.com/site/x32abi/" target="_blank">x32</a>.</p>



<p class="wp-block-paragraph">Long story short you keep your 32bit integers, you run like it&#8217;s a 32bit process but you are mapped into a 64bit address space.  Even better -static works!</p>



<p class="wp-block-paragraph">On Debian 10 the environment can be installed with the following:</p>



<pre class="wp-block-preformatted">apt-get install gcc-7 lib32gcc-7-dev libgcc-7-dev libx32gcc-7-dev gcc-7-multilib</pre>



<p class="wp-block-paragraph">Then to invoke it, use <span style="text-decoration: underline;"><em>gcc-7 -mx32</em></span> .  It&#8217;s that easy.</p>



<p class="wp-block-paragraph">WSLv1 vs WSLv2</p>



<pre class="wp-block-preformatted">$ ./pgp
 -bash: ./pgp: cannot execute binary file: Exec format error
$ file pgp
 pgp: ELF 32-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, BuildID[sha1]=2aa5f030603018ca1dc6c5c10aa979751b006aca, for GNU/Linux 3.4.0, not stripped</pre>



<p class="wp-block-paragraph">Notice it is now a 32-bit LSB executable, but also in the x86-64 address space!  However under the WSLv1 environment it won&#8217;t work.  Time to update to v2</p>



<pre class="wp-block-preformatted">   wsl --set-version Ubuntu-20.04 2
   Conversion in progress, this may take a few minutesâ€¦
   For information on key differences with WSL 2 please visit https://aka.ms/wsl2
   WSL 2 requires an update to its kernel component. For information please visit https://aka.ms/wsl2kernel </pre>



<p class="wp-block-paragraph">And now with the instance converted:</p>



<pre class="wp-block-preformatted">$ ./pgp
 Pretty Good Privacy 1.0 - RSA public key cryptography for the masses.
 (c) Copyright 1990 Philip Zimmermann, Phil's Pretty Good Software.  5 Jun 91
 For details on free licensing and distribution, see the PGP User's Guide.
 For other cryptography products and custom development services, contact:
 Philip Zimmermann, 3021 11th St, Boulder CO 80304 USA, phone (303)444-4541
 Usage summary:
 To encrypt a plaintext file with recipent's public key, type:
    pgp -e textfile her_userid      (produces textfile.ctx)
 To sign a plaintext file with your secret key, type:
    pgp -s textfile your_userid     (produces textfile.ctx)
 To sign a plaintext file with your secret key, and then encrypt it
    with recipent's public key, producing a .ctx file:
    pgp -es textfile her_userid your_userid
 To encrypt with conventional encryption only:  pgp -c textfile
 To decrypt or check a signature for a ciphertext (.ctx) file:
    pgp ciphertextfile [plaintextfile]
 To generate your own unique public/secret key pair, type:  pgp -k
 To add a public or secret key file's contents to your public
    or secret key ring:   pgp -a keyfile [keyring]
 To remove a key from your public key ring:     pgp -r userid [keyring]
 To view the contents of your public key ring:  pgp -v [userid] [keyring]
$</pre>



<p class="wp-block-paragraph">And we are in business!  Now we can run the example crypto test:</p>



<pre class="wp-block-preformatted">$ ./pgp testfile.ctx
 Pretty Good Privacy 1.0 - RSA public key cryptography for the masses.
 (c) Copyright 1990 Philip Zimmermann, Phil's Pretty Good Software.  5 Jun 91
 File is encrypted.  Secret key is required to read it.
 Key for user ID: Bond, James (007)
 286-bit key, Key ID A27A1F, created (null)
 Advisory warning: This RSA secret key is not protected by a passphrase.
 Just a moment-- .
 File has signature.  Public key is required to check signature. .
 Good signature from user "Smart, Maxwell (86)".
 Signature made Thu Jun  6 05:28:52 1991
 Plaintext filename: testfile</pre>



<p class="wp-block-paragraph">And there we are!</p>



<p class="wp-block-paragraph">PGP 1.0 suffers from 2 real defects of the era the first being the home brew bassomatic that is apparently full of all kinds of flaws, and the second lurking in <a rel="noreferrer noopener" href="https://unix.superglobalmegacorp.com/cgi-bin/cvsweb.cgi/pgp/src/rsalib.c?rev=1.1.1.1;cvsroot=pgp;only_with_tag=pgp10" target="_blank">rsalib.c</a></p>



<pre class="wp-block-preformatted"> The RSA public key cryptosystem is patented by the Massachusetts Institute of Technology (U.S. patent #4,405,829).  Public Key  Partners (PKP) holds the exclusive commercial license to sell and  sub-license the RSA public key cryptosystem.  The author of this  software implementation of the RSA algorithm is providing this  implementation for educational use only.  Licensing this algorithm  from PKP is the responsibility of you, the user, not Philip Zimmermann, the author of this implementation.  The author assumes no liability for any breach of patent law resulting from the unlicensed use of this software by the user. These routines implement all of the multiprecision arithmetic necessary for Rivest-Shamir-Adleman (RSA) public key cryptography.</pre>



<p class="wp-block-paragraph">And it ignited so much of a war about licensing the RSA cryptography base.  It wasn&#8217;t until 1992/1993 that the RSA released their own aptly named <a rel="noreferrer noopener" href="https://sourceforge.net/projects/rsaref/" target="_blank">rsaref</a> that at <a rel="noreferrer noopener" href="https://unix.superglobalmegacorp.com/cgi-bin/cvsweb.cgi/pgp/rsaref/README?rev=1.1.1.1;cvsroot=pgp" target="_blank">least clarified and addressed their licensing restrictions.</a>  As we found out later it wasn&#8217;t the DOJ shutting down encryption, nor wild acts of congress instead it was <a rel="noreferrer noopener" href="https://cs.stanford.edu/people/eroberts/cs201/projects/software-patents/rsa.html" target="_blank">US Patent 4,405,829</a> which finally expired in Sept 21, 2000, along with <a href="https://cr.yp.to/patents/us/4200770.html">US patent 4,200,770</a> Hellman Diffie Merkle, public-key cryptography which expired in September of 1997.  So in the end it was the lawyers who were to be feared, not the the US Government.</p>



<p class="wp-block-paragraph">Another source of annoyance was the public/private key files are stored in a binary format (hence the 16/32/64 issues I&#8217;m sure!).</p>



<pre class="wp-block-preformatted">C:\temp&gt;pgp -v jason.pub
 Pretty Good Privacy 1.0 - RSA public key cryptography for the masses.
 (c) Copyright 1990 Philip Zimmermann, Phil's Pretty Good Software.  5 Jun 91
 Key ring: 'jason.pub'
 Type bits/keyID   Date     User ID
 pub  990/F7CAD5 12-Jun-21  Jason Stevens
 1 key(s) examined.
 C:\temp&gt;type jason.pub
 Â°Ã¼Â½â•Ÿâ•“iÂºÂ½t<img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2195.png" alt="↕" class="wp-smiley" style="height: 1em; max-height: 1em;" />HÃ¯â•œÃ†(â†‘ÂªÎ±&amp;Eâ˜¼lKL$*âŒ =â””Â¥â•’[â•«Ã¨s,â•”kÃ¥r~â–MFBvâ‰¥â‰¡â•«Eâ”´â•ŸTÃ¿â•‘ÂµÃ³&nbsp;â•¨6,<img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2663.png" alt="♣" class="wp-smiley" style="height: 1em; max-height: 1em;" />â—„Ermoâ–¼Ã¦â–„;Â± Ã¹Ã®
 C:\temp&gt;</pre>



<p class="wp-block-paragraph">So naturally you have to use uuencode which led to MIME collisions and other fun stuff down the road. yay!</p>



<pre class="wp-block-code"><code>begin 666 jason.pub
MF9,`$!C$8`U*87-O;B!3=&amp;5V96YSW@/5RO&gt;TFV)_9@%49RW3NYGD&lt;8*H`3X1
MZ&gt;D'/F/D7$)OKD9&amp;K+&gt;A&lt;@4&lt;,$RV.+M?9VR;17)M;Q^1W#OQ()&gt;,#?B!J\?6
M::&gt;K=!)(B&#91;V2*!BFX"9%#VQ+3"0J]#W`!YW56]&gt;*&lt;RS):X9R?MY-1D)V\O#7
/1&lt;''5)BZYJ+_T#8L!0`1
`
end</code></pre>



<p class="wp-block-paragraph">Even though today we have widespread SSL, and all kinds of apps that encrypt by default, but Operation Trojan Shield shows that that an app is simply not enough, and you cannot trust anything.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>Though Enigma had some cryptographic weaknesses, in practice it was German procedural flaws, operator mistakes, failure to systematically introduce changes in encipherment procedures, and Allied capture of key tables and hardware that, during the war, enabled Allied cryptologists to succeed and &#8220;turned the tide&#8221; in the Allies&#8217; favour.<sup><a href="https://en.wikipedia.org/wiki/Enigma_machine#cite_note-FOOTNOTEKahn1991-15">[15]</a><a href="https://en.wikipedia.org/wiki/Enigma_machine#cite_note-FOOTNOTEStripp1993-16">[16]</a></sup></p><cite>-Wikipedia</cite></blockquote>



<p class="wp-block-paragraph">And just like the spy movies good crypto is tedious, bulky and rarely used properly<strong>*</strong>.</p>



<p class="has-text-align-right wp-block-paragraph"><em>Yes please don&#8217;t seriously rely on pgp 1.0!</em></p>
]]></content:encoded>
					
					<wfw:commentRss>https://virtuallyfun.com/2021/06/12/a-mildly-annoying-32bit-adventure-also-happy-30th-pgpg/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
		<item>
		<title>Fun with PGP 1.0</title>
		<link>https://virtuallyfun.com/2014/08/22/fun-with-pgp-1-0/</link>
					<comments>https://virtuallyfun.com/2014/08/22/fun-with-pgp-1-0/#comments</comments>
		
		<dc:creator><![CDATA[neozeed]]></dc:creator>
		<pubDate>Fri, 22 Aug 2014 13:07:33 +0000</pubDate>
				<category><![CDATA[crypto]]></category>
		<category><![CDATA[pgp]]></category>
		<category><![CDATA[Win32]]></category>
		<guid isPermaLink="false">https://virtuallyfun.com/?p=4473</guid>

					<description><![CDATA[Well I got slightly bored, and thought I&#8217;d dig into some old crypto software. Â And PGP 1.0 was as good as any place to start. Now one scandalous thing at the time was the inclusion of RSAREF 1.0, the RSA &#8230; <a href="https://virtuallyfun.com/2014/08/22/fun-with-pgp-1-0/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
										<content:encoded><![CDATA[<p>Well I got slightly bored, and thought I&#8217;d dig into some old crypto software. Â And PGP 1.0 was as good as any place to start.</p>
<p>Now one scandalous thing at the time was the inclusion of <a href="http://vpsland.superglobalmegacorp.com/old/install/encryption/rsaref/rsaref-1.0-1993.tar.gz">RSAREF 1.0</a>, the RSA reference library which redistribution required a license that wasn&#8217;t exactly included with PGP.</p>
<p style="padding-left: 30px;">A company called Public Key Partners (PKP) holds the exclusive<br />
commercial license to sell and sub-license the RSA public key<br />
cryptosystem. For licensing details on the RSA algorithm, you can<br />
contact Robert Fougner at PKP, at 408/735-6779. The author of this<br />
software implementation of the RSA algorithm is providing this<br />
implementation for educational use only.</p>
<p>And wow was this fun at the time. Â As far as I know this license lapsedÂ on<a href="http://cs.stanford.edu/people/eroberts/cs201/projects/software-patents/rsa.html">Â </a><span style="color: #545454;"><a href="http://cs.stanford.edu/people/eroberts/cs201/projects/software-patents/rsa.html">September 21, 2000</a>.Â </span></p>
<p>And then there was <a href="http://books.google.co.uk/books?id=cSe_0OnZqjAC&amp;lpg=PA101&amp;pg=PA101#v=onepage&amp;q&amp;f=false">this slight issue</a>:</p>
<p style="padding-left: 30px;">After Biham and Zimmermann go their food and sat down, Zimmermann took out a few pages of computer listings. Â Within minutes, Birham was finding fundamental flaws in Bass-O-Matic. Â Some of the flaws were subtle-weaknesses that made the algorithm susceptible to differential cryptanalysis, which was Birham&#8217;s speciality. Others were more embarrassing, like a conceptual error in Zimmermann&#8217;s algorithm that prevented the last bit of each byte from being properly encrypted. Â After ten minutes of Birham&#8217;s onslaught, Zimmermann realized that Bass-O-Matic was a lost cause.</p>
<p>So now you would be wondering, why would I even bother with what was a quickly abandoned encryption? Â Well I was bored, and I was more interested if I could locate the source to 1.0. Â What would be more interesting to me is to revive it onto somewhat more modern 32-bit platforms. Â Namely OS X, Win32 and MS-DOS.</p>
<p>With a little luck, I found the <a href="http://vpsland.superglobalmegacorp.com/old/install/encryption/pgp/unix_pgp10.tar.gz">unix_pgp10.tar.gz</a>, which does contain the source code for a Unix version of PGP! Â This version is more so geared to the SPARC of all things. Specifically it mentions:</p>
<p>Tested on SunOS 4.1 with gcc 1.39</p>
<p>However building on OS XÂ was trival with changing the Makefile. Â The CC had to be changed to reflect a 32bit build, and the DEFINES had to remove theÂ HIGHFIRST define, as the x86 platform is little endian.</p>
<p style="padding-left: 30px;">CC=cc -arch i386</p>
<p style="padding-left: 30px;">DEFINES= -DUNIX -DPSEUDORANDOM -DUNIT16 -DPORTABLE</p>
<p>Is the relevant changes.</p>
<p>And even better it&#8217;ll work!</p>
<p style="padding-left: 30px;">$ pgp pgp.ctx pgp.exe</p>
<p style="padding-left: 30px;">Pretty Good Privacy 1.0 &#8211; RSA public key cryptography for the masses.<br />
(c) Copyright 1990 Philip Zimmermann, Phil&#8217;s Pretty Good Software. 5 Jun 91</p>
<p style="padding-left: 30px;">File has signature. Public key is required to check signature.<br />
File &#8216;pgp.ctx&#8217; has signature, but with no text.<br />
Text is assumed to be in file &#8216;pgp.exe&#8217;.<br />
.<br />
Good signature from user &#8220;Zimmermann, Philip R. &#8211; prz@sage.cgd.ucar.edu&#8221;.<br />
Signature made Wed Jun 5 13:51:18 1991</p>
<p style="padding-left: 30px;">Signature and text are separate. No output file produced.<br />
Plaintext filename: pgp.exe</p>
<p>Wasn&#8217;t that great!</p>
<p>Now getting this to run on Windows was a little bit more of a challenge. Â I was going to build from the UNIX source code again, however both Visual C++, and Watcom C++ build an executable, but neither are able to add keys to the keyring, verify the executable reliably and deadlock all the time.</p>
<p>So I thought I&#8217;d get a little creative and start replacing some code from the <a href="http://vpsland.superglobalmegacorp.com/old/install/encryption/pgp/pgp10src.zip">MS-DOS version of PGP</a>. It turns out that all I needed was rsaio.c &amp; rsaio.h and I was able to build an executable. Â But I ran into other snags, and stack errors. Â A glance at the MS-DOS Makefile, and I saw that they had to up the stack size from the defaults. Â So I figured the same would hold true, and I picked a much larger 32kb stack for the heck of it. Â I mean it is 2014, and if you can&#8217;t handle a 32kb stack well..</p>
<p>Compiling on Visual C++ went like this:</p>
<p style="padding-left: 30px;">cl386 -c /DPSEUDORANDOM /DUNIT16 /DPORTABLE *.c<br />
cl *.obj /F32768 /Fepgp.exe</p>
<p>And for Watcom C++</p>
<p style="padding-left: 30px;">wcl386 -c -dPSEUDORANDOM -dUNIT16 -dPORTABLE *.c<br />
wcl386 *.obj -fe=pgp.exe -k32768</p>
<p>And now I can build for either compiler. Â And even better, it works!</p>
<p><div id="attachment_4476" style="width: 670px" class="wp-caption aligncenter"><a href="https://virtuallyfun.com/wp-content/uploads/2014/08/win32-pgp.png"><img fetchpriority="high" decoding="async" aria-describedby="caption-attachment-4476" class="size-full wp-image-4476" src="https://virtuallyfun.com/wp-content/uploads/2014/08/win32-pgp.png" alt="PGP 1.0 on Win32" width="660" height="342" /></a><p id="caption-attachment-4476" class="wp-caption-text">PGP 1.0 on Win32</p></div></p>
<p>Even for completness sakes, DOS4G/W works as well! Just remember to link for MS-DOS</p>
<p>wcl386 *.obj -fe=pgp.exe -k32768 -l=dos4g</p>
<p>And you should be good to go.</p>
<p><div id="attachment_4477" style="width: 1323px" class="wp-caption aligncenter"><a href="https://virtuallyfun.com/wp-content/uploads/2014/08/pgp-dos4gw.png"><img decoding="async" aria-describedby="caption-attachment-4477" class="size-full wp-image-4477" src="https://virtuallyfun.com/wp-content/uploads/2014/08/pgp-dos4gw.png" alt="PGP for 32bit MS-DOS" width="1313" height="441" /></a><p id="caption-attachment-4477" class="wp-caption-text">PGP for 32bit MS-DOS</p></div></p>
<p>So what happened to PGP? Â Well version 2 used a more &#8216;acceptable&#8217; encryption, the IDEA cypher, then the company was sold, IP was sold again and again. Â It&#8217;s still out there, mostly for email encryption.</p>
<p>While it sure did ignite the world on fire for a while, the overall difficulty of using it, combined with the ease of losing the private key and all your data is just too easy. Â But this really is the nature of the beast.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://virtuallyfun.com/2014/08/22/fun-with-pgp-1-0/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>
