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
nexedi
linux
Commits
c63f5cf8
Commit
c63f5cf8
authored
Aug 11, 2003
by
Kartikey Mahendra Bhatt
Committed by
Dave Jones
Aug 11, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[CRYPTO]: Add cast5, integration by jmorris@intercode.com.au
parent
6e6c3a14
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
1032 additions
and
1 deletion
+1032
-1
Documentation/crypto/api-intro.txt
Documentation/crypto/api-intro.txt
+3
-1
crypto/Kconfig
crypto/Kconfig
+7
-0
crypto/Makefile
crypto/Makefile
+1
-0
crypto/cast5.c
crypto/cast5.c
+852
-0
crypto/tcrypt.c
crypto/tcrypt.c
+101
-0
crypto/tcrypt.h
crypto/tcrypt.h
+68
-0
No files found.
Documentation/crypto/api-intro.txt
View file @
c63f5cf8
...
...
@@ -186,7 +186,6 @@ Original developers of the crypto algorithms:
Dag Arne Osvik (Serpent)
Brian Gladman (AES)
SHA1 algorithm contributors:
Jean-Francois Dive
...
...
@@ -214,6 +213,9 @@ AES algorithm contributors:
Kyle McMartin
Adam J. Richter
CAST5 algorithm contributors:
Kartikey Mahendra Bhatt (original developers unknown, FSF copyright).
Generic scatterwalk code by Adam J. Richter <adam@yggdrasil.com>
Please send any credits updates or corrections to:
...
...
crypto/Kconfig
View file @
c63f5cf8
...
...
@@ -126,6 +126,13 @@ config CRYPTO_AES
See http://csrc.nist.gov/encryption/aes/ for more information.
config CRYPTO_CAST5
tristate "CAST5 (CAST-128) cipher algorithm"
depends on CRYPTO
help
The CAST5 encryption algorithm (synonymous with CAST-128) is
described in RFC2144.
config CRYPTO_DEFLATE
tristate "Deflate compression algorithm"
depends on CRYPTO
...
...
crypto/Makefile
View file @
c63f5cf8
...
...
@@ -20,6 +20,7 @@ obj-$(CONFIG_CRYPTO_BLOWFISH) += blowfish.o
obj-$(CONFIG_CRYPTO_TWOFISH)
+=
twofish.o
obj-$(CONFIG_CRYPTO_SERPENT)
+=
serpent.o
obj-$(CONFIG_CRYPTO_AES)
+=
aes.o
obj-$(CONFIG_CRYPTO_CAST5)
+=
cast5.o
obj-$(CONFIG_CRYPTO_DEFLATE)
+=
deflate.o
obj-$(CONFIG_CRYPTO_TEST)
+=
tcrypt.o
crypto/cast5.c
0 → 100644
View file @
c63f5cf8
This diff is collapsed.
Click to expand it.
crypto/tcrypt.c
View file @
c63f5cf8
...
...
@@ -2192,6 +2192,102 @@ test_aes(void)
crypto_free_tfm
(
tfm
);
}
void
test_cast5
(
void
)
{
unsigned
int
ret
,
i
,
tsize
;
u8
*
p
,
*
q
,
*
key
;
struct
crypto_tfm
*
tfm
;
struct
cast5_tv
*
c5_tv
;
struct
scatterlist
sg
[
1
];
printk
(
"
\n
testing cast5 encryption
\n
"
);
tfm
=
crypto_alloc_tfm
(
"cast5"
,
0
);
if
(
tfm
==
NULL
)
{
printk
(
"failed to load transform for cast5 (default ecb)
\n
"
);
return
;
}
tsize
=
sizeof
(
cast5_enc_tv_template
);
if
(
tsize
>
TVMEMSIZE
)
{
printk
(
"template (%u) too big for tvmem (%u)
\n
"
,
tsize
,
TVMEMSIZE
);
return
;
}
memcpy
(
tvmem
,
cast5_enc_tv_template
,
tsize
);
c5_tv
=
(
void
*
)
tvmem
;
for
(
i
=
0
;
i
<
CAST5_ENC_TEST_VECTORS
;
i
++
)
{
printk
(
"test %u (%d bit key):
\n
"
,
i
+
1
,
c5_tv
[
i
].
keylen
*
8
);
key
=
c5_tv
[
i
].
key
;
ret
=
crypto_cipher_setkey
(
tfm
,
key
,
c5_tv
[
i
].
keylen
);
if
(
ret
)
{
printk
(
"setkey() failed flags=%x
\n
"
,
tfm
->
crt_flags
);
if
(
!
c5_tv
[
i
].
fail
)
goto
out
;
}
p
=
c5_tv
[
i
].
plaintext
;
sg
[
0
].
page
=
virt_to_page
(
p
);
sg
[
0
].
offset
=
((
long
)
p
&
~
PAGE_MASK
);
sg
[
0
].
length
=
sizeof
(
c5_tv
[
i
].
plaintext
);
ret
=
crypto_cipher_encrypt
(
tfm
,
sg
,
sg
,
sg
[
0
].
length
);
if
(
ret
)
{
printk
(
"encrypt() failed flags=%x
\n
"
,
tfm
->
crt_flags
);
goto
out
;
}
q
=
kmap
(
sg
[
0
].
page
)
+
sg
[
0
].
offset
;
hexdump
(
q
,
sizeof
(
c5_tv
[
i
].
ciphertext
));
printk
(
"%s
\n
"
,
memcmp
(
q
,
c5_tv
[
i
].
ciphertext
,
sizeof
(
c5_tv
[
i
].
ciphertext
))
?
"fail"
:
"pass"
);
}
tsize
=
sizeof
(
cast5_dec_tv_template
);
if
(
tsize
>
TVMEMSIZE
)
{
printk
(
"template (%u) too big for tvmem (%u)
\n
"
,
tsize
,
TVMEMSIZE
);
return
;
}
memcpy
(
tvmem
,
cast5_dec_tv_template
,
tsize
);
c5_tv
=
(
void
*
)
tvmem
;
for
(
i
=
0
;
i
<
CAST5_DEC_TEST_VECTORS
;
i
++
)
{
printk
(
"test %u (%d bit key):
\n
"
,
i
+
1
,
c5_tv
[
i
].
keylen
*
8
);
key
=
c5_tv
[
i
].
key
;
ret
=
crypto_cipher_setkey
(
tfm
,
key
,
c5_tv
[
i
].
keylen
);
if
(
ret
)
{
printk
(
"setkey() failed flags=%x
\n
"
,
tfm
->
crt_flags
);
if
(
!
c5_tv
[
i
].
fail
)
goto
out
;
}
p
=
c5_tv
[
i
].
plaintext
;
sg
[
0
].
page
=
virt_to_page
(
p
);
sg
[
0
].
offset
=
((
long
)
p
&
~
PAGE_MASK
);
sg
[
0
].
length
=
sizeof
(
c5_tv
[
i
].
plaintext
);
ret
=
crypto_cipher_decrypt
(
tfm
,
sg
,
sg
,
sg
[
0
].
length
);
if
(
ret
)
{
printk
(
"decrypt() failed flags=%x
\n
"
,
tfm
->
crt_flags
);
goto
out
;
}
q
=
kmap
(
sg
[
0
].
page
)
+
sg
[
0
].
offset
;
hexdump
(
q
,
sizeof
(
c5_tv
[
i
].
ciphertext
));
printk
(
"%s
\n
"
,
memcmp
(
q
,
c5_tv
[
i
].
ciphertext
,
sizeof
(
c5_tv
[
i
].
ciphertext
))
?
"fail"
:
"pass"
);
}
out:
crypto_free_tfm
(
tfm
);
}
static
void
test_deflate
(
void
)
{
...
...
@@ -2304,6 +2400,7 @@ do_test(void)
test_sha384
();
test_sha512
();
test_deflate
();
test_cast5
();
#ifdef CONFIG_CRYPTO_HMAC
test_hmac_md5
();
test_hmac_sha1
();
...
...
@@ -2363,6 +2460,10 @@ do_test(void)
test_deflate
();
break
;
case
14
:
test_cast5
();
break
;
#ifdef CONFIG_CRYPTO_HMAC
case
100
:
test_hmac_md5
();
...
...
crypto/tcrypt.h
View file @
c63f5cf8
...
...
@@ -1682,6 +1682,74 @@ struct aes_tv aes_dec_tv_template[] = {
},
};
/* Cast5 test vectors from RFC 2144 */
#define CAST5_ENC_TEST_VECTORS 3
#define CAST5_DEC_TEST_VECTORS 3
struct
cast5_tv
{
unsigned
keylen
;
unsigned
fail
;
u8
key
[
16
];
u8
plaintext
[
8
];
u8
ciphertext
[
8
];
};
struct
cast5_tv
cast5_enc_tv_template
[]
=
{
{
16
,
0
,
{
0x01
,
0x23
,
0x45
,
0x67
,
0x12
,
0x34
,
0x56
,
0x78
,
0x23
,
0x45
,
0x67
,
0x89
,
0x34
,
0x56
,
0x78
,
0x9A
},
{
0x01
,
0x23
,
0x45
,
0x67
,
0x89
,
0xab
,
0xcd
,
0xef
},
{
0x23
,
0x8b
,
0x4f
,
0xe5
,
0x84
,
0x7e
,
0x44
,
0xb2
},
},
{
10
,
0
,
{
0x01
,
0x23
,
0x45
,
0x67
,
0x12
,
0x34
,
0x56
,
0x78
,
0x23
,
0x45
},
{
0x01
,
0x23
,
0x45
,
0x67
,
0x89
,
0xab
,
0xcd
,
0xef
},
{
0xeb
,
0x6a
,
0x71
,
0x1a
,
0x2c
,
0x02
,
0x27
,
0x1b
},
},
{
5
,
0
,
{
0x01
,
0x23
,
0x45
,
0x67
,
0x12
},
{
0x01
,
0x23
,
0x45
,
0x67
,
0x89
,
0xab
,
0xcd
,
0xef
},
{
0x7a
,
0xc8
,
0x16
,
0xd1
,
0x6e
,
0x9b
,
0x30
,
0x2e
},
}
};
struct
cast5_tv
cast5_dec_tv_template
[]
=
{
{
16
,
0
,
{
0x01
,
0x23
,
0x45
,
0x67
,
0x12
,
0x34
,
0x56
,
0x78
,
0x23
,
0x45
,
0x67
,
0x89
,
0x34
,
0x56
,
0x78
,
0x9A
},
{
0x23
,
0x8b
,
0x4f
,
0xe5
,
0x84
,
0x7e
,
0x44
,
0xb2
},
{
0x01
,
0x23
,
0x45
,
0x67
,
0x89
,
0xab
,
0xcd
,
0xef
},
},
{
10
,
0
,
{
0x01
,
0x23
,
0x45
,
0x67
,
0x12
,
0x34
,
0x56
,
0x78
,
0x23
,
0x45
},
{
0xeb
,
0x6a
,
0x71
,
0x1a
,
0x2c
,
0x02
,
0x27
,
0x1b
},
{
0x01
,
0x23
,
0x45
,
0x67
,
0x89
,
0xab
,
0xcd
,
0xef
},
},
{
5
,
0
,
{
0x01
,
0x23
,
0x45
,
0x67
,
0x12
},
{
0x7a
,
0xc8
,
0x16
,
0xd1
,
0x6e
,
0x9b
,
0x30
,
0x2e
},
{
0x01
,
0x23
,
0x45
,
0x67
,
0x89
,
0xab
,
0xcd
,
0xef
},
}
};
/*
* Compression stuff.
*/
...
...
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