Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
ee72092e
Commit
ee72092e
authored
Jan 06, 2013
by
Davis King
Browse files
merged
parents
63a360e1
33a192fc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
33 deletions
+77
-33
dlib/md5/md5_kernel_1.cpp
dlib/md5/md5_kernel_1.cpp
+67
-33
dlib/test/md5.cpp
dlib/test/md5.cpp
+10
-0
No files found.
dlib/md5/md5_kernel_1.cpp
View file @
ee72092e
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
#include "../uintn.h"
#include "../uintn.h"
#include <sstream>
#include <sstream>
#include <cstring>
namespace
dlib
namespace
dlib
{
{
...
@@ -461,6 +462,7 @@ namespace dlib
...
@@ -461,6 +462,7 @@ namespace dlib
bool
write_length
=
false
;
bool
at_end
=
false
;
bool
at_end
=
false
;
std
::
streambuf
&
inputbuf
=
*
input
.
rdbuf
();
std
::
streambuf
&
inputbuf
=
*
input
.
rdbuf
();
while
(
!
at_end
)
while
(
!
at_end
)
...
@@ -473,7 +475,12 @@ namespace dlib
...
@@ -473,7 +475,12 @@ namespace dlib
{
{
at_end
=
true
;
at_end
=
true
;
unsigned
char
*
temp2
=
temp
;
unsigned
char
*
temp2
=
temp
;
unsigned
char
*
end
=
temp
+
56
;
unsigned
char
*
end
;
if
(
num
<
56
)
end
=
temp
+
56
;
else
end
=
temp
+
64
;
temp2
+=
num
;
temp2
+=
num
;
// apply padding
// apply padding
...
@@ -486,6 +493,9 @@ namespace dlib
...
@@ -486,6 +493,9 @@ namespace dlib
}
}
if
(
num
<
56
)
{
write_length
=
true
;
// make len the number of bits in the original message
// make len the number of bits in the original message
// but first multiply len by 8 and since len is only 32 bits the number might
// but first multiply len by 8 and since len is only 32 bits the number might
// overflow so we will carry out the multiplication manually and end up with
// overflow so we will carry out the multiplication manually and end up with
...
@@ -518,6 +528,7 @@ namespace dlib
...
@@ -518,6 +528,7 @@ namespace dlib
*
temp2
=
0
;
*
temp2
=
0
;
++
temp2
;
++
temp2
;
*
temp2
=
0
;
*
temp2
=
0
;
}
}
}
...
@@ -551,6 +562,29 @@ namespace dlib
...
@@ -551,6 +562,29 @@ namespace dlib
}
}
if
(
!
write_length
)
{
uint64
temp
=
len
*
8
;
uint32
aa
=
a
;
uint32
bb
=
b
;
uint32
cc
=
c
;
uint32
dd
=
d
;
std
::
memset
(
x
,
0
,
sizeof
(
x
));
x
[
15
]
=
(
temp
>>
32
);
x
[
14
]
=
(
temp
&
0xFFFFFFFF
);
scramble_block
(
a
,
b
,
c
,
d
,
x
);
a
=
a
+
aa
;
b
=
b
+
bb
;
c
=
c
+
cc
;
d
=
d
+
dd
;
}
// put a, b, c, and d into output
// put a, b, c, and d into output
output
[
0
]
=
static_cast
<
unsigned
char
>
((
a
)
&
0xFF
);
output
[
0
]
=
static_cast
<
unsigned
char
>
((
a
)
&
0xFF
);
...
...
dlib/test/md5.cpp
View file @
ee72092e
...
@@ -35,6 +35,16 @@ namespace
...
@@ -35,6 +35,16 @@ namespace
DLIB_TEST
(
md5
(
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
)
==
"d174ab98d277d9f5a5611c2c9f419d9f"
);
DLIB_TEST
(
md5
(
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
)
==
"d174ab98d277d9f5a5611c2c9f419d9f"
);
DLIB_TEST
(
md5
(
"12345678901234567890123456789012345678901234567890123456789012345678901234567890"
)
==
"57edf4a22be3c955ac49da2e2107b67a"
);
DLIB_TEST
(
md5
(
"12345678901234567890123456789012345678901234567890123456789012345678901234567890"
)
==
"57edf4a22be3c955ac49da2e2107b67a"
);
// make sure the two versions of md5() always agree
for
(
int
num
=
0
;
num
<
2000
;
++
num
)
{
std
::
string
temp
;
for
(
int
i
=
0
;
i
<
num
;
++
i
)
temp
+=
'a'
;
istringstream
str
(
temp
);
DLIB_TEST
(
md5
(
temp
)
==
md5
(
str
));
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment