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
c95f18f6
Commit
c95f18f6
authored
Aug 15, 2003
by
Kartikey Mahendra Bhatt
Committed by
Stephen Hemminger
Aug 15, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[CRYPTO]: Add CAST6 (CAST-256) algorithm.
parent
b73fdeae
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
766 additions
and
3 deletions
+766
-3
Documentation/crypto/api-intro.txt
Documentation/crypto/api-intro.txt
+1
-1
crypto/Kconfig
crypto/Kconfig
+7
-0
crypto/Makefile
crypto/Makefile
+1
-0
crypto/cast6.c
crypto/cast6.c
+563
-0
crypto/tcrypt.c
crypto/tcrypt.c
+107
-2
crypto/tcrypt.h
crypto/tcrypt.h
+87
-0
No files found.
Documentation/crypto/api-intro.txt
View file @
c95f18f6
...
@@ -213,7 +213,7 @@ AES algorithm contributors:
...
@@ -213,7 +213,7 @@ AES algorithm contributors:
Kyle McMartin
Kyle McMartin
Adam J. Richter
Adam J. Richter
CAST5 algorithm contributors:
CAST5
/CAST6
algorithm contributors:
Kartikey Mahendra Bhatt (original developers unknown, FSF copyright).
Kartikey Mahendra Bhatt (original developers unknown, FSF copyright).
Generic scatterwalk code by Adam J. Richter <adam@yggdrasil.com>
Generic scatterwalk code by Adam J. Richter <adam@yggdrasil.com>
...
...
crypto/Kconfig
View file @
c95f18f6
...
@@ -133,6 +133,13 @@ config CRYPTO_CAST5
...
@@ -133,6 +133,13 @@ config CRYPTO_CAST5
The CAST5 encryption algorithm (synonymous with CAST-128) is
The CAST5 encryption algorithm (synonymous with CAST-128) is
described in RFC2144.
described in RFC2144.
config CRYPTO_CAST6
tristate "CAST6 (CAST-256) cipher algorithm"
depends on CRYPTO
help
The CAST6 encryption algorithm (synonymous with CAST-256) is
described in RFC2612.
config CRYPTO_DEFLATE
config CRYPTO_DEFLATE
tristate "Deflate compression algorithm"
tristate "Deflate compression algorithm"
depends on CRYPTO
depends on CRYPTO
...
...
crypto/Makefile
View file @
c95f18f6
...
@@ -21,6 +21,7 @@ obj-$(CONFIG_CRYPTO_TWOFISH) += twofish.o
...
@@ -21,6 +21,7 @@ obj-$(CONFIG_CRYPTO_TWOFISH) += twofish.o
obj-$(CONFIG_CRYPTO_SERPENT)
+=
serpent.o
obj-$(CONFIG_CRYPTO_SERPENT)
+=
serpent.o
obj-$(CONFIG_CRYPTO_AES)
+=
aes.o
obj-$(CONFIG_CRYPTO_AES)
+=
aes.o
obj-$(CONFIG_CRYPTO_CAST5)
+=
cast5.o
obj-$(CONFIG_CRYPTO_CAST5)
+=
cast5.o
obj-$(CONFIG_CRYPTO_CAST6)
+=
cast6.o
obj-$(CONFIG_CRYPTO_DEFLATE)
+=
deflate.o
obj-$(CONFIG_CRYPTO_DEFLATE)
+=
deflate.o
obj-$(CONFIG_CRYPTO_TEST)
+=
tcrypt.o
obj-$(CONFIG_CRYPTO_TEST)
+=
tcrypt.o
crypto/cast6.c
0 → 100644
View file @
c95f18f6
This diff is collapsed.
Click to expand it.
crypto/tcrypt.c
View file @
c95f18f6
...
@@ -48,8 +48,8 @@ static char *tvmem;
...
@@ -48,8 +48,8 @@ static char *tvmem;
static
char
*
check
[]
=
{
static
char
*
check
[]
=
{
"des"
,
"md5"
,
"des3_ede"
,
"rot13"
,
"sha1"
,
"sha256"
,
"blowfish"
,
"des"
,
"md5"
,
"des3_ede"
,
"rot13"
,
"sha1"
,
"sha256"
,
"blowfish"
,
"twofish"
,
"serpent"
,
"sha384"
,
"sha512"
,
"md4"
,
"aes"
,
"
deflate"
,
"twofish"
,
"serpent"
,
"sha384"
,
"sha512"
,
"md4"
,
"aes"
,
"
cast6"
,
NULL
"deflate"
,
NULL
};
};
static
void
static
void
...
@@ -2087,6 +2087,105 @@ test_serpent(void)
...
@@ -2087,6 +2087,105 @@ test_serpent(void)
crypto_free_tfm
(
tfm
);
crypto_free_tfm
(
tfm
);
}
}
static
void
test_cast6
(
void
)
{
unsigned
int
ret
,
i
,
tsize
;
u8
*
p
,
*
q
,
*
key
;
struct
crypto_tfm
*
tfm
;
struct
cast6_tv
*
cast_tv
;
struct
scatterlist
sg
[
1
];
printk
(
"
\n
testing cast6 encryption
\n
"
);
tfm
=
crypto_alloc_tfm
(
"cast6"
,
0
);
if
(
tfm
==
NULL
)
{
printk
(
"failed to load transform for cast6 (default ecb)
\n
"
);
return
;
}
tsize
=
sizeof
(
cast6_enc_tv_template
);
if
(
tsize
>
TVMEMSIZE
)
{
printk
(
"template (%u) too big for tvmem (%u)
\n
"
,
tsize
,
TVMEMSIZE
);
return
;
}
memcpy
(
tvmem
,
cast6_enc_tv_template
,
tsize
);
cast_tv
=
(
void
*
)
tvmem
;
for
(
i
=
0
;
i
<
CAST6_ENC_TEST_VECTORS
;
i
++
)
{
printk
(
"test %u (%d bit key):
\n
"
,
i
+
1
,
cast_tv
[
i
].
keylen
*
8
);
key
=
cast_tv
[
i
].
key
;
ret
=
crypto_cipher_setkey
(
tfm
,
key
,
cast_tv
[
i
].
keylen
);
if
(
ret
)
{
printk
(
"setkey() failed flags=%x
\n
"
,
tfm
->
crt_flags
);
if
(
!
cast_tv
[
i
].
fail
)
goto
out
;
}
p
=
cast_tv
[
i
].
plaintext
;
sg
[
0
].
page
=
virt_to_page
(
p
);
sg
[
0
].
offset
=
((
long
)
p
&
~
PAGE_MASK
);
sg
[
0
].
length
=
sizeof
(
cast_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
(
cast_tv
[
i
].
result
));
printk
(
"%s
\n
"
,
memcmp
(
q
,
cast_tv
[
i
].
result
,
sizeof
(
cast_tv
[
i
].
result
))
?
"fail"
:
"pass"
);
}
printk
(
"
\n
testing cast6 decryption
\n
"
);
tsize
=
sizeof
(
cast6_dec_tv_template
);
if
(
tsize
>
TVMEMSIZE
)
{
printk
(
"template (%u) too big for tvmem (%u)
\n
"
,
tsize
,
TVMEMSIZE
);
return
;
}
memcpy
(
tvmem
,
cast6_dec_tv_template
,
tsize
);
cast_tv
=
(
void
*
)
tvmem
;
for
(
i
=
0
;
i
<
CAST6_DEC_TEST_VECTORS
;
i
++
)
{
printk
(
"test %u (%d bit key):
\n
"
,
i
+
1
,
cast_tv
[
i
].
keylen
*
8
);
key
=
cast_tv
[
i
].
key
;
ret
=
crypto_cipher_setkey
(
tfm
,
key
,
cast_tv
[
i
].
keylen
);
if
(
ret
)
{
printk
(
"setkey() failed flags=%x
\n
"
,
tfm
->
crt_flags
);
if
(
!
cast_tv
[
i
].
fail
)
goto
out
;
}
p
=
cast_tv
[
i
].
plaintext
;
sg
[
0
].
page
=
virt_to_page
(
p
);
sg
[
0
].
offset
=
((
long
)
p
&
~
PAGE_MASK
);
sg
[
0
].
length
=
sizeof
(
cast_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
(
cast_tv
[
i
].
result
));
printk
(
"%s
\n
"
,
memcmp
(
q
,
cast_tv
[
i
].
result
,
sizeof
(
cast_tv
[
i
].
result
))
?
"fail"
:
"pass"
);
}
out:
crypto_free_tfm
(
tfm
);
}
void
void
test_aes
(
void
)
test_aes
(
void
)
{
{
...
@@ -2396,11 +2495,13 @@ do_test(void)
...
@@ -2396,11 +2495,13 @@ do_test(void)
test_blowfish
();
test_blowfish
();
test_twofish
();
test_twofish
();
test_serpent
();
test_serpent
();
test_cast6
();
test_aes
();
test_aes
();
test_sha384
();
test_sha384
();
test_sha512
();
test_sha512
();
test_deflate
();
test_deflate
();
test_cast5
();
test_cast5
();
test_cast6
();
#ifdef CONFIG_CRYPTO_HMAC
#ifdef CONFIG_CRYPTO_HMAC
test_hmac_md5
();
test_hmac_md5
();
test_hmac_sha1
();
test_hmac_sha1
();
...
@@ -2464,6 +2565,10 @@ do_test(void)
...
@@ -2464,6 +2565,10 @@ do_test(void)
test_cast5
();
test_cast5
();
break
;
break
;
case
15
:
test_cast6
();
break
;
#ifdef CONFIG_CRYPTO_HMAC
#ifdef CONFIG_CRYPTO_HMAC
case
100
:
case
100
:
test_hmac_md5
();
test_hmac_md5
();
...
...
crypto/tcrypt.h
View file @
c95f18f6
...
@@ -1589,6 +1589,93 @@ struct serpent_tv serpent_dec_tv_template[] =
...
@@ -1589,6 +1589,93 @@ struct serpent_tv serpent_dec_tv_template[] =
}
}
};
};
/* Cast6 test vectors from RFC 2612 */
#define CAST6_ENC_TEST_VECTORS 3
#define CAST6_DEC_TEST_VECTORS 3
struct
cast6_tv
{
unsigned
keylen
;
unsigned
fail
;
u8
key
[
32
];
u8
plaintext
[
16
];
u8
result
[
16
];
};
struct
cast6_tv
cast6_enc_tv_template
[]
=
{
{
16
,
0
,
{
0x23
,
0x42
,
0xbb
,
0x9e
,
0xfa
,
0x38
,
0x54
,
0x2c
,
0x0a
,
0xf7
,
0x56
,
0x47
,
0xf2
,
0x9f
,
0x61
,
0x5d
},
{
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
},
{
0xc8
,
0x42
,
0xa0
,
0x89
,
0x72
,
0xb4
,
0x3d
,
0x20
,
0x83
,
0x6c
,
0x91
,
0xd1
,
0xb7
,
0x53
,
0x0f
,
0x6b
},
},
{
24
,
0
,
{
0x23
,
0x42
,
0xbb
,
0x9e
,
0xfa
,
0x38
,
0x54
,
0x2c
,
0xbe
,
0xd0
,
0xac
,
0x83
,
0x94
,
0x0a
,
0xc2
,
0x98
,
0xba
,
0xc7
,
0x7a
,
0x77
,
0x17
,
0x94
,
0x28
,
0x63
},
{
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
},
{
0x1b
,
0x38
,
0x6c
,
0x02
,
0x10
,
0xdc
,
0xad
,
0xcb
,
0xdd
,
0x0e
,
0x41
,
0xaa
,
0x08
,
0xa7
,
0xa7
,
0xe8
},
},
{
32
,
0
,
{
0x23
,
0x42
,
0xbb
,
0x9e
,
0xfa
,
0x38
,
0x54
,
0x2c
,
0xbe
,
0xd0
,
0xac
,
0x83
,
0x94
,
0x0a
,
0xc2
,
0x98
,
0x8d
,
0x7c
,
0x47
,
0xce
,
0x26
,
0x49
,
0x08
,
0x46
,
0x1c
,
0xc1
,
0xb5
,
0x13
,
0x7a
,
0xe6
,
0xb6
,
0x04
},
{
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
},
{
0x4f
,
0x6a
,
0x20
,
0x38
,
0x28
,
0x68
,
0x97
,
0xb9
,
0xc9
,
0x87
,
0x01
,
0x36
,
0x55
,
0x33
,
0x17
,
0xfa
},
}
};
struct
cast6_tv
cast6_dec_tv_template
[]
=
{
{
16
,
0
,
{
0x23
,
0x42
,
0xbb
,
0x9e
,
0xfa
,
0x38
,
0x54
,
0x2c
,
0x0a
,
0xf7
,
0x56
,
0x47
,
0xf2
,
0x9f
,
0x61
,
0x5d
},
{
0xc8
,
0x42
,
0xa0
,
0x89
,
0x72
,
0xb4
,
0x3d
,
0x20
,
0x83
,
0x6c
,
0x91
,
0xd1
,
0xb7
,
0x53
,
0x0f
,
0x6b
},
{
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
},
},
{
24
,
0
,
{
0x23
,
0x42
,
0xbb
,
0x9e
,
0xfa
,
0x38
,
0x54
,
0x2c
,
0xbe
,
0xd0
,
0xac
,
0x83
,
0x94
,
0x0a
,
0xc2
,
0x98
,
0xba
,
0xc7
,
0x7a
,
0x77
,
0x17
,
0x94
,
0x28
,
0x63
},
{
0x1b
,
0x38
,
0x6c
,
0x02
,
0x10
,
0xdc
,
0xad
,
0xcb
,
0xdd
,
0x0e
,
0x41
,
0xaa
,
0x08
,
0xa7
,
0xa7
,
0xe8
},
{
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
},
},
{
32
,
0
,
{
0x23
,
0x42
,
0xbb
,
0x9e
,
0xfa
,
0x38
,
0x54
,
0x2c
,
0xbe
,
0xd0
,
0xac
,
0x83
,
0x94
,
0x0a
,
0xc2
,
0x98
,
0x8d
,
0x7c
,
0x47
,
0xce
,
0x26
,
0x49
,
0x08
,
0x46
,
0x1c
,
0xc1
,
0xb5
,
0x13
,
0x7a
,
0xe6
,
0xb6
,
0x04
},
{
0x4f
,
0x6a
,
0x20
,
0x38
,
0x28
,
0x68
,
0x97
,
0xb9
,
0xc9
,
0x87
,
0x01
,
0x36
,
0x55
,
0x33
,
0x17
,
0xfa
},
{
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
},
}
};
/*
/*
* AES test vectors.
* AES test vectors.
*/
*/
...
...
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