views:

383

answers:

3

I would like to sign a device, and I have 64 bits to store my signature in the device. This device has a MAC address and some other details (about 30 bytes worth) I can mangle to create my signature.

If possible, I would like the method to be one-way, so that I can verify that the signature is valid without knowing how to create a valid signature. Most public-private keys have this feature but they generate signatures that are 48 bytes long (I only have 8 bytes).

Implementation in Python is a plus.

Thanks

EDIT: Thanks for the advice everyone. It sounds like there is no secure way to do this, only a way that is moderately inconvenient to attackers. I'll probably use a cryptographic hash combined with secret bit-shuffling. This will be as secure as any other link in my (very weak) 'security'.

A: 

You could just use a standard hashing function (MD5 SHA1) and only use the first or last 30 bytes.
The number of bytes a hashing function generates is fairly arbitrary - it's obviously a trade off between space and uniqueness. There is nothing special about the lenght of the signature they use.

Edit - sorry I was thinking that MD5 returned 32bytes- it actaulyl returns 16bytes but is ussually written as 32hex digits.

Martin Beckett
The problem with this solution is that it is very easy for someone else to figure out which hashing algorithm I used and create their own signatures. I'm considering a standard hash followed by bit shuffling but it is symmetrical (to test the signature is to create the signature)
Tom Leys
You _could_ use keyed hashing, that way the secret is with you. So, HMAC-MD5 or HMAC-SHA1, possibly truncated. I don't know about the security of this truncation, mind you.
Chris Jester-Young
Of course, keyed hashing means that the key used to sign needs to be with the verifier too (symmetric). Oh well. Maybe there is a way to do asymmetric keyed hashing. :-P
Chris Jester-Young
Keyed hashing is the best I can come up with, without trying to re-implement DSA (http://en.wikipedia.org/wiki/Digital_Signature_Algorithm) with very small keys.
Tom Leys
+2  A: 

Basically what you need is a 64-bit cryptographic hash funcion, such as Ripemd-64 or elf-64. Then you encrypt the hash with a cryptographic method and you got a 64 bit signature. The only problem is, from the point of view of a non-cryptoanalyst, that 64 bit offers a much weaker signature than typical over-128 bit hash. Nonetheless it could still be suitable for your application.

Fernando Miguélez
Yeah, it is a pretty weak signature. We are happy to live with "it is harder to crack the signature than to crack something else". Any suggestions for the cryptographic method? Can I use something "Off the shelf?"
Tom Leys
I would use RSA. There are various RSA implementations for Python out there, including a pure-python one (http://pypi.python.org/pypi/rsa)
Martin v. Löwis
I have been looking around to find a suitable encryption method that gives the required output of 64 bits but it is not an easy task. Surely because such a weak encryption algorithm is more useless. What about using sth secret along with hash computing method?
Fernando Miguélez
+3  A: 

Hash functions and digital signatures are very different things.

The size of a digital signature depends on the underlying hash function and the key length. So in theory, you can create an RSA implementation that generates 64-bit signatures, but that'd be an extremely weak signature.

For smaller key lengths, you might want to look at elliptic curve cryptography.

EDIT: Yes, I'm a cryptographer.

EDIT 2: Yet if you only need a hash function, you can look at elf64 or RIPEMD-64 as Fernando Miguélez suggested.

EDIT 3: Doing the math, you'd need to use 16-bit keys in ECC to generate 64-bit signatures, which is very weak. For ECC, anything less than 128 bits can be considered weak. For RSA this is 1024 bits.

Can Berk Güder
If it is that weak, is it worth using a standard algorithm at all? Should I just go the hash and scramble method and hope that security by obscurity saves the day?
Tom Leys
Security by obscurity *never* works. First thing I learned in college. =)
Can Berk Güder
Although 16-bit security is no security at all.
Can Berk Güder