Personal info for msh

This person is currently certified at Journeyer level.

Name: Matthew Hamrick

Homepage: http://www.cryptonomicon.net/msh/

Notes:

This is where I document my fun experiments with Squeak. I've a few other sites I contribute content to though:
<dl> <dt>Stacking Fault</dt> <dd>This is my main blog. There's no telling what you'll find here. Whatever strikes my fancy at the time.</dd> <dt>Security Technique</dt> <dd>Security Technique is a web magazine I started a couple years ago to be sort of a slashdot meets Salon for the security technology development community. But alas, the real world got in the way. One day I hope to return.</dd> </dl>

And the good folks at Technorati came up with the following javascript bits to track this blog... But alas, script tags aren't enabled through this interface... &ltscript type="text/javascript" src="http://embed.technorati.com/embed/vugs9q8dw.js"&gt&lt/script&gt

This person is:

Recent diary entries for msh:
RSS

10 Jan 2006  »

Parsing WebStats with Squeak

Over the past month I've become obsessed with usage reports for web sites: Analog, awstats, et al. I was not completely satisfied with what I was getting from the existing packages, so I decided to roll my own. You can see what I'm doing by filing in http://www.revejo.org/msh/changesets/msh-webstat.1.cs. An example of how to use the classes defined there is included in the changeset preamble. And for good measure, it's included here as well.

| a f1 f2 f3 r2 r3|
r3 _ AccessLogBaseReporter new.
r2 _ AccessLogBaseReporter new.
f3 _ AccessLogFilter new.
f2 _ AccessLogFilter new.
f1 _ AccessLogFilter new.
a _ AccessLogReport new.
r3 id: 'successful'.
r2 id: 'all'.
f2 addDestination: r2.
f2 addFilter: [ :i | true ].
f2 source: f1.
f3 addDestination: r3.
f3 addFilter: [ :e | ( e result ) = 200 ].
f3 source: f1.
f1 addDestination: f2.
f1 addDestination: f3.
f1 addFilter: [ :i | true ].
f1 source: a.
a
	stream: ( AccessLogStream with: (FileStream oldFileNamed: '/Users/mhamrick/Documents/Sites/Cryptonomicon.Net/access-log' ) );
	filter: f1.
( a report ) printOn: Transcript.
Transcript flush.

Essentially what you do is you create a chain or tree of objects. The trunk of the tree is an instance of the AccessLogReport class. You pass it a 'filter' and a 'stream'. The stream should be an instance of AccessLogStream (as demonstrated above.) The filter is an object that responds to the filtering and reporting protocol.

In the example above, the f1 is a simple "connector" filter. The only thing it does is receive events from its inputs and pass them on to its outputs. In this case, the outputs are two other filters: f2 and f3. f2 is a filter that simply passes all it's results to the reporter r2. f3 is a filter that passes events whose result was 200 (as opposed to 404 or 403) to the reporter r3.

Both r2 and r3 are "base reporters" meaning they track total hits, unique ips, and total bandwidth.

It's kinda rough right now, but I hope to make it a little more interesting over the next couple of weeks.

11 Dec 2005  »

Simple BASH script for creating a new Squeak instance

One of the things that I find myself doing on a regular basis is filing out changes, re-installing, and then filing selected changes back in to the new installation.

The main reason I'm doing this is that I'm playing around with some of the language's core features: Class, Behavior and various aspects of message contexts. Ocassionally I'll do something really, really bad which results in an unrunnable image. More frequently I'll modify certain core behaviors that make things run funny, or at least I fear that they're running funny, and want to start again from a fresh install.

So I now have a "stable" squeak directory, along with a host of various directories that include different experiements. The stable directory is pretty stable, but experiments come and go with alarming regularity. So I finally got tired of reinstalling Squeak and implementing the standard changes I make, so I came up with the following script to do it for me.

What I've done is I downloaded a standard Squeak install, made a common changes to the image, and then I saved it in a common source directory. The idea here is that when it's time to experiment, I simply issue a single unix command to get a new directory with a new squeak instance.

One of the things I've done is that I make links to files and directories when I can, and only copy the image and changes file.

I started by creating the ~/Library/Squeak directory. In that directory I put the common and 3.8 directories. In the common directory, I put the SqueakV3.sources file. In the 3.8 directory, I put the Plugins directory and the files ReadMe.txt, Squeak3.8-6665.image and Squeak3.8-6665.changes.

I modified everything to be read-only (though Plugins and directories are still executable.) I then crafted the following script that creates a new directory with a name I give it, then links to and copies files into the new directory.

I'm not entirely certain that non-Macophiles be able to use it without modification, but I figured it might be handy for MacOS-X users out there. For everyone else, it might be a handy template.

#!/bin/bash
if [ "${SQUEAKIFY_SOURCE_REVISION}t" == "t" ]; then 
  SQUEAKIFY_SOURCE_REVISION="3.8"
fi

if [ "${SQUEAKIFY_SOURCE}t" == "t" ]; then SQUEAKIFY_SOURCE="$HOME/Library/Squeak" fi

COMMON_DIR="${SQUEAKIFY_SOURCE}/Common" REVISION_DIR="${SQUEAKIFY_SOURCE}/${SQUEAKIFY_SOURCE_REVISION}"

mkdir $1 ln -s ${REVISION_DIR}/Plugins $1/Plugins ln -s ${REVISION_DIR}/ReadMe.txt $1/ReadMe.txt ln -s ${COMMON_DIR}/SqueakV3.sources $1/SqueakV3.sources cp ${REVISION_DIR}/*image $1 chmod 644 $1/*image cp ${REVISION_DIR}/*changes $1 chmod 644 $1/*changes

9 Dec 2005  »

Improved Hash Function Handling in msh-crypto.2.cs

Just a note to say that I've added support for SHA224, SHA384 and SHA512 to the msh-crypto and msh-crypto-tests packages.

As an interesting aside... the SUnit tests for the SHA384 and SHA512 appear to fail, but when I execute the code in the tests manually (i.e.- I paste it into a Workspace window and DoIt) I get the correct results. Not sure what to think about that...

The SHA384 and SHA512 implementations are quite slow. This has to do mostly with the fact that these algorithms assume we have 64 bit values, so we see a lot of our friend the LargePositiveInteger. These classes could use a pretty good refactoring, but I'm more likely to work on more Symmetric Ciphers and Modes of Operation first.

If you're interested, you can pick up the latest changeset at http://www.cryptonomicon.net/msh/changesets/msh-crypto.2.cs and http://www.cryptonomicon.net/msh/changesets/msh-crypto-test.2.cs. Note it's being released under a BSD License, not Squeak-L. But please feel free to play around with these classes and let me know what you think. There's documentation in the MessageDigest class on how to use these classes.

8 Nov 2005 (updated 8 Nov 2005)  »

Demo of "secure" Password holder

A couple days ago Andreas Raab posted to the Croquet dev list saying he had pushed out a couple images with MC passwords built into them. Sure it's a security faux pas, but you would think that by now we wouldn't have to bury passwords inside images. Some of the blame here goes to the tool; there should be a "secure vault" for Squeak.

Chris Mueller posted a quick note about KryptOn ( documented at http://minnow.cc.gatech.edu/squeak/5785 ). I think he's putting the finishing touches on that code, and it promises to be pretty cool.

I've been working on the security roadmap for Spoon over the last couple of weeks. A full-featured "vault" to store private things (like passwords, shared secrets, private keys) and public things (like certificates) is in the roadmap. Having been "programming in PowerPoint(tm)" for the last couple of days (which is my way of saying I've been drawing a bunch of boxes and not actually coding) has left me wanting to hack a little code. So.. I put together a brief demo of how a "secure" password vault might look to an client method.

Assuming you're running the Spoon control image and don't have the msh-crypto classes loaded, you can file in the change set at http://www.cryptonomicon.net/msh/squeak/msh-passdemo.1.cs . Sadly there's something funky going on with the changeset loader in Squeak 3.8 that makes it difficult to load the changeset. If you're running Squeak3.8, you can use the changeset from http://www.cryptonomicon.net/msh/squeak/spoon-pass-demo-for-squeak38.1.cs.

Here are a few notes from the class documentation about the "SpoonPassword" class (note that it's simply named Password in the spoon changeset.)

The SpoonPassword is one of a long line of simple password holders for Squeakish smalltalks. This one was developed for Spoon.

The SpoonPassword class responds to #at: and #at:put: messages so it looks like a dictionary to clients. If you want to "securely" hold a password, you simply add it to the SpoonPassword dictionary like so:

SpoonPassword at: 'celeste:account:msh@cryptonomicon.net' put: 'Dingos'

To retrieve the password for this account, use the invocation:

SpoonPassword at: 'celeste:account:msh@cryptonomicon.net'

The next time you save the image, you will be prompted for a master key for the "secure" vault these passwords live in.

Now... you might be one of these people that doesn't like being prompted for passwords. That's okay; I understand. I have a list of passwords as long as my arm, and the main purpose of this class is to keep passwords out of images that get sent around on development lists.

If you look closely, you'll see that I've added a method to Preferences called #secretVaultPassword. It currently returns nil, but if you set it to return something non-nil, you'll have an image that has the master password for the local copy of your secret vault. This is sorta playing fast and loose with the concept, but hey, I'm all about giving people enough rope to hang themselves.

If you're going to set the secretVaultPassword, don't distribute your svault.bin file.

And what's wrong with this implementation?

So I wrote this as a quick demo in response to a question from Andreas Raab. It's similar in theory to something we're planning on adding to Spoon, so I figured I would release it into the wild and see if anyone had any constructive criticism of the code. The implementation is pretty darn'd poor. But the interface I think is reasonable. Here's a quick list of things that are wrong with the implementation:

* Using a vernam cipher with a magic cookie in the front. ARC4 has a additive feature such that when you take one plaintext, encrypt it with two different keys and then XOR the two ciphertexts together, you get the XOR of the two keystreams. This is bad.

* Using "stock" ARC4 is generally considered bad. ARC4 has been the target of a lot of successful cryptanalysis lately. What we SHOULD do is come up with a fast version of AES for Spoon and use that instead. Hmm... oddly enough... this is on the roadmap.

* The svault.bin parser is laughable. No... seriously... if you want a good laugh look at my parser.

* There are no tests.

* It keeps asking you if you're sure you want to save the file or overwrite it. I've got to look at the logic once more.

* It doesn't give you a clean option to cancel flushing the passwords to disk (which requires you to type in a password before shutting down.)

* It uses ARC4. Yeah, I mentioned this before. But this is bad enough to mention twice.

* It's only a password vault, not the full PKCS12ish thing we want to eventually have.

Anyhow... I hope this code is of interest to someone out there. Feel free to pelt me with comments or questions.

-Cheers, -Matt H.

27 Oct 2005 (updated 27 Oct 2005)  »

Ship, Captain, Crew in Smalltalk

I can't tell you how many time's I've wanted to play Ship, Captain and Crew but just didn't have any dice handy. Now with this handy class, I can play as much as I want, all without ever leaving Squeak!

The code is available as a changeset at http://www.cryptonomicon.net/msh/squeak/msh-scc.1.cs.

So for all you pirates out there, the main class you should be interested in is ShipCaptainCrew. This class' instances model a SCC game where you have 3 throws of 5 dice to get a 6, 5 and a 4 (in that order) with the goal that you're trying to have the other two dice add up to a high score. After installing the changeset, all you need do is evaluate the following with printIt:

( ShipCaptainCrew new ) throw; throw; throw; score

I'm ashamed of the fact that I didn't include a ShipCaptainCrewMorph in the distribution. Hey... everyone loves nice UIs. But if you happen to have a Transcript open, you can see the blow by blow of the three rolls. My goal was to actually write the morph, but the real world got in the way and I don't have time for that right now.

If you want to code up a Morph to add a nice UI, it shouldn't be that difficult. I use methods to access the various instance variables used by each instance. Plus I defined a UI category. The current version doesn't do anything with the UI other than emit text to the transcript, but if you were clever, you could probably override the UI methods in a subclass, including liberal use of #changed and #update to make a pretty straight-forward model for Morphic or MVC.

Another reason you might want to subclass this guy is to change the default behavior of the evaluator. After each throw, I call the #evaluate method to figure out which dice I should save and which I should throw next time (if you're looking at the Transcript output of this class, numbers in parentheses are rolls the evaluator thinks we should keep.) I created a subclass called SimpleStrategySCC that overrides the #evaluate method that implements the simple strategy of not rerolling dice that are 4, 5, or 6. Maybe you have a better strategy? If so, all you have to do to test it is write a subclass that overrides #evaluate. So if you want to test out SimpleStrategySCC, just evaluate the following:

(SimpleStrategySCC new) throw; throw; throw; score

Finally... I pulled the same trick with the randomosity category that I used in the Star Trek plot generator. I would love to use real random numbers, but c'mon, SCC just isn't that important to warrant the extra work.

And for the truely geeky... you can simulate a game of SCC with more than 5 dice by using the #new: method on ShipCaptainCrew.

Okay, that's enough. There's not too much more to say other than I justified spending the time to write this by telling myself it's a good example of how to design a model for a MVC triad. I like to think that the structure of this implementation shows how you can separate behaviors between implementations and use subclassing to extend object behavior. I like to think it's well documented, and I hope it's easy to understand.

8 older entries...

This person has certified others as follows:

Others have certified this person as follows:

[ Certification disabled because you're not logged in. ]

[ Home | Articles | Login/Account | People | Projects ]