-----Original Message----- From: owner-openssl-us...@openssl.org [mailto:owner-openssl-us...@openssl.org] On Behalf Of Ger Hobbelt Sent: 19 January 2009 14:00 To: openssl-users@openssl.org Subject: Re: Hashing bit-oriented data
> On Mon, Jan 19, 2009 at 1:48 PM, Young, Alistair <alistair.yo...@logica.com> wrote: > > Hello, > > > > Using the OpenSSL command line, is it possible to compute hashes of > > data which is not a whole number of bytes in length? For example, a > > block of data consisting of (say) 110 bits? > > > > ... snip ... > > Since all [supported] secure hash algorithms are byte, pardon, *word*-based, > the mere definition of those algorithms precludes the possiblity of hashing 110 > bit data bursts without any [bit-]padding. Here, 'word' size depends on the > secure hash algorithm used. So the oversimplified answer is: no can do. > > Given that you don't ask whether particular bit-data-stream oriented secure > hash algorithm XYZ is supported by OpenSSL, while it's not listed in the feature > set, I have a question in return: are you sure you are ware what you are asking > here? If yes, please specify required hash algorithm and other specifics and we > might be able to help you out. Hi Ger - many thanks for the reply. My experience in this area is limited - so I may well be asking a silly question! :) My understanding, however, is that the hashing algorithms (I am specifically thinking of SHA-256) do not place any restrictions on the length of the data being hashed. For example, the pseudocode for SHA-256 given at <http://en.wikipedia.org/wiki/SHA_hash_functions> states that the first steps are: * append bit '1' to the message * append k bits '0' to the message until the length of the message is congruent to 448 (mod 512) * append length (before pre-processing) in bits as a 64-bit integer There appears to be nothing intrinsically byte- or word-based about that logic. So, to take my 110-bit message example, I would hope to be able to pass this in and have the hashing logic append a '1', then 337 '0's, and then the number "110" as a 64-bit integer. This then gives 512-bits (16*32-bit words) for the main hashing algorithm to work with. Am I missing a subtle point somewhere? Cheers, Alistair. Please help Logica to respect the environment by not printing this email / Merci d'aider Logica à préserver l'environnement en évitant d'imprimer ce mail / Bitte drucken Sie diese Nachricht nicht aus und helfen Sie so Logica dabei die Umwelt zu schuetzen / Por favor ajude a Logica a respeitar o ambiente não imprimindo este correio electrónico. This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you. ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager majord...@openssl.org