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
d09f51b6
Commit
d09f51b6
authored
Jul 14, 2007
by
David S. Miller
Browse files
Options
Browse Files
Download
Plain Diff
Merge master.kernel.org:/pub/scm/linux/kernel/git/herbert/crypto-2.6
Conflicts: crypto/Kconfig
parents
1b1ac759
e559e91c
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
125 additions
and
34 deletions
+125
-34
crypto/Kconfig
crypto/Kconfig
+1
-5
crypto/ablkcipher.c
crypto/ablkcipher.c
+29
-2
crypto/algapi.c
crypto/algapi.c
+2
-2
crypto/api.c
crypto/api.c
+1
-1
crypto/blkcipher.c
crypto/blkcipher.c
+25
-0
crypto/cipher.c
crypto/cipher.c
+30
-3
crypto/hash.c
crypto/hash.c
+37
-1
include/linux/crypto.h
include/linux/crypto.h
+0
-20
No files found.
crypto/Kconfig
View file @
d09f51b6
...
...
@@ -12,9 +12,7 @@ source "crypto/async_tx/Kconfig"
#
# Cryptographic API Configuration
#
menu "Cryptographic options"
config CRYPTO
menuconfig CRYPTO
bool "Cryptographic API"
help
This option provides the core Cryptographic API.
...
...
@@ -473,5 +471,3 @@ config CRYPTO_TEST
source "drivers/crypto/Kconfig"
endif # if CRYPTO
endmenu
crypto/ablkcipher.c
View file @
d09f51b6
...
...
@@ -19,16 +19,41 @@
#include <linux/module.h>
#include <linux/seq_file.h>
static
int
setkey_unaligned
(
struct
crypto_ablkcipher
*
tfm
,
const
u8
*
key
,
unsigned
int
keylen
)
{
struct
ablkcipher_alg
*
cipher
=
crypto_ablkcipher_alg
(
tfm
);
unsigned
long
alignmask
=
crypto_ablkcipher_alignmask
(
tfm
);
int
ret
;
u8
*
buffer
,
*
alignbuffer
;
unsigned
long
absize
;
absize
=
keylen
+
alignmask
;
buffer
=
kmalloc
(
absize
,
GFP_ATOMIC
);
if
(
!
buffer
)
return
-
ENOMEM
;
alignbuffer
=
(
u8
*
)
ALIGN
((
unsigned
long
)
buffer
,
alignmask
+
1
);
memcpy
(
alignbuffer
,
key
,
keylen
);
ret
=
cipher
->
setkey
(
tfm
,
alignbuffer
,
keylen
);
memset
(
alignbuffer
,
0
,
absize
);
kfree
(
buffer
);
return
ret
;
}
static
int
setkey
(
struct
crypto_ablkcipher
*
tfm
,
const
u8
*
key
,
unsigned
int
keylen
)
{
struct
ablkcipher_alg
*
cipher
=
crypto_ablkcipher_alg
(
tfm
);
unsigned
long
alignmask
=
crypto_ablkcipher_alignmask
(
tfm
);
if
(
keylen
<
cipher
->
min_keysize
||
keylen
>
cipher
->
max_keysize
)
{
crypto_ablkcipher_set_flags
(
tfm
,
CRYPTO_TFM_RES_BAD_KEY_LEN
);
return
-
EINVAL
;
}
if
((
unsigned
long
)
key
&
alignmask
)
return
setkey_unaligned
(
tfm
,
key
,
keylen
);
return
cipher
->
setkey
(
tfm
,
key
,
keylen
);
}
...
...
@@ -66,8 +91,10 @@ static void crypto_ablkcipher_show(struct seq_file *m, struct crypto_alg *alg)
seq_printf
(
m
,
"min keysize : %u
\n
"
,
ablkcipher
->
min_keysize
);
seq_printf
(
m
,
"max keysize : %u
\n
"
,
ablkcipher
->
max_keysize
);
seq_printf
(
m
,
"ivsize : %u
\n
"
,
ablkcipher
->
ivsize
);
seq_printf
(
m
,
"qlen : %u
\n
"
,
ablkcipher
->
queue
->
qlen
);
seq_printf
(
m
,
"max qlen : %u
\n
"
,
ablkcipher
->
queue
->
max_qlen
);
if
(
ablkcipher
->
queue
)
{
seq_printf
(
m
,
"qlen : %u
\n
"
,
ablkcipher
->
queue
->
qlen
);
seq_printf
(
m
,
"max qlen : %u
\n
"
,
ablkcipher
->
queue
->
max_qlen
);
}
}
const
struct
crypto_type
crypto_ablkcipher_type
=
{
...
...
crypto/algapi.c
View file @
d09f51b6
...
...
@@ -34,7 +34,7 @@ void crypto_larval_error(const char *name, u32 type, u32 mask)
if
(
alg
)
{
if
(
crypto_is_larval
(
alg
))
{
struct
crypto_larval
*
larval
=
(
void
*
)
alg
;
complete
(
&
larval
->
completion
);
complete
_all
(
&
larval
->
completion
);
}
crypto_mod_put
(
alg
);
}
...
...
@@ -164,7 +164,7 @@ static int __crypto_register_alg(struct crypto_alg *alg,
continue
;
larval
->
adult
=
alg
;
complete
(
&
larval
->
completion
);
complete
_all
(
&
larval
->
completion
);
continue
;
}
...
...
crypto/api.c
View file @
d09f51b6
...
...
@@ -144,7 +144,7 @@ static void crypto_larval_kill(struct crypto_alg *alg)
down_write
(
&
crypto_alg_sem
);
list_del
(
&
alg
->
cra_list
);
up_write
(
&
crypto_alg_sem
);
complete
(
&
larval
->
completion
);
complete
_all
(
&
larval
->
completion
);
crypto_alg_put
(
alg
);
}
...
...
crypto/blkcipher.c
View file @
d09f51b6
...
...
@@ -336,16 +336,41 @@ static int blkcipher_walk_first(struct blkcipher_desc *desc,
return
blkcipher_walk_next
(
desc
,
walk
);
}
static
int
setkey_unaligned
(
struct
crypto_tfm
*
tfm
,
const
u8
*
key
,
unsigned
int
keylen
)
{
struct
blkcipher_alg
*
cipher
=
&
tfm
->
__crt_alg
->
cra_blkcipher
;
unsigned
long
alignmask
=
crypto_tfm_alg_alignmask
(
tfm
);
int
ret
;
u8
*
buffer
,
*
alignbuffer
;
unsigned
long
absize
;
absize
=
keylen
+
alignmask
;
buffer
=
kmalloc
(
absize
,
GFP_ATOMIC
);
if
(
!
buffer
)
return
-
ENOMEM
;
alignbuffer
=
(
u8
*
)
ALIGN
((
unsigned
long
)
buffer
,
alignmask
+
1
);
memcpy
(
alignbuffer
,
key
,
keylen
);
ret
=
cipher
->
setkey
(
tfm
,
alignbuffer
,
keylen
);
memset
(
alignbuffer
,
0
,
absize
);
kfree
(
buffer
);
return
ret
;
}
static
int
setkey
(
struct
crypto_tfm
*
tfm
,
const
u8
*
key
,
unsigned
int
keylen
)
{
struct
blkcipher_alg
*
cipher
=
&
tfm
->
__crt_alg
->
cra_blkcipher
;
unsigned
long
alignmask
=
crypto_tfm_alg_alignmask
(
tfm
);
if
(
keylen
<
cipher
->
min_keysize
||
keylen
>
cipher
->
max_keysize
)
{
tfm
->
crt_flags
|=
CRYPTO_TFM_RES_BAD_KEY_LEN
;
return
-
EINVAL
;
}
if
((
unsigned
long
)
key
&
alignmask
)
return
setkey_unaligned
(
tfm
,
key
,
keylen
);
return
cipher
->
setkey
(
tfm
,
key
,
keylen
);
}
...
...
crypto/cipher.c
View file @
d09f51b6
...
...
@@ -20,16 +20,43 @@
#include <linux/string.h>
#include "internal.h"
static
int
setkey_unaligned
(
struct
crypto_tfm
*
tfm
,
const
u8
*
key
,
unsigned
int
keylen
)
{
struct
cipher_alg
*
cia
=
&
tfm
->
__crt_alg
->
cra_cipher
;
unsigned
long
alignmask
=
crypto_tfm_alg_alignmask
(
tfm
);
int
ret
;
u8
*
buffer
,
*
alignbuffer
;
unsigned
long
absize
;
absize
=
keylen
+
alignmask
;
buffer
=
kmalloc
(
absize
,
GFP_ATOMIC
);
if
(
!
buffer
)
return
-
ENOMEM
;
alignbuffer
=
(
u8
*
)
ALIGN
((
unsigned
long
)
buffer
,
alignmask
+
1
);
memcpy
(
alignbuffer
,
key
,
keylen
);
ret
=
cia
->
cia_setkey
(
tfm
,
alignbuffer
,
keylen
);
memset
(
alignbuffer
,
0
,
absize
);
kfree
(
buffer
);
return
ret
;
}
static
int
setkey
(
struct
crypto_tfm
*
tfm
,
const
u8
*
key
,
unsigned
int
keylen
)
{
struct
cipher_alg
*
cia
=
&
tfm
->
__crt_alg
->
cra_cipher
;
unsigned
long
alignmask
=
crypto_tfm_alg_alignmask
(
tfm
);
tfm
->
crt_flags
&=
~
CRYPTO_TFM_RES_MASK
;
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
,
key
,
keylen
);
}
if
((
unsigned
long
)
key
&
alignmask
)
return
setkey_unaligned
(
tfm
,
key
,
keylen
);
return
cia
->
cia_setkey
(
tfm
,
key
,
keylen
);
}
static
void
cipher_crypt_unaligned
(
void
(
*
fn
)(
struct
crypto_tfm
*
,
u8
*
,
...
...
crypto/hash.c
View file @
d09f51b6
...
...
@@ -22,6 +22,42 @@ static unsigned int crypto_hash_ctxsize(struct crypto_alg *alg, u32 type,
return
alg
->
cra_ctxsize
;
}
static
int
hash_setkey_unaligned
(
struct
crypto_hash
*
crt
,
const
u8
*
key
,
unsigned
int
keylen
)
{
struct
crypto_tfm
*
tfm
=
crypto_hash_tfm
(
crt
);
struct
hash_alg
*
alg
=
&
tfm
->
__crt_alg
->
cra_hash
;
unsigned
long
alignmask
=
crypto_hash_alignmask
(
crt
);
int
ret
;
u8
*
buffer
,
*
alignbuffer
;
unsigned
long
absize
;
absize
=
keylen
+
alignmask
;
buffer
=
kmalloc
(
absize
,
GFP_ATOMIC
);
if
(
!
buffer
)
return
-
ENOMEM
;
alignbuffer
=
(
u8
*
)
ALIGN
((
unsigned
long
)
buffer
,
alignmask
+
1
);
memcpy
(
alignbuffer
,
key
,
keylen
);
ret
=
alg
->
setkey
(
crt
,
alignbuffer
,
keylen
);
memset
(
alignbuffer
,
0
,
absize
);
kfree
(
buffer
);
return
ret
;
}
static
int
hash_setkey
(
struct
crypto_hash
*
crt
,
const
u8
*
key
,
unsigned
int
keylen
)
{
struct
crypto_tfm
*
tfm
=
crypto_hash_tfm
(
crt
);
struct
hash_alg
*
alg
=
&
tfm
->
__crt_alg
->
cra_hash
;
unsigned
long
alignmask
=
crypto_hash_alignmask
(
crt
);
if
((
unsigned
long
)
key
&
alignmask
)
return
hash_setkey_unaligned
(
crt
,
key
,
keylen
);
return
alg
->
setkey
(
crt
,
key
,
keylen
);
}
static
int
crypto_init_hash_ops
(
struct
crypto_tfm
*
tfm
,
u32
type
,
u32
mask
)
{
struct
hash_tfm
*
crt
=
&
tfm
->
crt_hash
;
...
...
@@ -34,7 +70,7 @@ static int crypto_init_hash_ops(struct crypto_tfm *tfm, u32 type, u32 mask)
crt
->
update
=
alg
->
update
;
crt
->
final
=
alg
->
final
;
crt
->
digest
=
alg
->
digest
;
crt
->
setkey
=
alg
->
setkey
;
crt
->
setkey
=
hash_
setkey
;
crt
->
digestsize
=
alg
->
digestsize
;
return
0
;
...
...
include/linux/crypto.h
View file @
d09f51b6
...
...
@@ -295,28 +295,8 @@ struct blkcipher_tfm {
};
struct
cipher_tfm
{
void
*
cit_iv
;
unsigned
int
cit_ivsize
;
u32
cit_mode
;
int
(
*
cit_setkey
)(
struct
crypto_tfm
*
tfm
,
const
u8
*
key
,
unsigned
int
keylen
);
int
(
*
cit_encrypt
)(
struct
crypto_tfm
*
tfm
,
struct
scatterlist
*
dst
,
struct
scatterlist
*
src
,
unsigned
int
nbytes
);
int
(
*
cit_encrypt_iv
)(
struct
crypto_tfm
*
tfm
,
struct
scatterlist
*
dst
,
struct
scatterlist
*
src
,
unsigned
int
nbytes
,
u8
*
iv
);
int
(
*
cit_decrypt
)(
struct
crypto_tfm
*
tfm
,
struct
scatterlist
*
dst
,
struct
scatterlist
*
src
,
unsigned
int
nbytes
);
int
(
*
cit_decrypt_iv
)(
struct
crypto_tfm
*
tfm
,
struct
scatterlist
*
dst
,
struct
scatterlist
*
src
,
unsigned
int
nbytes
,
u8
*
iv
);
void
(
*
cit_xor_block
)(
u8
*
dst
,
const
u8
*
src
);
void
(
*
cit_encrypt_one
)(
struct
crypto_tfm
*
tfm
,
u8
*
dst
,
const
u8
*
src
);
void
(
*
cit_decrypt_one
)(
struct
crypto_tfm
*
tfm
,
u8
*
dst
,
const
u8
*
src
);
};
...
...
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