Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
dd26a14c
Commit
dd26a14c
authored
Oct 26, 2002
by
James Morris
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[CRYPTO]: Add MD4.
parent
f8b20525
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
107 additions
and
6 deletions
+107
-6
crypto/Config.help
crypto/Config.help
+3
-0
crypto/Config.in
crypto/Config.in
+1
-0
crypto/Makefile
crypto/Makefile
+1
-0
crypto/autoload.c
crypto/autoload.c
+2
-1
crypto/md5.c
crypto/md5.c
+1
-2
crypto/tcrypt.c
crypto/tcrypt.c
+50
-1
crypto/tcrypt.h
crypto/tcrypt.h
+46
-0
include/linux/crypto.h
include/linux/crypto.h
+3
-2
No files found.
crypto/Config.help
View file @
dd26a14c
...
...
@@ -3,6 +3,9 @@
#
CONFIG_CRYPTO
This option provides the core Cryptographic API.
CONFIG_CRYPTO_MD4
MD4 message digest algorithm (RFC1320), including HMAC (RFC2104).
CONFIG_CRYPTO_MD5
MD5 message digest algorithm (RFC1321), including HMAC (RFC2104, RFC2403).
...
...
crypto/Config.in
View file @
dd26a14c
...
...
@@ -6,6 +6,7 @@ comment 'Cryptographic options'
bool 'Cryptographic API' CONFIG_CRYPTO
if [ "$CONFIG_CRYPTO" = "y" ]; then
tristate ' MD4 digest algorithm' CONFIG_CRYPTO_MD4
tristate ' MD5 digest algorithm' CONFIG_CRYPTO_MD5
tristate ' SHA-1 digest algorithm' CONFIG_CRYPTO_SHA1
tristate ' DES and Triple DES EDE cipher algorithms' CONFIG_CRYPTO_DES
...
...
crypto/Makefile
View file @
dd26a14c
...
...
@@ -7,6 +7,7 @@ export-objs := api.o
obj-$(CONFIG_CRYPTO)
+=
api.o cipher.o digest.o compress.o
obj-$(CONFIG_KMOD)
+=
autoload.o
obj-$(CONFIG_CRYPTO_MD4)
+=
md4.o
obj-$(CONFIG_CRYPTO_MD5)
+=
md5.o
obj-$(CONFIG_CRYPTO_SHA1)
+=
sha1.o
obj-$(CONFIG_CRYPTO_DES)
+=
des.o
...
...
crypto/autoload.c
View file @
dd26a14c
...
...
@@ -25,10 +25,11 @@ static struct {
}
alg_modmap
[]
=
{
{
CRYPTO_ALG_DES
,
"des"
},
{
CRYPTO_ALG_DES3_EDE
,
"des"
},
{
CRYPTO_ALG_MD4
,
"md4"
},
{
CRYPTO_ALG_MD5
,
"md5"
},
{
CRYPTO_ALG_SHA1
,
"sha1"
},
};
#define ALG_MAX_MODMAP
4
#define ALG_MAX_MODMAP
5
void
crypto_alg_autoload
(
u32
algid
)
{
...
...
crypto/md5.c
View file @
dd26a14c
...
...
@@ -19,7 +19,6 @@
#include <linux/module.h>
#include <linux/string.h>
#include <linux/crypto.h>
#include <asm/byteorder.h>
#define MD5_DIGEST_SIZE 16
...
...
@@ -43,7 +42,7 @@ struct md5_ctx {
static
inline
void
md5_transform
(
u32
*
hash
,
u32
const
*
in
)
{
register
u32
a
,
b
,
c
,
d
;
u32
a
,
b
,
c
,
d
;
a
=
hash
[
0
];
b
=
hash
[
1
];
...
...
crypto/tcrypt.c
View file @
dd26a14c
...
...
@@ -174,6 +174,51 @@ static void test_md5(void)
crypto_free_tfm
(
tfm
);
}
static
void
test_md4
(
void
)
{
char
*
p
;
int
i
;
struct
scatterlist
sg
[
1
];
char
result
[
128
];
struct
crypto_tfm
*
tfm
;
struct
md4_testvec
*
md4_tv
;
size_t
tsize
;
printk
(
"
\n
testing md4
\n
"
);
tsize
=
sizeof
(
md4_tv_template
);
if
(
tsize
>
TVMEMSIZE
)
{
printk
(
"template (%Zd) too big for tvmem (%d)
\n
"
,
tsize
,
TVMEMSIZE
);
return
;
}
memcpy
(
tvmem
,
md4_tv_template
,
tsize
);
md4_tv
=
(
void
*
)
tvmem
;
tfm
=
crypto_alloc_tfm
(
CRYPTO_ALG_MD4
);
if
(
tfm
==
NULL
)
{
printk
(
"failed to load transform for CRYPTO_ALG_MD4
\n
"
);
return
;
}
for
(
i
=
0
;
i
<
MD4_TEST_VECTORS
;
i
++
)
{
printk
(
"test %d:
\n
"
,
i
+
1
);
memset
(
result
,
0
,
sizeof
(
result
));
p
=
md4_tv
[
i
].
plaintext
;
sg
[
0
].
page
=
virt_to_page
(
p
);
sg
[
0
].
offset
=
((
long
)
p
&
~
PAGE_MASK
);
sg
[
0
].
length
=
strlen
(
md4_tv
[
i
].
plaintext
);
crypto_digest_digest
(
tfm
,
sg
,
1
,
result
);
hexdump
(
result
,
crypto_tfm_digestsize
(
tfm
));
printk
(
"%s
\n
"
,
memcmp
(
result
,
md4_tv
[
i
].
digest
,
crypto_tfm_digestsize
(
tfm
))
?
"fail"
:
"pass"
);
}
crypto_free_tfm
(
tfm
);
}
static
void
test_sha1
(
void
)
{
char
*
p
;
...
...
@@ -239,7 +284,6 @@ static void test_sha1(void)
memset
(
result
,
0
,
sizeof
(
result
));
crypto_digest_digest
(
tfm
,
sg
,
2
,
result
);
hexdump
(
result
,
crypto_tfm_digestsize
(
tfm
));
printk
(
"%s
\n
"
,
memcmp
(
result
,
sha1_tv
[
1
].
digest
,
crypto_tfm_digestsize
(
tfm
))
?
"fail"
:
"pass"
);
printk
(
"
\n
testing hmac_sha1
\n
"
);
...
...
@@ -1213,6 +1257,7 @@ static void do_test(void)
test_sha1
();
test_des
();
test_des3_ede
();
test_md4
();
break
;
case
1
:
...
...
@@ -1230,6 +1275,10 @@ static void do_test(void)
case
4
:
test_des3_ede
();
break
;
case
5
:
test_md4
();
break
;
default:
/* useful for debugging */
...
...
crypto/tcrypt.h
View file @
dd26a14c
...
...
@@ -17,8 +17,54 @@
#define _CRYPTO_TCRYPT_H
#define MD5_DIGEST_SIZE 16
#define MD4_DIGEST_SIZE 16
#define SHA1_DIGEST_SIZE 20
/*
* MD4 test vectors from RFC1320
*/
#define MD4_TEST_VECTORS 7
struct
md4_testvec
{
char
plaintext
[
128
];
char
digest
[
MD4_DIGEST_SIZE
];
}
md4_tv_template
[]
=
{
{
""
,
{
0x31
,
0xd6
,
0xcf
,
0xe0
,
0xd1
,
0x6a
,
0xe9
,
0x31
,
0xb7
,
0x3c
,
0x59
,
0xd7
,
0xe0
,
0xc0
,
0x89
,
0xc0
}
},
{
"a"
,
{
0xbd
,
0xe5
,
0x2c
,
0xb3
,
0x1d
,
0xe3
,
0x3e
,
0x46
,
0x24
,
0x5e
,
0x05
,
0xfb
,
0xdb
,
0xd6
,
0xfb
,
0x24
}
},
{
"abc"
,
{
0xa4
,
0x48
,
0x01
,
0x7a
,
0xaf
,
0x21
,
0xd8
,
0x52
,
0x5f
,
0xc1
,
0x0a
,
0xe8
,
0x7a
,
0xa6
,
0x72
,
0x9d
}
},
{
"message digest"
,
{
0xd9
,
0x13
,
0x0a
,
0x81
,
0x64
,
0x54
,
0x9f
,
0xe8
,
0x18
,
0x87
,
0x48
,
0x06
,
0xe1
,
0xc7
,
0x01
,
0x4b
}
},
{
"abcdefghijklmnopqrstuvwxyz"
,
{
0xd7
,
0x9e
,
0x1c
,
0x30
,
0x8a
,
0xa5
,
0xbb
,
0xcd
,
0xee
,
0xa8
,
0xed
,
0x63
,
0xdf
,
0x41
,
0x2d
,
0xa9
}
},
{
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
,
{
0x04
,
0x3f
,
0x85
,
0x82
,
0xf2
,
0x41
,
0xdb
,
0x35
,
0x1c
,
0xe6
,
0x27
,
0xe1
,
0x53
,
0xe7
,
0xf0
,
0xe4
}
},
{
"12345678901234567890123456789012345678901234567890123456789012345678901234567890"
,
{
0xe3
,
0x3b
,
0x4d
,
0xdc
,
0x9c
,
0x38
,
0xf2
,
0x19
,
0x9c
,
0x3e
,
0x7b
,
0x16
,
0x4f
,
0xcc
,
0x05
,
0x36
}
},
};
/*
* MD5 test vectors from RFC1321
*/
...
...
include/linux/crypto.h
View file @
dd26a14c
...
...
@@ -56,8 +56,9 @@
#define CRYPTO_ALG_DES3_EDE_ECB (CRYPTO_ALG_DES3_EDE|CRYPTO_MODE_ECB)
#define CRYPTO_ALG_DES3_EDE_CBC (CRYPTO_ALG_DES3_EDE|CRYPTO_MODE_CBC)
#define CRYPTO_ALG_MD5 (0x00000f00|CRYPTO_TYPE_DIGEST)
#define CRYPTO_ALG_SHA1 (0x00000f01|CRYPTO_TYPE_DIGEST)
#define CRYPTO_ALG_MD4 (0x00000f00|CRYPTO_TYPE_DIGEST)
#define CRYPTO_ALG_MD5 (0x00000f01|CRYPTO_TYPE_DIGEST)
#define CRYPTO_ALG_SHA1 (0x00000f02|CRYPTO_TYPE_DIGEST)
#define CRYPTO_UNSPEC 0
#define CRYPTO_MAX_ALG_NAME 64
...
...
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