I don't know whether this is the right place to pose this question,
but I don't know any better group:
When I tried to implement the md5 algorithm in c I never got the
expected digests until I looked up the appendix of rfc1321 where
Rivest gives an reference implementation in C.
The RFC says "append the length of the message (before padding) as two
32-bit words, least significant word first, lsb-first as well. But
actually Rivest does save the length in a 32-bit word but then shifts
it 3 bits to the left!
What I get for a message length of one:
0x00000001 0x00000000
But he gets:
0x00000008 0x00000000
Does anyone know the reason for that and can explain it to me? Or does
anyone have a least a clue? 7 3123
"Sloede" <mi***************@sloede.com> wrote in message
news:6a*************************@posting.google.co m... I don't know whether this is the right place to pose this question, but I don't know any better group:
It isn't. But I don't know anywhere better either.
[snip] The RFC says "append the length of the message (before padding) as two 32-bit words, least significant word first, lsb-first as well. But actually Rivest does save the length in a 32-bit word but then shifts it 3 bits to the left!
It would appear that the length referred to in your quote is measured in
bits not bytes.
Alex
>When I tried to implement the md5 algorithm in c I never got the expected digests until I looked up the appendix of rfc1321 where Rivest gives an reference implementation in C.
The RFC says "append the length of the message (before padding) as two 32-bit words, least significant word first, lsb-first as well. But actually Rivest does save the length in a 32-bit word but then shifts it 3 bits to the left!
Doesn't rfc1321 define the length of the message as being *IN BITS*,
not bytes?
Gordon L. Burditt
"Sloede" <mi***************@sloede.com> wrote in message
news:6a*************************@posting.google.co m... I don't know whether this is the right place to pose this question, but I don't know any better group:
When I tried to implement the md5 algorithm in c I never got the expected digests until I looked up the appendix of rfc1321 where Rivest gives an reference implementation in C.
The RFC says "append the length of the message (before padding) as two 32-bit words, least significant word first, lsb-first as well. But actually Rivest does save the length in a 32-bit word but then shifts it 3 bits to the left!
What I get for a message length of one:
0x00000001 0x00000000
But he gets:
0x00000008 0x00000000
Does anyone know the reason for that and can explain it to me? Or does anyone have a least a clue?
Length is in bits not bytes.
Free MD5 [among many others] source in portable C at http://libtomcrypt.org
Tom go***********@sneaky.lerctr.org (Gordon Burditt) wrote in message news:<bu********@library2.airnews.net>... Doesn't rfc1321 define the length of the message as being *IN BITS*, not bytes?
Gordon L. Burditt
Phew, this piece of information I just oversaw. Thanks to all for
helping me, though this isn't actually the right group to ask (but
noone did name a more appropriate one, hence it didn't seem to be a
very bad choice).
Michael Schlottke
Alex Fraser wrote: "Sloede" <mi***************@sloede.com> wrote in message news:6a*************************@posting.google.co m...
I don't know whether this is the right place to pose this question, but I don't know any better group:
It isn't. But I don't know anywhere better either.
comp.programming springs to mind, as this is an algorithm and,
therefore, independent of any specific language. But maybe the
comp.programming folks would see things differently.
comp.lang.c would be a good place to come when you have an
implementation in standard C and it either a) doesn't work, or b) you
want to make it more portable (even standard C leaves enough up to the
implementation to make this a bit of a task if you're inexperienced).
Then the regs here wouldn't focus on your algorithm as much as your
code, but [OT] posts (that is, posts that are knowingly off-topic with
[OT] in their name) eventually crop up in most large threads.
(Need I say that we don't like having non-standard C in comp.lang.c?
There are plenty of places to ask about compiler-specific extensions and
modifications, including header files like conio.h and dos.h, or
unistd.h and wait.h. We usually aren't rude, but we are pretty firm.) [snip]
The RFC says "append the length of the message (before padding) as two 32-bit words, least significant word first, lsb-first as well. But actually Rivest does save the length in a 32-bit word but then shifts it 3 bits to the left!
It would appear that the length referred to in your quote is measured in bits not bytes.
Everyone else seems to concur with this assessment. It seems natural,
anyway: Who treats bits as a datatype these days? Even in C, the
smallest primitive type is the char, which maps naturally to the concept
of a byte. (CHAR_BITS == 8 for most implementations, and I think it is
guaranteed to be at least 8 for all conformant ones.)
--
My address is yvoregnevna gjragl-guerr gjb-gubhfnaq guerr ng lnubb qbg pbz
Note: Rot13 and convert spelled-out numbers to numerical equivalents.
"August Derleth" <se*@sig.now> wrote in message
news:aq*****************@fe02.usenetserver.com... Everyone else seems to concur with this assessment. It seems natural, anyway: Who treats bits as a datatype these days? Even in C, the smallest primitive type is the char, which maps naturally to the concept of a byte. (CHAR_BITS == 8 for most implementations, and I think it is guaranteed to be at least 8 for all conformant ones.)
Most implementations are octet oriented (e.g. compress an array of 64
"chars") so even on platforms where CHAR_BIT >= 9 the algorithms will work
provided you only put message bits in the lower 8 bits.
Technically though MD5 is bit oriented [can hash any arbitrary length
message]. However, it's not really useful that way since you can't really
transmit/store odd-lengths to most mediums anyways.
Tom This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Deniz Bahar |
last post by:
Hello,
A couple days ago my friend (OOP guy) shows me what OOP was all about
in C++. This morning I figured I can do pretty much the same thing
with C (by putting function pointers in...
|
by: Benny C. Mildh |
last post by:
Hi!
I'm trying to implement my own CanConvertTo-method from the derived
TypeConverter class.
Public Overrides Function CanConvertFrom(ByVal context As
ITypeDescriptorContext, ByVal sourceType...
|
by: nate axtell |
last post by:
I'm trying to create a custom DataGridBoolColumn. I inherit
DataGridColumnStyle and create a public CheckBox variable. This columnType
will be mapped to a dataTable boolean column. What are the...
|
by: Jonathan Wood |
last post by:
Greetings!
I am still trying to determine the best way to implement a Web site that
contains many documents that visitors can read. Most of the suggestions I've
been given indicate that I should...
|
by: RichG |
last post by:
With the help of Cor Ligthert in a pryor post I was able to make this
sub:
Public Sub disableControls(ByVal frm As Form)
'this is to create a read only form that has active buttons
Dim x As...
|
by: ragtag99 |
last post by:
I posted this on comp.lang.asm.x86, alt.os.development, comp.arch,
comp.lang.c++
Im working with windows xp professional, NTFS and programming with
MASM, c++ (free compiler) or visual basic 6.0...
|
by: RSH |
last post by:
Hi,
I have been reading on interfaces working on samples I've run across on the
web. For the life of me I cannot seem to grasp them.
It appears to me that interfaces are simply blueprints to...
|
by: jm |
last post by:
I am having trouble understanding the purposes of an interface, even
though the concept of interfaces is around me all the time (user
interface, for example). I'm just not understanding software...
|
by: emin.shopper |
last post by:
I had a need recently to check if my subclasses properly implemented
the desired interface and wished that I could use something like an
abstract base class in python. After reading up on metaclass...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |