-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[third_party] Message-digest algorithm reference implementation
- Loading branch information
Showing
12 changed files
with
1,071 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Description: | ||
# Reference implementations of MD4 and MD5 | ||
# Taken from: | ||
# http://www.ietf.org/rfc/rfc1320.txt (MD4) | ||
# http://www.ietf.org/rfc/rfc1321.txt (MD5) | ||
|
||
licenses(["notice"]) # RSA MD4, MD5 Licenses (see LICENSE.{md4,md5}) | ||
|
||
cc_library( | ||
name = "md_global", | ||
hdrs = ["global.h"], | ||
) | ||
|
||
cc_library( | ||
name = "md4", | ||
srcs = ["md4c.c"], | ||
hdrs = ["md4.h"], | ||
visibility = ["//visibility:public"], | ||
deps = [":md_global"], | ||
) | ||
|
||
cc_binary( | ||
name = "md4driver", | ||
testonly = 1, | ||
srcs = ["mddriver.c"], | ||
copts = ["-DMD=4"], | ||
deps = [":md4"], | ||
) | ||
|
||
cc_library( | ||
name = "md5", | ||
srcs = ["md5c.c"], | ||
hdrs = ["md5.h"], | ||
visibility = ["//visibility:public"], | ||
deps = [":md_global"], | ||
) | ||
|
||
cc_binary( | ||
name = "md5driver", | ||
testonly = 1, | ||
srcs = ["mddriver.c"], | ||
copts = ["-DMD=5"], | ||
deps = [":md5"], | ||
) | ||
|
||
sh_test( | ||
name = "md_test", | ||
size = "small", | ||
srcs = ["md_test.sh"], | ||
data = [ | ||
"golden.md4", | ||
"golden.md5", | ||
":md4driver", | ||
":md5driver", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
md4.h, md4c.c: | ||
|
||
Copyright (C) 1990-2, RSA Data Security, Inc. All rights reserved. | ||
|
||
License to copy and use this software is granted provided that it | ||
is identified as the "RSA Data Security, Inc. MD4 Message-Digest | ||
Algorithm" in all material mentioning or referencing this software | ||
or this function. | ||
|
||
License is also granted to make and use derivative works provided | ||
that such works are identified as "derived from the RSA Data | ||
Security, Inc. MD4 Message-Digest Algorithm" in all material | ||
mentioning or referencing the derived work. | ||
|
||
RSA Data Security, Inc. makes no representations concerning either | ||
the merchantability of this software or the suitability of this | ||
software for any particular purpose. It is provided "as is" | ||
without express or implied warranty of any kind. | ||
|
||
These notices must be retained in any copies of any part of this | ||
documentation and/or software. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
md5.h, md5c.c: | ||
|
||
Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All | ||
rights reserved. | ||
|
||
License to copy and use this software is granted provided that it | ||
is identified as the "RSA Data Security, Inc. MD5 Message-Digest | ||
Algorithm" in all material mentioning or referencing this software | ||
or this function. | ||
|
||
License is also granted to make and use derivative works provided | ||
that such works are identified as "derived from the RSA Data | ||
Security, Inc. MD5 Message-Digest Algorithm" in all material | ||
mentioning or referencing the derived work. | ||
|
||
RSA Data Security, Inc. makes no representations concerning either | ||
the merchantability of this software or the suitability of this | ||
software for any particular purpose. It is provided "as is" | ||
without express or implied warranty of any kind. | ||
|
||
These notices must be retained in any copies of any part of this | ||
documentation and/or software. | ||
----------------------------------------------------------------- | ||
mddriver.c: | ||
|
||
Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All | ||
rights reserved. | ||
|
||
RSA Data Security, Inc. makes no representations concerning either | ||
the merchantability of this software or the suitability of this | ||
software for any particular purpose. It is provided "as is" | ||
without express or implied warranty of any kind. | ||
|
||
These notices must be retained in any copies of any part of this | ||
documentation and/or software. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* GLOBAL.H - RSAREF types and constants | ||
*/ | ||
|
||
#include <stdint.h> | ||
|
||
/* POINTER defines a generic pointer type */ | ||
typedef unsigned char *POINTER; | ||
|
||
/* UINT2 defines a two byte word */ | ||
typedef uint16_t UINT2; | ||
|
||
/* UINT4 defines a four byte word */ | ||
typedef uint32_t UINT4; | ||
|
||
#define PROTO_LIST(list) list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
MD4 test suite: | ||
MD4 ("") = 31d6cfe0d16ae931b73c59d7e0c089c0 | ||
MD4 ("a") = bde52cb31de33e46245e05fbdbd6fb24 | ||
MD4 ("abc") = a448017aaf21d8525fc10ae87aa6729d | ||
MD4 ("message digest") = d9130a8164549fe818874806e1c7014b | ||
MD4 ("abcdefghijklmnopqrstuvwxyz") = d79e1c308aa5bbcdeea8ed63df412da9 | ||
MD4 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") = 043f8582f241db351ce627e153e7f0e4 | ||
MD4 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") = e33b4ddc9c38f2199c3e7b164fcc0536 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
MD5 test suite: | ||
MD5 ("") = d41d8cd98f00b204e9800998ecf8427e | ||
MD5 ("a") = 0cc175b9c0f1b6a831c399e269772661 | ||
MD5 ("abc") = 900150983cd24fb0d6963f7d28e17f72 | ||
MD5 ("message digest") = f96b697d7cb7938d525a2f31aaf161d0 | ||
MD5 ("abcdefghijklmnopqrstuvwxyz") = c3fcd3d76192e4007dfb496cca67e13b | ||
MD5 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") = d174ab98d277d9f5a5611c2c9f419d9f | ||
MD5 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") = 57edf4a22be3c955ac49da2e2107b67a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#ifndef THIRD_PARTY_MD4_MD4_H_ | ||
#define THIRD_PARTY_MD4_MD4_H_ | ||
|
||
/* MD4.H - header file for MD4C.C */ | ||
|
||
/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All | ||
rights reserved. | ||
License to copy and use this software is granted provided that it | ||
is identified as the "RSA Data Security, Inc. MD4 Message-Digest | ||
Algorithm" in all material mentioning or referencing this software | ||
or this function. | ||
License is also granted to make and use derivative works provided | ||
that such works are identified as "derived from the RSA Data | ||
Security, Inc. MD4 Message-Digest Algorithm" in all material | ||
mentioning or referencing the derived work. | ||
RSA Data Security, Inc. makes no representations concerning either | ||
the merchantability of this software or the suitability of this | ||
software for any particular purpose. It is provided "as is" | ||
without express or implied warranty of any kind. | ||
These notices must be retained in any copies of any part of this | ||
documentation and/or software. | ||
*/ | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#include "third_party/md/global.h" | ||
|
||
/* MD4 context. */ | ||
typedef struct { | ||
UINT4 state[4]; /* state (ABCD) */ | ||
UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */ | ||
unsigned char buffer[64]; /* input buffer */ | ||
} MD4_CTX; | ||
|
||
void MD4Init PROTO_LIST((MD4_CTX *)); | ||
|
||
void MD4Update PROTO_LIST((MD4_CTX *, unsigned char *, unsigned int)); | ||
|
||
void MD4Final PROTO_LIST((unsigned char [16], MD4_CTX *)); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif // THIRD_PARTY_MD4_MD4_H_ |
Oops, something went wrong.