md5(microtime())

Don’t use md5(microtime()). You might think it’s more secure than md5(rand()), but it isn’t.

With a decent amount of tries and a method of syncing (like a clock on your website) one can predict the result of microtime() to the millisecond. This only leaves about a 1000 different possible return values for microtime() to be guessed. That isn’t safe.

Just stick with md5(rand()), and if you’re lucky and rand() is backed by /dev/random you won’t even need the md5(). In both cases it will be quite a lot more secure than using microtime().

A loud present

Today, a friend of mine, Gerben, gave me a birthday present (a tad late). Not the usual beverages (turned 18 ;)) (usual, but still very well appreciated :)), but a home-made portable speaker with built-in amplifier. Here seen making more sound than the internal speaker of my Thinkpad:

dsc_0050.jpg

It’s a nifty little device: it’s powered by either an internal battery or an external power source.

dsc_0048.jpg

It contains a voltage converter and a rectifier which allows a variable AC power source to be connected. This has been added to be able to connect the speaker to the electrical generator of a bicycle. Why? The previous version of this speaker was taken on the bicycle trip with a few friends to the Hertog Jan Brewery in Arcen (~70km) which was only powered by a battery (which tends to be exhausted).

Even better, when set into external source mode it recharges the battery. And because of the voltage converter, the sound doesn’t get louder when you are cycling faster, but the quality of the sound gets better!

dsc_0051.jpgdsc_0049.jpgdsc_0047.jpg

I’ve had quite some fun dissecting the little device. Thanks again Gerben!

Simple Branch Prediction Analysis

This paper outlines simple branch prediction analysis attack against the RSA decryption algorithm.

At the core of RSA decryption is a loop over all bits of the secret key number d. When the bit 1 there is other code executed than when the bit is 0. The CPU branches on a different bit.

A spy process can be run on the CPU which measures the branch cache of the CPU by flooding the cache with branches and measuring the time it takes. When the sequentially running secret process doing RSA decryption makes a different branch (1 instead of 0) it can be noticed in a change of execution time on the spy process’s branches.

In this way quite a lot of secret bits can be derived.

There are some clear buts:

  • You must be able to insert a spy process on the computer itself and it should know exactly when the RSA process runs.
  • To attain clear readings, there shouldn’t be other processes claiming too much CPU time.
  • The spy and CPU process should run on the same physical processor and preferably at the same time (dual core)

An easy fix would be to allocate a whole processor for the RSA decryption time, so no process can spy. Another option would be to add noise in the Branch Prediction Buffer, but that would result in a performance loss.

RTFM, where?

Recently a buddy on msn asked me a linux question, he just started linux so he had some problems getting stuff done.

He downloaded an installer, he said, a .run, but he doesn’t know how to execute it. He tried googling for it and asking on forums, but didn’t get an answer, so he asked me.

I solved his problem, but I still wondered, where you can find that you need to put ‘./’ in front of a file in bash to execute it and where can you find that you probably need to chmod +x the file too if you downloaded it from somewhere, if you are a total newcomer to linux.

The bash tutorial would’ve probably solved it, but do you know that that thing in which you are typing actually is a separate program? Probably not.

I basically learned all this trivial stuff while following the gentoo installation manual, but I guess that’s a bit too much to ask from each new linux user. There should be a good linux introduction that explains this trivial stuff somewhere to which I can redirect new users. Anyone knows one?

Fallacies (1)

I just read this on slashdot:

statistically significant relationship between autism rates and television watching

Offcourse this relation was explained as televisions causing children to become autistic. This is a very annoying fallacy. Why? Because just maybe children with autism like to watch television more than other children.

If there is a relation, and if it’s not coincidental, there are still two ways to explain it as a cause and effect relation — you cant just blindly assume that one of the two is the cause.

Same goes with relations like:

“Children that play violent games are more likely to become criminals” or “Children that are to become criminals are more likely to play games”

Stupid shout culture.

Good and bad CAPTCHA`s

CAPTCHA’s are images which content needs to be written into a textbox by a user to make sure it’s a human instead of some computer script. This is an example of a good CAPTCHA of yahoo:

yahoo53.jpeg

This is an example of a really bad CAPTCHA:
dotmac18.jpeg

What makes a CAPTCHA good, as in hard to solve by a computer? Lets look how a computer would solve a CAPTCHA, there basically are 3 parts:

  1. Remove rubish background.
  2. Remove rubish lines and partition the image into sections, with in each section a letter.
  3. Recognize the letter with a neural network.

Part 1 is very easy in most cases — just filter everything out that isn’t black and isn’t a glyph-ic curve. It gets a bit more difficult if the font and background colors are random, but usually it’s simple to distinguish between a glyph (small, curve-ish, solid color) and a background (solid, usually gradients). Software is way better in this step than humans.

Part 2 is the most difficult part for software. Distorting fonts isn’t that much of a problem, as long as the software can recognize seperate curve-blobs. The real problem comes in when there are red-hering-curves or when several glyphs are connected with curves like in the yahoo CAPTCHA. When the captcha uses undistorted fixed aligned fonts, it isn’t a problem even if you add glyph connecting curves like in the dotmac CAPTCHA, because you only need to add a little bit of code to recognize an authentic glyph curve (small, thin) and then you can predict the position of the other curves. Humans are better in this step than computers.

Part 3 is a bit tedious for software, but usually easier for specifically trained neural networks than for humans.

How to make a good CAPTCHA:

  • Do not add stupid background or differently coloured polygons, they won’t work at all — they will only confuse the human.
  • Do not use a fixed font, size or alignment. Rotate the font a bit, transform it a bit and, most importantly, place them unpredictably.
  • Add glyph like curves the intersect preferably only two glyphs to make them less recognizable. Take care though that you don’t make them too font like, because that’ll prevent the human from recognizing. These extra intersecting curves make CAPTCHA’s strong, because it prevents proper partitioning.
  • Don’t use strange fonts that might seem hard to see, but are easy recognizable. For instance, dotted fonts are very easy to locate when everything else are solid curves.

Update: nice blogpost on breaking captcha’s: http://www.brains-n-brawn.com/default.aspx?vDir=aicaptcha

T60 (2)

After 2 days installing gentoo on my great T60 I’ve accomplished quite a lot so far:

  • WiFi works. 4 seperate components (userland, firmware, kernel module and yet another kernel module) increase complexity a bit. Although the fifth component caused trouble — I forgot to tweak conf.d/net
  • Radeon X1400 and video card worked almost directly after using aticonf — nice! When I upgraded to xorg-server-1.1, though, I got a few crashes when closing X in a not-so-nice manner.
  • Using the synaptics drivers my touchpad now support drag’n’drop, right and middle mouse click and scrolling emulation. Still got to find a way to bind the thinkpad shortcut to disable/enable the point or pad.
  • Finally got the DVD rewriter to work. It seems I overlooked one little stupid generic E-IDE option in the kernel config.
  • Bluetooth and infrared should work — haven’t got the gadgets to try them out
  • Never even saw a PCCard, so didn’t even bother to look into ti
  • Software suspend (hibernation) doens’t work yet, but I definitely be working on that.

Arcen

Last tuesday I cycled with some friends (about 11) to Arcen to visit the Hertog Jan brewery. The ~75km of cycling went pretty well — way better than expected. We stayed on a 4 star camping for the night and cycled back the next day.

Needless to say, this was a great experience and we all had a lot of fun.

Some photos were made, I’ll post them as soon as I get them.

bcmap 0.1

bcmap is a simply program to be linked against klibc to map Broadcom RAIDCORE disks to more sensible and stable device nodes.

Currently the bcraid drivers assign the next available sd node to a detected disk, which is very inconvenient when you have a usb stick inserted on boot which pushes your root disk from sda to sdb.

bcmap ensures that your first array will always be /dev/bca, which is a nice thing.

>>> bcmap-0.1.tar.bz2 (source code)

Licensed under the (holy) GNU GPL v.2

bcraid drivers part two

Here’s a small patch that tweak the broadcom raid drivers for the bc4000 series to run on the latest kernels:

http://w-nz.com/~darkshines/projects/bcraid-2.1.0-bw1.patch

Note that it is everything but complete. Some other pointers getting the bcraid to work:

  • Use sparse memory or conitguous memory instead of incontiguous memory in the memory layout configuration in the kernel. (CONFIG_SPARSEMEM=y)
  • Enable the magic sysrq key (CONFIG_MAGIC_SYSRQ=y)

At the moment I’m trying to get the bcraid module working in an initrd to allow the root partition on the raid drivers.

The rm -r / typo

Today I accidently made a (yes, very stupid) typo in a root console:

rm -r /

I noticed the typo almost directly, but rm managed to wipe out my /bin and started removing parts of /boot. This situation wasn’t very helpful for the stability of my system, as you might understand.

For the windows user: it’s a bit like deleting half of all executables in the windows folder.

One key difference: when running linux, you can fix it easily. I booted a livecd, mounted my system, copied the /bin from a stage3 tarball to my root partition and rebooted.

And it’s working again! There were some complaints about a libproc version mismatch with the binaries, but that’ll be easily solved by a emerge -e system.

You just got to love linux. (and other nixes for that matter)

SINP: Push versus Pull

SINP is pull based — I give my SINP address to someone, and he will pull the information he wants from my SINP server.

Our competitor SXIP is push based. When I use my SXIP identity I push all information I want to provide to the service — there doesn’t even have to be a SXIP server (‘homesite’).

Push has got certain advantages over pull:

  • Pull is complexer: you need more traffic and more complicated traffic. Push is simpler.
  • You most likely need a seperate server for pull (you need one with SINP at least), this makes you rely on your SINP server. You don’t need a real one for push.

But pull too got advantages:

  • You don’t need to actively give your information. When I’m offline someone can still pull information from my SINP identity.
  • Pull doesn’t require the actual information to go via your computer. If someone requests my creditcard number and I allow it, it won’t be redirected through the computer I’m using, which is safer.