<?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>From Accessibility to Zope &#187; Crypto</title>
	<atom:link href="http://blog.mauveweb.co.uk/category/crypto/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.mauveweb.co.uk</link>
	<description>experiments in contemporary web development</description>
	<lastBuildDate>Thu, 18 Aug 2011 23:26:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Paypal Encrypted Web Payments</title>
		<link>http://blog.mauveweb.co.uk/2007/06/14/paypal-encrypted-web-payments/</link>
		<comments>http://blog.mauveweb.co.uk/2007/06/14/paypal-encrypted-web-payments/#comments</comments>
		<pubDate>Thu, 14 Jun 2007 18:33:20 +0000</pubDate>
		<dc:creator>mauve</dc:creator>
				<category><![CDATA[Crypto]]></category>
		<category><![CDATA[e-Commerce]]></category>

		<guid isPermaLink="false">http://blog.mauveweb.co.uk/2007/06/14/paypal-encrypted-web-payments/</guid>
		<description><![CDATA[I've spent this afternoon fighting with Paypal's developer sandbox to make encrypted web payments work. This is the system of whereby the details of an order are transferred as a form field encrypted with public key cryptography, but I wouldn't expect anyone to know that because Paypal has a wide glossary of internal terminology that [...]]]></description>
			<content:encoded><![CDATA[<p>I've spent this afternoon fighting with Paypal's developer sandbox to make encrypted web payments work. This is the system of whereby the details of an order are transferred as a form field encrypted with public key cryptography, but I wouldn't expect anyone to know that because Paypal has a wide glossary of internal terminology that is almost impenetrable to the novice.</p>
<p>I have never done a particularly large amount with Paypal. It's come up occasionally but I've always done the hastiest job possible, perhaps pasting some code from PaypalTech.com or something. This time I've been working in Python with Django so I've had to develop everything from scratch with the M2Crypto OpenSSL wrapper. Paypal's developer documentation lacks sufficient detail for a clean-room implementation (thought there are numerous examples to be found, none exactly corresponded to M2Crypto/Python). Furthermore, it does not give useful error messages, which can make it extremely troublesome to integrate with.</p>
<p>This is how I made <acronym title="(PayPal) Encrypted Web Payments">EWP</acronym> work.</p>
<ol>
<li>Paypal expects data to arrive as a set of key-value pairs, which you should already have/know about. The documentation for these is extensive.</li>
<li>Make the payment system work unencrypted, using input fields with the corresponding names and values to the key-value pairs. This ensures that the information PayPal needs to receive is correct before you start faffing with encrypting that data. If you do not have a PayPal account, you can sign up for a "sandbox" account, then register as many scratch accounts as you like. Note that PayPal does not email you the confirmation emails for sandbox account; they appear in the sandbox interface under the "Emails" tab.</li>
<li>Generate an <acronym title="Secure Sockets Layer">SSL</acronym> keypair in <acronym title="Privacy Enhanced Mail">PEM</acronym> format with <code>openssl genrsa</code> . If you view this file, it is titled as "PRIVATE KEY", but it does contain both private and public keys. The exact commandline arguments for this command are documented in the <a href="https://www.paypal.com/en_US/pdf/PP_WebsitePaymentsStandard_IntegrationGuide.pdf">PayPal Website Payments Standard Integration Guide</a>.</li>
<li>Generate a self-signed <acronym title="Secure Sockets Layer">SSL</acronym> certificate from your keypair with <code>openssl req</code>. An <acronym title="Secure Sockets Layer">SSL</acronym> certificate contains your public key, some details about the owner, and one or more cryptographic signatures. Again, this is well documented.</li>
<li>Exchange certficates with PayPal by logging in and visiting "Encrypted Web Payments" under "Profile". You save PayPal's certificate to a file, and upload your own. Paypal assigns a certificate ID to your certificate, which you must now add to your key-value pairs under the key <code>cert_id</code> . It displays this certificate ID in the table and will also email you a copy. Recall however, that PayPal's sandbox development server does not actually email you; "emails" are stored and are available on the web interface under the "Emails" tab.</li>
<li>Generate the plaintext for the signing by encoding the key-value pairs as <code><em>key</em>=<em>value</em></code> , separated only by linefeed (\n, <acronym title="American Standard Code for Information Interchange">ASCII</acronym> 0&#215;0a) characters. <acronym title="Carriage Return">CR</acronym>-<acronym title="Line Feed">LF</acronym> does not work.</li>
<li>Sign the plaintext using <acronym title="Secure Multipurpose Internet Mail Extensions"><acronym title="Secure Multipurpose Internet Mail Extensions">S/MIME</acronym></acronym>. This requires both your private key (for the cryptography) and your certificate (to identify whose signature it is). Use these options:
<ul>
<li>Use binary input mode, which prevents OpenSSL munging its input.</li>
<li>Encode the data in opaque form. This implies that the text to be signed is encoded along with the signature, as opposed to detached, which doesn't encode the plaintext.</li>
<li>Output the resulting <acronym title="Public Key Cryptography Standards">PKCS7</acronym> structure in <acronym title="Distinguished Encoding Rules">DER</acronym> (<strong>not <acronym title="Privacy Enhanced Mail">PEM</acronym>, nor <acronym title="Secure Multipurpose Internet Mail Extensions"><acronym title="Secure Multipurpose Internet Mail Extensions">S/MIME</acronym></acronym></strong>) format. This is a binary format.</li>
</ul>
</li>
<li>Encrypt the resulting <acronym title="Distinguished Encoding Rules">DER</acronym> using PayPal's certificate (ie. public key):
<ul>
<li>Again, use binary input mode</li>
<li>Use the 3-key triple-<acronym title="Data Encryption Standard">DES</acronym>, <acronym title="Cipher-Block Chaining">CBC</acronym> mode block cipher. OpenSSL calls this des-ede3-cbc or just des3.</li>
<li>Output the resulting <acronym title="Public Key Cryptography Standards">PKCS7</acronym> structure in <acronym title="Privacy Enhanced Mail">PEM</acronym> format, which is a base64-encoded format.</li>
</ul>
</li>
<li>Insert the <acronym title="Privacy Enhanced Mail">PEM</acronym> blob into a form field named <code>encrypted</code>. There must also be a hidden value form field, named <code>cmd</code>, with value <code>_s-xclick</code>.</li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://blog.mauveweb.co.uk/2007/06/14/paypal-encrypted-web-payments/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MP3-spliced Encrypted Filesystem</title>
		<link>http://blog.mauveweb.co.uk/2006/10/10/mp3-spliced-encrypted-filesystem/</link>
		<comments>http://blog.mauveweb.co.uk/2006/10/10/mp3-spliced-encrypted-filesystem/#comments</comments>
		<pubDate>Tue, 10 Oct 2006 02:26:46 +0000</pubDate>
		<dc:creator>mauve</dc:creator>
				<category><![CDATA[Crypto]]></category>

		<guid isPermaLink="false">http://blog.mauveweb.co.uk/2006/10/10/mp3-spliced-encrypted-filesystem/</guid>
		<description><![CDATA[I've had a crazy idea for a way of protecting data using an MP3 collection. It's completely ridiculous, inefficient, and it can probably be shot to pieces. But it's fun.
MP3 streams consist of a bundle of frames. Frames begin with a 12-bit string of zeros, then there is a brief header which gives the bitrate [...]]]></description>
			<content:encoded><![CDATA[<p>I've had a crazy idea for a way of protecting data using an <acronym title="MPEG 1 Layer 3 Audio">MP3</acronym> collection. It's completely ridiculous, inefficient, and it can probably be shot to pieces. But it's fun.</p>
<p><acronym title="MPEG 1 Layer 3 Audio">MP3</acronym> streams consist of a bundle of frames. Frames begin with a 12-bit string of zeros, then there is a brief header which gives the bitrate and length of the frame, then the frame data. <acronym title="MPEG 1 Layer 3 Audio">MP3</acronym> players should wait for the 12-bit sync, then read the frame, then wait for another sync (in most <acronym title="MPEG 1 Layer 3 Audio">MP3</acronym> data this follows immediately).</p>
<p>It should be possible to bung in random bytes in there between frames and have players ignore it completely.</p>
<p>What if the bytes you stick in there comprise a filesystem? Say you use 10 6MB <acronym title="MPEG 1 Layer 3 Audio">MP3s</acronym> and pad them by say 10% with the filesystem data. 6MB filesystem! Enough for your most important secrets, and nobody is going to look for it there. Security through obscurity. Still, that's only version 1 of the protocol (ie. it occurred to me first).</p>
<p>Version 2: use a block cipher to encrypt the filesystem. Obviously, this is important as otherwise plaintext bytes are readily visible.</p>
<p>Version 3: hide the <acronym title="MPEG 1 Layer 3 Audio">MP3s</acronym> that you've used to create the filesystem in a collection of <acronym title="MPEG 1 Layer 3 Audio">MP3s</acronym> &#8211; a large but random number of <acronym title="MPEG 1 Layer 3 Audio">MP3s</acronym> that have been similarly padded, but with junk. Now you need the right <acronym title="MPEG 1 Layer 3 Audio">MP3s</acronym> in the right order. Choosing <em>r</em> <acronym title="MPEG 1 Layer 3 Audio">MP3s</acronym> in the right order from a set of <em>n</em> gives <sup><em>n</em></sup>P<sub><em>r</em></sub> combinations, which, for <em>r</em> << <em>n</em> is approximately <em>n</em><sup><em>r</em></sup>. For example, choosing 10 (in order) from a relatively modest collection of 500 (~ 2<sup>9</sup>) is roughly equivalent to a 90-bit passphrase or a 15-character random password consisting of A-Z,a-z,0-9. But the nice thing about this is that humans should be good at reconstructing playlists from memory, even with thousands of <acronym title="MPEG 1 Layer 3 Audio">MP3s</acronym> to choose from.</p>
<p>Version 4:  Stripe the bytes between different <acronym title="MPEG 1 Layer 3 Audio">MP3s</acronym>. Ensure that cipher blocks are split between <acronym title="MPEG 1 Layer 3 Audio">MP3s</acronym>. This ensures that you can't run a brute force crack attempt against part of the encrypted data because you can't dig a whole block out of any one file.</p>
<p>Version 5: (optionally) use some acoustic element of the assembled <acronym title="MPEG 1 Layer 3 Audio">MP3</acronym> playlist as part of the passphrase for the block cipher. Entering one 'digit' of passphrase might be the equivalent of selecting a riff in the right song, or one particular lyric. Say you have to choose a 5-second segment from your 10 3-minute <acronym title="MPEG 1 Layer 3 Audio">MP3s</acronym> &#8211; that's about 8.5 bits of passphrase.</p>
<p>Version 6: swap some, <strong>but not all</strong> of your <acronym title="MPEG 1 Layer 3 Audio">MP3s</acronym> with <acronym title="Peer to peer">P2Ps</acronym>. There is an element of deniability &#8211; the random data may or may not be yours. Most <acronym title="MPEG 1 Layer 3 Audio">MP3</acronym> collections I've seen have been collected from hundreds of different sources &#8211; and anyone using the system will have lots of <acronym title="MPEG 1 Layer 3 Audio">MP3s</acronym> with a mixture of junk and real padding, so to find many <acronym title="MPEG 1 Layer 3 Audio">MP3s</acronym> containing junk on any one system does not mean they have encrypted data. It just means they are guilty of piracy.<br />
Told you it's completely ridiculous. But isn't it fun? <img src='http://blog.mauveweb.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>]]></content:encoded>
			<wfw:commentRss>http://blog.mauveweb.co.uk/2006/10/10/mp3-spliced-encrypted-filesystem/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

