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
fb4e6f86
Commit
fb4e6f86
authored
Nov 06, 2002
by
James Morris
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[CRYPTO]: Add blowfish algorithm.
parent
6a86b3f1
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
965 additions
and
53 deletions
+965
-53
Documentation/crypto/api-intro.txt
Documentation/crypto/api-intro.txt
+10
-0
crypto/Kconfig
crypto/Kconfig
+16
-5
crypto/Makefile
crypto/Makefile
+1
-0
crypto/api.c
crypto/api.c
+10
-6
crypto/blowfish.c
crypto/blowfish.c
+479
-0
crypto/cipher.c
crypto/cipher.c
+8
-2
crypto/des.c
crypto/des.c
+26
-34
crypto/tcrypt.c
crypto/tcrypt.c
+211
-1
crypto/tcrypt.h
crypto/tcrypt.h
+195
-2
include/linux/crypto.h
include/linux/crypto.h
+9
-3
No files found.
Documentation/crypto/api-intro.txt
View file @
fb4e6f86
...
...
@@ -101,6 +101,10 @@ will not be included in the mainline until around 2011), and be based
on a recognized standard and/or have been subjected to appropriate
peer review.
Also check for any RFCs which may relate to the use of specific algorithms,
as well as general application notes such as RFC2451 ("The ESP CBC-Mode
Cipher Algorithms").
BUGS
...
...
@@ -164,6 +168,7 @@ Original developers of the initial set of crypto algorithms:
Andrew Tridgell and Steve French (MD4)
Colin Plumb (MD5)
Steve Raid (SHA1)
Jean-Luc Cooke (SHA256)
Kazunori Miyazawa / USAGI (HMAC)
The DES code was subsequently redeveloped by:
...
...
@@ -172,6 +177,11 @@ The DES code was subsequently redeveloped by:
Gisle Sælensminde
Niels Möller
The Blowfish code was subsequently redeveloped by:
Herbert Valerio Riedel
Kyle McMartin
Please send any credits updates or corrections to:
James Morris <jmorris@intercode.com.au>
crypto/Kconfig
View file @
fb4e6f86
...
...
@@ -32,18 +32,16 @@ config CRYPTO_SHA1
tristate "SHA1 digest algorithm"
depends on CRYPTO
help
SHA-1 secure hash standard (FIPS 180-1).
SHA-1 secure hash standard (FIPS 180-1
/DFIPS 180-2
).
config CRYPTO_SHA256
tristate "SHA256 digest algorithm"
depends on CRYPTO
help
SHA256 secure hash standard.
SHA256 secure hash standard
(DFIPS 180-2)
.
This version of SHA implements a 256 bit hash with 128 bits of
security against collision attacks. It is described in:
http://csrc.nist.gov/cryptval/shs/sha256-384-512.pdf
security against collision attacks.
config CRYPTO_DES
tristate "DES and Triple DES EDE cipher algorithms"
...
...
@@ -51,6 +49,19 @@ config CRYPTO_DES
help
DES cipher algorithm (FIPS 46-2), and Triple DES EDE (FIPS 46-3).
config CRYPTO_BLOWFISH
tristate "Blowfish cipher algorithm"
depends on CRYPTO
help
Blowfish cipher algorithm, by Bruce Schneier.
This is a fast cipher which can use variable length key from 32
bits to 448 bits. It's fast, simple and specifically designed for
use on "large microprocessors".
See also:
http://www.counterpane.com/blowfish.html
config CRYPTO_TEST
tristate "Testing module"
depends on CRYPTO
...
...
crypto/Makefile
View file @
fb4e6f86
...
...
@@ -14,6 +14,7 @@ obj-$(CONFIG_CRYPTO_MD5) += md5.o
obj-$(CONFIG_CRYPTO_SHA1)
+=
sha1.o
obj-$(CONFIG_CRYPTO_SHA256)
+=
sha256.o
obj-$(CONFIG_CRYPTO_DES)
+=
des.o
obj-$(CONFIG_CRYPTO_BLOWFISH)
+=
blowfish.o
obj-$(CONFIG_CRYPTO_TEST)
+=
tcrypt.o
...
...
crypto/api.c
View file @
fb4e6f86
...
...
@@ -262,19 +262,23 @@ static int c_show(struct seq_file *m, void *p)
{
struct
crypto_alg
*
alg
=
(
struct
crypto_alg
*
)
p
;
seq_printf
(
m
,
"name : %s
\n
"
,
alg
->
cra_name
);
seq_printf
(
m
,
"module : %s
\n
"
,
alg
->
cra_module
?
seq_printf
(
m
,
"name
: %s
\n
"
,
alg
->
cra_name
);
seq_printf
(
m
,
"module
: %s
\n
"
,
alg
->
cra_module
?
alg
->
cra_module
->
name
:
"[static]"
);
seq_printf
(
m
,
"blocksize : %u
\n
"
,
alg
->
cra_blocksize
);
seq_printf
(
m
,
"blocksize
: %u
\n
"
,
alg
->
cra_blocksize
);
switch
(
alg
->
cra_flags
&
CRYPTO_ALG_TYPE_MASK
)
{
case
CRYPTO_ALG_TYPE_CIPHER
:
seq_printf
(
m
,
"keysize : %u
\n
"
,
alg
->
cra_cipher
.
cia_keysize
);
seq_printf
(
m
,
"ivsize : %u
\n
"
,
alg
->
cra_cipher
.
cia_ivsize
);
seq_printf
(
m
,
"min keysize : %u
\n
"
,
alg
->
cra_cipher
.
cia_min_keysize
);
seq_printf
(
m
,
"max keysize : %u
\n
"
,
alg
->
cra_cipher
.
cia_max_keysize
);
seq_printf
(
m
,
"ivsize : %u
\n
"
,
alg
->
cra_cipher
.
cia_ivsize
);
break
;
case
CRYPTO_ALG_TYPE_DIGEST
:
seq_printf
(
m
,
"digestsize : %u
\n
"
,
seq_printf
(
m
,
"digestsize
: %u
\n
"
,
alg
->
cra_digest
.
dia_digestsize
);
break
;
}
...
...
crypto/blowfish.c
0 → 100644
View file @
fb4e6f86
This diff is collapsed.
Click to expand it.
crypto/cipher.c
View file @
fb4e6f86
...
...
@@ -188,8 +188,14 @@ static void ecb_process(struct crypto_tfm *tfm, u8 *block,
static
int
setkey
(
struct
crypto_tfm
*
tfm
,
const
u8
*
key
,
unsigned
int
keylen
)
{
return
tfm
->
__crt_alg
->
cra_cipher
.
cia_setkey
(
tfm
->
crt_ctx
,
key
,
keylen
,
&
tfm
->
crt_flags
);
struct
cipher_alg
*
cia
=
&
tfm
->
__crt_alg
->
cra_cipher
;
if
(
keylen
<
cia
->
cia_min_keysize
||
keylen
>
cia
->
cia_max_keysize
)
{
tfm
->
crt_flags
|=
CRYPTO_TFM_RES_BAD_KEY_LEN
;
return
-
EINVAL
;
}
else
return
cia
->
cia_setkey
(
tfm
->
crt_ctx
,
key
,
keylen
,
&
tfm
->
crt_flags
);
}
static
int
ecb_encrypt
(
struct
crypto_tfm
*
tfm
,
...
...
crypto/des.c
View file @
fb4e6f86
...
...
@@ -1032,11 +1032,6 @@ static int setkey(u32 *expkey, const u8 *key, unsigned int keylen, u32 *flags)
u32
n
,
w
;
u8
bits0
[
56
],
bits1
[
56
];
if
(
keylen
!=
DES_KEY_SIZE
)
{
*
flags
|=
CRYPTO_TFM_RES_BAD_KEY_LEN
;
return
-
EINVAL
;
}
n
=
parity
[
key
[
0
]];
n
<<=
4
;
n
|=
parity
[
key
[
1
]];
n
<<=
4
;
n
|=
parity
[
key
[
2
]];
n
<<=
4
;
...
...
@@ -1208,11 +1203,6 @@ static int des3_ede_setkey(void *ctx, const u8 *key,
unsigned
int
i
,
off
;
struct
des3_ede_ctx
*
dctx
=
ctx
;
if
(
keylen
!=
DES3_EDE_KEY_SIZE
)
{
*
flags
|=
CRYPTO_TFM_RES_BAD_KEY_LEN
;
return
-
EINVAL
;
}
if
(
!
(
memcmp
(
key
,
&
key
[
DES_KEY_SIZE
],
DES_KEY_SIZE
)
&&
memcmp
(
&
key
[
DES_KEY_SIZE
],
&
key
[
DES_KEY_SIZE
*
2
],
DES_KEY_SIZE
)))
{
...
...
@@ -1249,33 +1239,35 @@ static void des3_ede_decrypt(void *ctx, u8 *dst, const u8 *src)
}
static
struct
crypto_alg
des_alg
=
{
.
cra_name
=
"des"
,
.
cra_flags
=
CRYPTO_ALG_TYPE_CIPHER
,
.
cra_blocksize
=
DES_BLOCK_SIZE
,
.
cra_ctxsize
=
sizeof
(
struct
des_ctx
),
.
cra_module
=
THIS_MODULE
,
.
cra_list
=
LIST_HEAD_INIT
(
des_alg
.
cra_list
),
.
cra_u
=
{
.
cipher
=
{
.
cia_keysize
=
DES_KEY_SIZE
,
.
cia_ivsize
=
DES_BLOCK_SIZE
,
.
cia_setkey
=
des_setkey
,
.
cia_encrypt
=
des_encrypt
,
.
cia_decrypt
=
des_decrypt
}
}
.
cra_name
=
"des"
,
.
cra_flags
=
CRYPTO_ALG_TYPE_CIPHER
,
.
cra_blocksize
=
DES_BLOCK_SIZE
,
.
cra_ctxsize
=
sizeof
(
struct
des_ctx
),
.
cra_module
=
THIS_MODULE
,
.
cra_list
=
LIST_HEAD_INIT
(
des_alg
.
cra_list
),
.
cra_u
=
{
.
cipher
=
{
.
cia_min_keysize
=
DES_KEY_SIZE
,
.
cia_max_keysize
=
DES_KEY_SIZE
,
.
cia_ivsize
=
DES_BLOCK_SIZE
,
.
cia_setkey
=
des_setkey
,
.
cia_encrypt
=
des_encrypt
,
.
cia_decrypt
=
des_decrypt
}
}
};
static
struct
crypto_alg
des3_ede_alg
=
{
.
cra_name
=
"des3_ede"
,
.
cra_flags
=
CRYPTO_ALG_TYPE_CIPHER
,
.
cra_blocksize
=
DES3_EDE_BLOCK_SIZE
,
.
cra_ctxsize
=
sizeof
(
struct
des3_ede_ctx
),
.
cra_module
=
THIS_MODULE
,
.
cra_list
=
LIST_HEAD_INIT
(
des3_ede_alg
.
cra_list
),
.
cra_u
=
{
.
cipher
=
{
.
cia_keysize
=
DES3_EDE_KEY_SIZE
,
.
cia_ivsize
=
DES3_EDE_BLOCK_SIZE
,
.
cia_setkey
=
des3_ede_setkey
,
.
cia_encrypt
=
des3_ede_encrypt
,
.
cia_decrypt
=
des3_ede_decrypt
}
}
.
cra_name
=
"des3_ede"
,
.
cra_flags
=
CRYPTO_ALG_TYPE_CIPHER
,
.
cra_blocksize
=
DES3_EDE_BLOCK_SIZE
,
.
cra_ctxsize
=
sizeof
(
struct
des3_ede_ctx
),
.
cra_module
=
THIS_MODULE
,
.
cra_list
=
LIST_HEAD_INIT
(
des3_ede_alg
.
cra_list
),
.
cra_u
=
{
.
cipher
=
{
.
cia_min_keysize
=
DES3_EDE_KEY_SIZE
,
.
cia_max_keysize
=
DES3_EDE_KEY_SIZE
,
.
cia_ivsize
=
DES3_EDE_BLOCK_SIZE
,
.
cia_setkey
=
des3_ede_setkey
,
.
cia_encrypt
=
des3_ede_encrypt
,
.
cia_decrypt
=
des3_ede_decrypt
}
}
};
static
int
__init
init
(
void
)
...
...
crypto/tcrypt.c
View file @
fb4e6f86
...
...
@@ -47,7 +47,7 @@ static char *xbuf;
static
char
*
tvmem
;
static
char
*
check
[]
=
{
"des"
,
"md5"
,
"des3_ede"
,
"rot13"
,
"sha1"
,
"sha256"
,
"des"
,
"md5"
,
"des3_ede"
,
"rot13"
,
"sha1"
,
"sha256"
,
"blowfish"
,
NULL
};
...
...
@@ -1480,6 +1480,210 @@ test_des3_ede(void)
crypto_free_tfm
(
tfm
);
}
void
test_blowfish
(
void
)
{
unsigned
int
ret
,
i
;
unsigned
int
tsize
;
char
*
p
,
*
q
;
struct
crypto_tfm
*
tfm
;
char
*
key
;
struct
bf_tv
*
bf_tv
;
struct
scatterlist
sg
[
1
];
printk
(
"
\n
testing blowfish encryption
\n
"
);
tsize
=
sizeof
(
bf_enc_tv_template
);
if
(
tsize
>
TVMEMSIZE
)
{
printk
(
"template (%u) too big for tvmem (%u)
\n
"
,
tsize
,
TVMEMSIZE
);
return
;
}
memcpy
(
tvmem
,
bf_enc_tv_template
,
tsize
);
bf_tv
=
(
void
*
)
tvmem
;
tfm
=
crypto_alloc_tfm
(
"blowfish"
,
0
);
if
(
tfm
==
NULL
)
{
printk
(
"failed to load transform for blowfish (default ecb)
\n
"
);
return
;
}
for
(
i
=
0
;
i
<
BF_ENC_TEST_VECTORS
;
i
++
)
{
printk
(
"test %u (%d bit key):
\n
"
,
i
+
1
,
bf_tv
[
i
].
keylen
*
8
);
key
=
bf_tv
[
i
].
key
;
ret
=
crypto_cipher_setkey
(
tfm
,
key
,
bf_tv
[
i
].
keylen
);
if
(
ret
)
{
printk
(
"setkey() failed flags=%x
\n
"
,
tfm
->
crt_flags
);
if
(
!
bf_tv
[
i
].
fail
)
goto
out
;
}
p
=
bf_tv
[
i
].
plaintext
;
sg
[
0
].
page
=
virt_to_page
(
p
);
sg
[
0
].
offset
=
((
long
)
p
&
~
PAGE_MASK
);
sg
[
0
].
length
=
bf_tv
[
i
].
plen
;
ret
=
crypto_cipher_encrypt
(
tfm
,
sg
,
1
);
if
(
ret
)
{
printk
(
"encrypt() failed flags=%x
\n
"
,
tfm
->
crt_flags
);
goto
out
;
}
q
=
kmap
(
sg
[
0
].
page
)
+
sg
[
0
].
offset
;
hexdump
(
q
,
bf_tv
[
i
].
rlen
);
printk
(
"%s
\n
"
,
memcmp
(
q
,
bf_tv
[
i
].
result
,
bf_tv
[
i
].
rlen
)
?
"fail"
:
"pass"
);
}
printk
(
"
\n
testing blowfish decryption
\n
"
);
tsize
=
sizeof
(
bf_dec_tv_template
);
if
(
tsize
>
TVMEMSIZE
)
{
printk
(
"template (%u) too big for tvmem (%u)
\n
"
,
tsize
,
TVMEMSIZE
);
return
;
}
memcpy
(
tvmem
,
bf_dec_tv_template
,
tsize
);
bf_tv
=
(
void
*
)
tvmem
;
for
(
i
=
0
;
i
<
BF_DEC_TEST_VECTORS
;
i
++
)
{
printk
(
"test %u (%d bit key):
\n
"
,
i
+
1
,
bf_tv
[
i
].
keylen
*
8
);
key
=
bf_tv
[
i
].
key
;
ret
=
crypto_cipher_setkey
(
tfm
,
key
,
bf_tv
[
i
].
keylen
);
if
(
ret
)
{
printk
(
"setkey() failed flags=%x
\n
"
,
tfm
->
crt_flags
);
if
(
!
bf_tv
[
i
].
fail
)
goto
out
;
}
p
=
bf_tv
[
i
].
plaintext
;
sg
[
0
].
page
=
virt_to_page
(
p
);
sg
[
0
].
offset
=
((
long
)
p
&
~
PAGE_MASK
);
sg
[
0
].
length
=
bf_tv
[
i
].
plen
;
ret
=
crypto_cipher_decrypt
(
tfm
,
sg
,
1
);
if
(
ret
)
{
printk
(
"decrypt() failed flags=%x
\n
"
,
tfm
->
crt_flags
);
goto
out
;
}
q
=
kmap
(
sg
[
0
].
page
)
+
sg
[
0
].
offset
;
hexdump
(
q
,
bf_tv
[
i
].
rlen
);
printk
(
"%s
\n
"
,
memcmp
(
q
,
bf_tv
[
i
].
result
,
bf_tv
[
i
].
rlen
)
?
"fail"
:
"pass"
);
}
crypto_free_tfm
(
tfm
);
tfm
=
crypto_alloc_tfm
(
"blowfish"
,
CRYPTO_TFM_MODE_CBC
);
if
(
tfm
==
NULL
)
{
printk
(
"failed to load transform for blowfish cbc
\n
"
);
return
;
}
printk
(
"
\n
testing blowfish cbc encryption
\n
"
);
tsize
=
sizeof
(
bf_cbc_enc_tv_template
);
if
(
tsize
>
TVMEMSIZE
)
{
printk
(
"template (%u) too big for tvmem (%u)
\n
"
,
tsize
,
TVMEMSIZE
);
goto
out
;
}
memcpy
(
tvmem
,
bf_cbc_enc_tv_template
,
tsize
);
bf_tv
=
(
void
*
)
tvmem
;
for
(
i
=
0
;
i
<
BF_CBC_ENC_TEST_VECTORS
;
i
++
)
{
printk
(
"test %u (%d bit key):
\n
"
,
i
+
1
,
bf_tv
[
i
].
keylen
*
8
);
key
=
bf_tv
[
i
].
key
;
ret
=
crypto_cipher_setkey
(
tfm
,
key
,
bf_tv
[
i
].
keylen
);
if
(
ret
)
{
printk
(
"setkey() failed flags=%x
\n
"
,
tfm
->
crt_flags
);
goto
out
;
}
p
=
bf_tv
[
i
].
plaintext
;
sg
[
0
].
page
=
virt_to_page
(
p
);
sg
[
0
].
offset
=
((
long
)
p
&
~
PAGE_MASK
);
sg
[
0
].
length
=
bf_tv
[
i
].
plen
;;
crypto_cipher_set_iv
(
tfm
,
bf_tv
[
i
].
iv
,
crypto_tfm_alg_ivsize
(
tfm
));
ret
=
crypto_cipher_encrypt
(
tfm
,
sg
,
1
);
if
(
ret
)
{
printk
(
"blowfish_cbc_encrypt() failed flags=%x
\n
"
,
tfm
->
crt_flags
);
goto
out
;
}
q
=
kmap
(
sg
[
0
].
page
)
+
sg
[
0
].
offset
;
hexdump
(
q
,
bf_tv
[
i
].
rlen
);
printk
(
"%s
\n
"
,
memcmp
(
q
,
bf_tv
[
i
].
result
,
bf_tv
[
i
].
rlen
)
?
"fail"
:
"pass"
);
}
printk
(
"
\n
testing blowfish cbc decryption
\n
"
);
tsize
=
sizeof
(
bf_cbc_dec_tv_template
);
if
(
tsize
>
TVMEMSIZE
)
{
printk
(
"template (%u) too big for tvmem (%u)
\n
"
,
tsize
,
TVMEMSIZE
);
goto
out
;
}
memcpy
(
tvmem
,
bf_cbc_dec_tv_template
,
tsize
);
bf_tv
=
(
void
*
)
tvmem
;
for
(
i
=
0
;
i
<
BF_CBC_ENC_TEST_VECTORS
;
i
++
)
{
printk
(
"test %u (%d bit key):
\n
"
,
i
+
1
,
bf_tv
[
i
].
keylen
*
8
);
key
=
bf_tv
[
i
].
key
;
ret
=
crypto_cipher_setkey
(
tfm
,
key
,
bf_tv
[
i
].
keylen
);
if
(
ret
)
{
printk
(
"setkey() failed flags=%x
\n
"
,
tfm
->
crt_flags
);
goto
out
;
}
p
=
bf_tv
[
i
].
plaintext
;
sg
[
0
].
page
=
virt_to_page
(
p
);
sg
[
0
].
offset
=
((
long
)
p
&
~
PAGE_MASK
);
sg
[
0
].
length
=
bf_tv
[
i
].
plen
;;
crypto_cipher_set_iv
(
tfm
,
bf_tv
[
i
].
iv
,
crypto_tfm_alg_ivsize
(
tfm
));
ret
=
crypto_cipher_decrypt
(
tfm
,
sg
,
1
);
if
(
ret
)
{
printk
(
"blowfish_cbc_decrypt() failed flags=%x
\n
"
,
tfm
->
crt_flags
);
goto
out
;
}
q
=
kmap
(
sg
[
0
].
page
)
+
sg
[
0
].
offset
;
hexdump
(
q
,
bf_tv
[
i
].
rlen
);
printk
(
"%s
\n
"
,
memcmp
(
q
,
bf_tv
[
i
].
result
,
bf_tv
[
i
].
rlen
)
?
"fail"
:
"pass"
);
}
out:
crypto_free_tfm
(
tfm
);
}
static
void
test_available
(
void
)
{
...
...
@@ -1504,6 +1708,8 @@ do_test(void)
test_des
();
test_des3_ede
();
test_md4
();
test_sha256
();
test_blowfish
();
#ifdef CONFIG_CRYPTO_HMAC
test_hmac_md5
();
test_hmac_sha1
();
...
...
@@ -1534,6 +1740,10 @@ do_test(void)
case
6
:
test_sha256
();
break
;
case
7
:
test_blowfish
();
break
;
#ifdef CONFIG_CRYPTO_HMAC
case
100
:
...
...
crypto/tcrypt.h
View file @
fb4e6f86
...
...
@@ -591,7 +591,7 @@ struct sha256_testvec {
};
/*
* DES test vectors
(also need to test for weak keys etc)
.
* DES test vectors.
*/
#define DES_ENC_TEST_VECTORS 5
#define DES_DEC_TEST_VECTORS 2
...
...
@@ -972,6 +972,199 @@ struct des_tv des3_ede_dec_tv_template[] = {
{
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
},
},
};
/*
* Blowfish test vectors.
*/
#define BF_ENC_TEST_VECTORS 6
#define BF_DEC_TEST_VECTORS 6
#define BF_CBC_ENC_TEST_VECTORS 1
#define BF_CBC_DEC_TEST_VECTORS 1
struct
bf_tv
{
unsigned
int
keylen
;
unsigned
int
plen
;
unsigned
int
rlen
;
int
fail
;
char
key
[
56
];
char
iv
[
8
];
char
plaintext
[
32
];
char
result
[
32
];
};
struct
bf_tv
bf_enc_tv_template
[]
=
{
/* DES test vectors from OpenSSL */
{
8
,
8
,
8
,
0
,
{
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
},
{
0
},
{
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
},
{
0x4E
,
0xF9
,
0x97
,
0x45
,
0x61
,
0x98
,
0xDD
,
0x78
},
},
#endif
/* _CRYPTO_TCRYPT_H */
{
8
,
8
,
8
,
0
,
{
0x1F
,
0x1F
,
0x1F
,
0x1F
,
0x0E
,
0x0E
,
0x0E
,
0x0E
,
},
{
0
},
{
0x01
,
0x23
,
0x45
,
0x67
,
0x89
,
0xAB
,
0xCD
,
0xEF
},
{
0xA7
,
0x90
,
0x79
,
0x51
,
0x08
,
0xEA
,
0x3C
,
0xAE
},
},
{
8
,
8
,
8
,
0
,
{
0xF0
,
0xE1
,
0xD2
,
0xC3
,
0xB4
,
0xA5
,
0x96
,
0x87
,
},
{
0
},
{
0xFE
,
0xDC
,
0xBA
,
0x98
,
0x76
,
0x54
,
0x32
,
0x10
},
{
0xE8
,
0x7A
,
0x24
,
0x4E
,
0x2C
,
0xC8
,
0x5E
,
0x82
}
},
/* Vary the keylength... */
{
16
,
8
,
8
,
0
,
{
0xF0
,
0xE1
,
0xD2
,
0xC3
,
0xB4
,
0xA5
,
0x96
,
0x87
,
0x78
,
0x69
,
0x5A
,
0x4B
,
0x3C
,
0x2D
,
0x1E
,
0x0F
},
{
0
},
{
0xFE
,
0xDC
,
0xBA
,
0x98
,
0x76
,
0x54
,
0x32
,
0x10
},
{
0x93
,
0x14
,
0x28
,
0x87
,
0xEE
,
0x3B
,
0xE1
,
0x5C
}
},
{
21
,
8
,
8
,
0
,
{
0xF0
,
0xE1
,
0xD2
,
0xC3
,
0xB4
,
0xA5
,
0x96
,
0x87
,
0x78
,
0x69
,
0x5A
,
0x4B
,
0x3C
,
0x2D
,
0x1E
,
0x0F
,
0x00
,
0x11
,
0x22
,
0x33
,
0x44
},
{
0
},
{
0xFE
,
0xDC
,
0xBA
,
0x98
,
0x76
,
0x54
,
0x32
,
0x10
},
{
0xE6
,
0xF5
,
0x1E
,
0xD7
,
0x9B
,
0x9D
,
0xB2
,
0x1F
}
},
/* Generated with bf488 */
{
56
,
8
,
8
,
0
,
{
0xF0
,
0xE1
,
0xD2
,
0xC3
,
0xB4
,
0xA5
,
0x96
,
0x87
,
0x78
,
0x69
,
0x5A
,
0x4B
,
0x3C
,
0x2D
,
0x1E
,
0x0F
,
0x00
,
0x11
,
0x22
,
0x33
,
0x44
,
0x55
,
0x66
,
0x77
,
0x04
,
0x68
,
0x91
,
0x04
,
0xC2
,
0xFD
,
0x3B
,
0x2F
,
0x58
,
0x40
,
0x23
,
0x64
,
0x1A
,
0xBA
,
0x61
,
0x76
,
0x1F
,
0x1F
,
0x1F
,
0x1F
,
0x0E
,
0x0E
,
0x0E
,
0x0E
,
0xFF
,
0xFF
,
0xFF
,
0xFF
,
0xFF
,
0xFF
,
0xFF
,
0xFF
},
{
0
},
{
0xFE
,
0xDC
,
0xBA
,
0x98
,
0x76
,
0x54
,
0x32
,
0x10
},
{
0xc0
,
0x45
,
0x04
,
0x01
,
0x2e
,
0x4e
,
0x1f
,
0x53
}
}
};
struct
bf_tv
bf_dec_tv_template
[]
=
{
/* DES test vectors from OpenSSL */
{
8
,
8
,
8
,
0
,
{
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
},
{
0
},
{
0x4E
,
0xF9
,
0x97
,
0x45
,
0x61
,
0x98
,
0xDD
,
0x78
},
{
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
}
},
{
8
,
8
,
8
,
0
,
{
0x1F
,
0x1F
,
0x1F
,
0x1F
,
0x0E
,
0x0E
,
0x0E
,
0x0E
,
},
{
0
},
{
0xA7
,
0x90
,
0x79
,
0x51
,
0x08
,
0xEA
,
0x3C
,
0xAE
},
{
0x01
,
0x23
,
0x45
,
0x67
,
0x89
,
0xAB
,
0xCD
,
0xEF
}
},
{
8
,
8
,
8
,
0
,
{
0xF0
,
0xE1
,
0xD2
,
0xC3
,
0xB4
,
0xA5
,
0x96
,
0x87
,
},
{
0
},
{
0xE8
,
0x7A
,
0x24
,
0x4E
,
0x2C
,
0xC8
,
0x5E
,
0x82
},
{
0xFE
,
0xDC
,
0xBA
,
0x98
,
0x76
,
0x54
,
0x32
,
0x10
}
},
/* Vary the keylength... */
{
16
,
8
,
8
,
0
,
{
0xF0
,
0xE1
,
0xD2
,
0xC3
,
0xB4
,
0xA5
,
0x96
,
0x87
,
0x78
,
0x69
,
0x5A
,
0x4B
,
0x3C
,
0x2D
,
0x1E
,
0x0F
},
{
0
},
{
0x93
,
0x14
,
0x28
,
0x87
,
0xEE
,
0x3B
,
0xE1
,
0x5C
},
{
0xFE
,
0xDC
,
0xBA
,
0x98
,
0x76
,
0x54
,
0x32
,
0x10
}
},
{
21
,
8
,
8
,
0
,
{
0xF0
,
0xE1
,
0xD2
,
0xC3
,
0xB4
,
0xA5
,
0x96
,
0x87
,
0x78
,
0x69
,
0x5A
,
0x4B
,
0x3C
,
0x2D
,
0x1E
,
0x0F
,
0x00
,
0x11
,
0x22
,
0x33
,
0x44
},
{
0
},
{
0xE6
,
0xF5
,
0x1E
,
0xD7
,
0x9B
,
0x9D
,
0xB2
,
0x1F
},
{
0xFE
,
0xDC
,
0xBA
,
0x98
,
0x76
,
0x54
,
0x32
,
0x10
}
},
/* Generated with bf488, using OpenSSL, Libgcrypt and Nettle */
{
56
,
8
,
8
,
0
,
{
0xF0
,
0xE1
,
0xD2
,
0xC3
,
0xB4
,
0xA5
,
0x96
,
0x87
,
0x78
,
0x69
,
0x5A
,
0x4B
,
0x3C
,
0x2D
,
0x1E
,
0x0F
,
0x00
,
0x11
,
0x22
,
0x33
,
0x44
,
0x55
,
0x66
,
0x77
,
0x04
,
0x68
,
0x91
,
0x04
,
0xC2
,
0xFD
,
0x3B
,
0x2F
,
0x58
,
0x40
,
0x23
,
0x64
,
0x1A
,
0xBA
,
0x61
,
0x76
,
0x1F
,
0x1F
,
0x1F
,
0x1F
,
0x0E
,
0x0E
,
0x0E
,
0x0E
,
0xFF
,
0xFF
,
0xFF
,
0xFF
,
0xFF
,
0xFF
,
0xFF
,
0xFF
},
{
0
},
{
0xc0
,
0x45
,
0x04
,
0x01
,
0x2e
,
0x4e
,
0x1f
,
0x53
},
{
0xFE
,
0xDC
,
0xBA
,
0x98
,
0x76
,
0x54
,
0x32
,
0x10
}
}
};
struct
bf_tv
bf_cbc_enc_tv_template
[]
=
{
/* From OpenSSL */
{
16
,
32
,
32
,
0
,
{
0x01
,
0x23
,
0x45
,
0x67
,
0x89
,
0xAB
,
0xCD
,
0xEF
,
0xF0
,
0xE1
,
0xD2
,
0xC3
,
0xB4
,
0xA5
,
0x96
,
0x87
},
{
0xFE
,
0xDC
,
0xBA
,
0x98
,
0x76
,
0x54
,
0x32
,
0x10
},
{
0x37
,
0x36
,
0x35
,
0x34
,
0x33
,
0x32
,
0x31
,
0x20
,
0x4E
,
0x6F
,
0x77
,
0x20
,
0x69
,
0x73
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x74
,
0x69
,
0x6D
,
0x65
,
0x20
,
0x66
,
0x6F
,
0x72
,
0x20
,
0x00
,
0x00
,
0x00
,
0x00
},
{
0x6B
,
0x77
,
0xB4
,
0xD6
,
0x30
,
0x06
,
0xDE
,
0xE6
,
0x05
,
0xB1
,
0x56
,
0xE2
,
0x74
,
0x03
,
0x97
,
0x93
,
0x58
,
0xDE
,
0xB9
,
0xE7
,
0x15
,
0x46
,
0x16
,
0xD9
,
0x59
,
0xF1
,
0x65
,
0x2B
,
0xD5
,
0xFF
,
0x92
,
0xCC
}
},
};
struct
bf_tv
bf_cbc_dec_tv_template
[]
=
{
/* From OpenSSL */
{
16
,
32
,
32
,
0
,
{
0x01
,
0x23
,
0x45
,
0x67
,
0x89
,
0xAB
,
0xCD
,
0xEF
,
0xF0
,
0xE1
,
0xD2
,
0xC3
,
0xB4
,
0xA5
,
0x96
,
0x87
},
{
0xFE
,
0xDC
,
0xBA
,
0x98
,
0x76
,
0x54
,
0x32
,
0x10
},
{
0x6B
,
0x77
,
0xB4
,
0xD6
,
0x30
,
0x06
,
0xDE
,
0xE6
,
0x05
,
0xB1
,
0x56
,
0xE2
,
0x74
,
0x03
,
0x97
,
0x93
,
0x58
,
0xDE
,
0xB9
,
0xE7
,
0x15
,
0x46
,
0x16
,
0xD9
,
0x59
,
0xF1
,
0x65
,
0x2B
,
0xD5
,
0xFF
,
0x92
,
0xCC
},
{
0x37
,
0x36
,
0x35
,
0x34
,
0x33
,
0x32
,
0x31
,
0x20
,
0x4E
,
0x6F
,
0x77
,
0x20
,
0x69
,
0x73
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x74
,
0x69
,
0x6D
,
0x65
,
0x20
,
0x66
,
0x6F
,
0x72
,
0x20
,
0x00
,
0x00
,
0x00
,
0x00
}
},
};
#endif
/* _CRYPTO_TCRYPT_H */
include/linux/crypto.h
View file @
fb4e6f86
...
...
@@ -67,7 +67,8 @@ struct scatterlist;
* via crypto_register_alg() and crypto_unregister_alg().
*/
struct
cipher_alg
{
unsigned
int
cia_keysize
;
unsigned
int
cia_min_keysize
;
unsigned
int
cia_max_keysize
;
unsigned
int
cia_ivsize
;
int
(
*
cia_setkey
)(
void
*
ctx
,
const
u8
*
key
,
unsigned
int
keylen
,
u32
*
flags
);
...
...
@@ -208,9 +209,14 @@ static inline u32 crypto_tfm_alg_type(struct crypto_tfm *tfm)
return
tfm
->
__crt_alg
->
cra_flags
&
CRYPTO_ALG_TYPE_MASK
;
}
static
inline
unsigned
int
crypto_tfm_alg_keysize
(
struct
crypto_tfm
*
tfm
)
static
inline
unsigned
int
crypto_tfm_alg_
min_
keysize
(
struct
crypto_tfm
*
tfm
)
{
return
tfm
->
__crt_alg
->
cra_cipher
.
cia_keysize
;
return
tfm
->
__crt_alg
->
cra_cipher
.
cia_min_keysize
;
}
static
inline
unsigned
int
crypto_tfm_alg_max_keysize
(
struct
crypto_tfm
*
tfm
)
{
return
tfm
->
__crt_alg
->
cra_cipher
.
cia_max_keysize
;
}
static
inline
unsigned
int
crypto_tfm_alg_ivsize
(
struct
crypto_tfm
*
tfm
)
...
...
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