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
dd2514fe
Commit
dd2514fe
authored
Mar 03, 2004
by
Jon Oberheide
Committed by
Stephen Hemminger
Mar 03, 2004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[CRYPTO]: Add ARC4 module.
parent
0db1f9e3
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
269 additions
and
1 deletion
+269
-1
Documentation/crypto/api-intro.txt
Documentation/crypto/api-intro.txt
+1
-0
crypto/Kconfig
crypto/Kconfig
+10
-0
crypto/Makefile
crypto/Makefile
+1
-0
crypto/arc4.c
crypto/arc4.c
+106
-0
crypto/tcrypt.c
crypto/tcrypt.c
+10
-1
crypto/tcrypt.h
crypto/tcrypt.h
+141
-0
No files found.
Documentation/crypto/api-intro.txt
View file @
dd2514fe
...
...
@@ -186,6 +186,7 @@ Original developers of the crypto algorithms:
Dag Arne Osvik (Serpent)
Brian Gladman (AES)
Kartikey Mahendra Bhatt (CAST6)
Jon Oberheide (ARC4)
SHA1 algorithm contributors:
Jean-Francois Dive
...
...
crypto/Kconfig
View file @
dd2514fe
...
...
@@ -140,6 +140,16 @@ config CRYPTO_CAST6
The CAST6 encryption algorithm (synonymous with CAST-256) is
described in RFC2612.
config CRYPTO_ARC4
tristate "ARC4 cipher algorithm"
depends on CRYPTO
help
ARC4 cipher algorithm.
This is a stream cipher using keys ranging from 8 bits to 2048
bits in length. ARC4 is commonly used in protocols such as WEP
and SSL.
config CRYPTO_DEFLATE
tristate "Deflate compression algorithm"
depends on CRYPTO
...
...
crypto/Makefile
View file @
dd2514fe
...
...
@@ -21,6 +21,7 @@ obj-$(CONFIG_CRYPTO_SERPENT) += serpent.o
obj-$(CONFIG_CRYPTO_AES)
+=
aes.o
obj-$(CONFIG_CRYPTO_CAST5)
+=
cast5.o
obj-$(CONFIG_CRYPTO_CAST6)
+=
cast6.o
obj-$(CONFIG_CRYPTO_ARC4)
+=
arc4.o
obj-$(CONFIG_CRYPTO_DEFLATE)
+=
deflate.o
obj-$(CONFIG_CRYPTO_TEST)
+=
tcrypt.o
crypto/arc4.c
0 → 100644
View file @
dd2514fe
/*
* Cryptographic API
*
* ARC4 Cipher Algorithm
*
* Jon Oberheide <jon@focalhost.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
*/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/crypto.h>
#define ARC4_MIN_KEY_SIZE 1
#define ARC4_MAX_KEY_SIZE 256
#define ARC4_BLOCK_SIZE 1
struct
arc4_ctx
{
u8
S
[
256
];
u8
x
,
y
;
};
static
int
arc4_set_key
(
void
*
ctx_arg
,
const
u8
*
in_key
,
unsigned
int
key_len
,
u32
*
flags
)
{
struct
arc4_ctx
*
ctx
=
ctx_arg
;
int
i
,
j
=
0
,
k
=
0
;
ctx
->
x
=
1
;
ctx
->
y
=
0
;
for
(
i
=
0
;
i
<
256
;
i
++
)
ctx
->
S
[
i
]
=
i
;
for
(
i
=
0
;
i
<
256
;
i
++
)
{
u8
a
=
ctx
->
S
[
i
];
j
=
(
j
+
in_key
[
k
]
+
a
)
&
0xff
;
ctx
->
S
[
i
]
=
ctx
->
S
[
j
];
ctx
->
S
[
j
]
=
a
;
if
(
++
k
>=
key_len
)
k
=
0
;
}
/* TODO: dump the first 768 bytes generated as recommended
by Ilya Mironov (http://eprint.iacr.org/2002/067/) to
increase the statistical strength of the state table */
return
0
;
}
static
void
arc4_crypt
(
void
*
ctx_arg
,
u8
*
out
,
const
u8
*
in
)
{
struct
arc4_ctx
*
ctx
=
ctx_arg
;
u8
*
const
S
=
ctx
->
S
;
u8
x
=
ctx
->
x
;
u8
y
=
ctx
->
y
;
u8
a
=
S
[
x
];
y
=
(
y
+
a
)
&
0xff
;
u8
b
=
S
[
y
];
S
[
x
]
=
b
;
S
[
y
]
=
a
;
x
=
(
x
+
1
)
&
0xff
;
*
out
++
=
*
in
^
S
[(
a
+
b
)
&
0xff
];
ctx
->
x
=
x
;
ctx
->
y
=
y
;
}
static
struct
crypto_alg
arc4_alg
=
{
.
cra_name
=
"arc4"
,
.
cra_flags
=
CRYPTO_ALG_TYPE_CIPHER
,
.
cra_blocksize
=
ARC4_BLOCK_SIZE
,
.
cra_ctxsize
=
sizeof
(
struct
arc4_ctx
),
.
cra_module
=
THIS_MODULE
,
.
cra_list
=
LIST_HEAD_INIT
(
arc4_alg
.
cra_list
),
.
cra_u
=
{
.
cipher
=
{
.
cia_min_keysize
=
ARC4_MIN_KEY_SIZE
,
.
cia_max_keysize
=
ARC4_MAX_KEY_SIZE
,
.
cia_setkey
=
arc4_set_key
,
.
cia_encrypt
=
arc4_crypt
,
.
cia_decrypt
=
arc4_crypt
}
}
};
static
int
__init
arc4_init
(
void
)
{
return
crypto_register_alg
(
&
arc4_alg
);
}
static
void
__exit
arc4_exit
(
void
)
{
crypto_unregister_alg
(
&
arc4_alg
);
}
module_init
(
arc4_init
);
module_exit
(
arc4_exit
);
MODULE_LICENSE
(
"GPL"
);
MODULE_DESCRIPTION
(
"ARC4 Cipher Algorithm"
);
MODULE_AUTHOR
(
"Jon Oberheide <jon@focalhost.com>"
);
crypto/tcrypt.c
View file @
dd2514fe
...
...
@@ -61,7 +61,7 @@ static char *tvmem;
static
char
*
check
[]
=
{
"des"
,
"md5"
,
"des3_ede"
,
"rot13"
,
"sha1"
,
"sha256"
,
"blowfish"
,
"twofish"
,
"serpent"
,
"sha384"
,
"sha512"
,
"md4"
,
"aes"
,
"cast6"
,
"deflate"
,
NULL
"
arc4"
,
"
deflate"
,
NULL
};
static
void
...
...
@@ -556,6 +556,10 @@ do_test(void)
test_cipher
(
"cast6"
,
MODE_ECB
,
ENCRYPT
,
cast6_enc_tv_template
,
CAST6_ENC_TEST_VECTORS
);
test_cipher
(
"cast6"
,
MODE_ECB
,
DECRYPT
,
cast6_dec_tv_template
,
CAST6_DEC_TEST_VECTORS
);
//ARC4
test_cipher
(
"arc4"
,
MODE_ECB
,
ENCRYPT
,
arc4_enc_tv_template
,
ARC4_ENC_TEST_VECTORS
);
test_cipher
(
"arc4x"
,
MODE_ECB
,
DECRYPT
,
arc4_dec_tv_template
,
ARC4_DEC_TEST_VECTORS
);
test_hash
(
"sha384"
,
sha384_tv_template
,
SHA384_TEST_VECTORS
);
test_hash
(
"sha512"
,
sha512_tv_template
,
SHA512_TEST_VECTORS
);
test_deflate
();
...
...
@@ -638,6 +642,11 @@ do_test(void)
test_cipher
(
"cast6"
,
MODE_ECB
,
DECRYPT
,
cast6_dec_tv_template
,
CAST6_DEC_TEST_VECTORS
);
break
;
case
16
:
test_cipher
(
"arc4"
,
MODE_ECB
,
ENCRYPT
,
arc4_enc_tv_template
,
ARC4_ENC_TEST_VECTORS
);
test_cipher
(
"arc4"
,
MODE_ECB
,
DECRYPT
,
arc4_dec_tv_template
,
ARC4_DEC_TEST_VECTORS
);
break
;
#ifdef CONFIG_CRYPTO_HMAC
case
100
:
test_hmac
(
"md5"
,
hmac_md5_tv_template
,
HMAC_MD5_TEST_VECTORS
);
...
...
crypto/tcrypt.h
View file @
dd2514fe
...
...
@@ -1488,6 +1488,147 @@ struct cipher_testvec cast5_dec_tv_template[] =
},
};
/*
* ARC4 test vectors from OpenSSL
*/
#define ARC4_ENC_TEST_VECTORS 7
#define ARC4_DEC_TEST_VECTORS 7
struct
cipher_testvec
arc4_enc_tv_template
[]
=
{
{
.
key
=
{
0x01
,
0x23
,
0x45
,
0x67
,
0x89
,
0xab
,
0xcd
,
0xef
},
.
klen
=
8
,
.
input
=
{
0x01
,
0x23
,
0x45
,
0x67
,
0x89
,
0xab
,
0xcd
,
0xef
},
.
ilen
=
8
,
.
result
=
{
0x75
,
0xb7
,
0x87
,
0x80
,
0x99
,
0xe0
,
0xc5
,
0x96
},
.
rlen
=
8
,
},
{
.
key
=
{
0x01
,
0x23
,
0x45
,
0x67
,
0x89
,
0xab
,
0xcd
,
0xef
},
.
klen
=
8
,
.
input
=
{
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
},
.
ilen
=
8
,
.
result
=
{
0x74
,
0x94
,
0xc2
,
0xe7
,
0x10
,
0x4b
,
0x08
,
0x79
},
.
rlen
=
8
,
},
{
.
key
=
{
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
},
.
klen
=
8
,
.
input
=
{
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
},
.
ilen
=
8
,
.
result
=
{
0xde
,
0x18
,
0x89
,
0x41
,
0xa3
,
0x37
,
0x5d
,
0x3a
},
.
rlen
=
8
,
},
{
.
key
=
{
0xef
,
0x01
,
0x23
,
0x45
},
.
klen
=
4
,
.
input
=
{
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
},
.
ilen
=
20
,
.
result
=
{
0xd6
,
0xa1
,
0x41
,
0xa7
,
0xec
,
0x3c
,
0x38
,
0xdf
,
0xbd
,
0x61
,
0x5a
,
0x11
,
0x62
,
0xe1
,
0xc7
,
0xba
,
0x36
,
0xb6
,
0x78
,
0x58
},
.
rlen
=
20
,
},
{
.
key
=
{
0x01
,
0x23
,
0x45
,
0x67
,
0x89
,
0xab
,
0xcd
,
0xef
},
.
klen
=
8
,
.
input
=
{
0x12
,
0x34
,
0x56
,
0x78
,
0x9A
,
0xBC
,
0xDE
,
0xF0
,
0x12
,
0x34
,
0x56
,
0x78
,
0x9A
,
0xBC
,
0xDE
,
0xF0
,
0x12
,
0x34
,
0x56
,
0x78
,
0x9A
,
0xBC
,
0xDE
,
0xF0
,
0x12
,
0x34
,
0x56
,
0x78
},
.
ilen
=
28
,
.
result
=
{
0x66
,
0xa0
,
0x94
,
0x9f
,
0x8a
,
0xf7
,
0xd6
,
0x89
,
0x1f
,
0x7f
,
0x83
,
0x2b
,
0xa8
,
0x33
,
0xc0
,
0x0c
,
0x89
,
0x2e
,
0xbe
,
0x30
,
0x14
,
0x3c
,
0xe2
,
0x87
,
0x40
,
0x01
,
0x1e
,
0xcf
},
.
rlen
=
28
,
},
{
.
key
=
{
0xef
,
0x01
,
0x23
,
0x45
},
.
klen
=
4
,
.
input
=
{
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
},
.
ilen
=
10
,
.
result
=
{
0xd6
,
0xa1
,
0x41
,
0xa7
,
0xec
,
0x3c
,
0x38
,
0xdf
,
0xbd
,
0x61
},
.
rlen
=
10
,
},
{
.
key
=
{
0x01
,
0x23
,
0x45
,
0x67
,
0x89
,
0xAB
,
0xCD
,
0xEF
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
},
.
klen
=
16
,
.
input
=
{
0x01
,
0x23
,
0x45
,
0x67
,
0x89
,
0xAB
,
0xCD
,
0xEF
},
.
ilen
=
8
,
.
result
=
{
0x69
,
0x72
,
0x36
,
0x59
,
0x1B
,
0x52
,
0x42
,
0xB1
},
.
rlen
=
8
,
},
};
struct
cipher_testvec
arc4_dec_tv_template
[]
=
{
{
.
key
=
{
0x01
,
0x23
,
0x45
,
0x67
,
0x89
,
0xab
,
0xcd
,
0xef
},
.
klen
=
8
,
.
input
=
{
0x75
,
0xb7
,
0x87
,
0x80
,
0x99
,
0xe0
,
0xc5
,
0x96
},
.
ilen
=
8
,
.
result
=
{
0x01
,
0x23
,
0x45
,
0x67
,
0x89
,
0xab
,
0xcd
,
0xef
},
.
rlen
=
8
,
},
{
.
key
=
{
0x01
,
0x23
,
0x45
,
0x67
,
0x89
,
0xab
,
0xcd
,
0xef
},
.
klen
=
8
,
.
input
=
{
0x74
,
0x94
,
0xc2
,
0xe7
,
0x10
,
0x4b
,
0x08
,
0x79
},
.
ilen
=
8
,
.
result
=
{
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
},
.
rlen
=
8
,
},
{
.
key
=
{
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
},
.
klen
=
8
,
.
input
=
{
0xde
,
0x18
,
0x89
,
0x41
,
0xa3
,
0x37
,
0x5d
,
0x3a
},
.
ilen
=
8
,
.
result
=
{
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
},
.
rlen
=
8
,
},
{
.
key
=
{
0xef
,
0x01
,
0x23
,
0x45
},
.
klen
=
4
,
.
input
=
{
0xd6
,
0xa1
,
0x41
,
0xa7
,
0xec
,
0x3c
,
0x38
,
0xdf
,
0xbd
,
0x61
,
0x5a
,
0x11
,
0x62
,
0xe1
,
0xc7
,
0xba
,
0x36
,
0xb6
,
0x78
,
0x58
},
.
ilen
=
20
,
.
result
=
{
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
},
.
rlen
=
20
,
},
{
.
key
=
{
0x01
,
0x23
,
0x45
,
0x67
,
0x89
,
0xab
,
0xcd
,
0xef
},
.
klen
=
8
,
.
input
=
{
0x66
,
0xa0
,
0x94
,
0x9f
,
0x8a
,
0xf7
,
0xd6
,
0x89
,
0x1f
,
0x7f
,
0x83
,
0x2b
,
0xa8
,
0x33
,
0xc0
,
0x0c
,
0x89
,
0x2e
,
0xbe
,
0x30
,
0x14
,
0x3c
,
0xe2
,
0x87
,
0x40
,
0x01
,
0x1e
,
0xcf
},
.
ilen
=
28
,
.
result
=
{
0x12
,
0x34
,
0x56
,
0x78
,
0x9A
,
0xBC
,
0xDE
,
0xF0
,
0x12
,
0x34
,
0x56
,
0x78
,
0x9A
,
0xBC
,
0xDE
,
0xF0
,
0x12
,
0x34
,
0x56
,
0x78
,
0x9A
,
0xBC
,
0xDE
,
0xF0
,
0x12
,
0x34
,
0x56
,
0x78
},
.
rlen
=
28
,
},
{
.
key
=
{
0xef
,
0x01
,
0x23
,
0x45
},
.
klen
=
4
,
.
input
=
{
0xd6
,
0xa1
,
0x41
,
0xa7
,
0xec
,
0x3c
,
0x38
,
0xdf
,
0xbd
,
0x61
},
.
ilen
=
10
,
.
result
=
{
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
},
.
rlen
=
10
,
},
{
.
key
=
{
0x01
,
0x23
,
0x45
,
0x67
,
0x89
,
0xAB
,
0xCD
,
0xEF
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
},
.
klen
=
16
,
.
input
=
{
0x69
,
0x72
,
0x36
,
0x59
,
0x1B
,
0x52
,
0x42
,
0xB1
},
.
ilen
=
8
,
.
result
=
{
0x01
,
0x23
,
0x45
,
0x67
,
0x89
,
0xAB
,
0xCD
,
0xEF
},
.
rlen
=
8
,
},
};
/*
* 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