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
c6cb56fc
Commit
c6cb56fc
authored
Sep 27, 2011
by
James Morris
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'next-hex2bin' of
git://github.com/mzohar/linux-evm
into next
parents
a427fd14
8c35ad20
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
15 deletions
+47
-15
drivers/target/target_core_fabric_lib.c
drivers/target/target_core_fabric_lib.c
+9
-3
include/linux/kernel.h
include/linux/kernel.h
+1
-1
lib/hexdump.c
lib/hexdump.c
+11
-4
security/keys/encrypted-keys/encrypted.c
security/keys/encrypted-keys/encrypted.c
+11
-3
security/keys/trusted.c
security/keys/trusted.c
+15
-4
No files found.
drivers/target/target_core_fabric_lib.c
View file @
c6cb56fc
...
@@ -63,6 +63,7 @@ u32 sas_get_pr_transport_id(
...
@@ -63,6 +63,7 @@ u32 sas_get_pr_transport_id(
unsigned
char
*
buf
)
unsigned
char
*
buf
)
{
{
unsigned
char
*
ptr
;
unsigned
char
*
ptr
;
int
ret
;
/*
/*
* Set PROTOCOL IDENTIFIER to 6h for SAS
* Set PROTOCOL IDENTIFIER to 6h for SAS
...
@@ -74,7 +75,9 @@ u32 sas_get_pr_transport_id(
...
@@ -74,7 +75,9 @@ u32 sas_get_pr_transport_id(
*/
*/
ptr
=
&
se_nacl
->
initiatorname
[
4
];
/* Skip over 'naa. prefix */
ptr
=
&
se_nacl
->
initiatorname
[
4
];
/* Skip over 'naa. prefix */
hex2bin
(
&
buf
[
4
],
ptr
,
8
);
ret
=
hex2bin
(
&
buf
[
4
],
ptr
,
8
);
if
(
ret
<
0
)
pr_debug
(
"sas transport_id: invalid hex string
\n
"
);
/*
/*
* The SAS Transport ID is a hardcoded 24-byte length
* The SAS Transport ID is a hardcoded 24-byte length
...
@@ -156,8 +159,9 @@ u32 fc_get_pr_transport_id(
...
@@ -156,8 +159,9 @@ u32 fc_get_pr_transport_id(
unsigned
char
*
buf
)
unsigned
char
*
buf
)
{
{
unsigned
char
*
ptr
;
unsigned
char
*
ptr
;
int
i
;
int
i
,
ret
;
u32
off
=
8
;
u32
off
=
8
;
/*
/*
* PROTOCOL IDENTIFIER is 0h for FCP-2
* PROTOCOL IDENTIFIER is 0h for FCP-2
*
*
...
@@ -174,7 +178,9 @@ u32 fc_get_pr_transport_id(
...
@@ -174,7 +178,9 @@ u32 fc_get_pr_transport_id(
i
++
;
i
++
;
continue
;
continue
;
}
}
hex2bin
(
&
buf
[
off
++
],
&
ptr
[
i
],
1
);
ret
=
hex2bin
(
&
buf
[
off
++
],
&
ptr
[
i
],
1
);
if
(
ret
<
0
)
pr_debug
(
"fc transport_id: invalid hex string
\n
"
);
i
+=
2
;
i
+=
2
;
}
}
/*
/*
...
...
include/linux/kernel.h
View file @
c6cb56fc
...
@@ -382,7 +382,7 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
...
@@ -382,7 +382,7 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
}
}
extern
int
hex_to_bin
(
char
ch
);
extern
int
hex_to_bin
(
char
ch
);
extern
void
hex2bin
(
u8
*
dst
,
const
char
*
src
,
size_t
count
);
extern
int
__must_check
hex2bin
(
u8
*
dst
,
const
char
*
src
,
size_t
count
);
/*
/*
* General tracing related utility functions - trace_printk(),
* General tracing related utility functions - trace_printk(),
...
...
lib/hexdump.c
View file @
c6cb56fc
...
@@ -38,14 +38,21 @@ EXPORT_SYMBOL(hex_to_bin);
...
@@ -38,14 +38,21 @@ EXPORT_SYMBOL(hex_to_bin);
* @dst: binary result
* @dst: binary result
* @src: ascii hexadecimal string
* @src: ascii hexadecimal string
* @count: result length
* @count: result length
*
* Return 0 on success, -1 in case of bad input.
*/
*/
void
hex2bin
(
u8
*
dst
,
const
char
*
src
,
size_t
count
)
int
hex2bin
(
u8
*
dst
,
const
char
*
src
,
size_t
count
)
{
{
while
(
count
--
)
{
while
(
count
--
)
{
*
dst
=
hex_to_bin
(
*
src
++
)
<<
4
;
int
hi
=
hex_to_bin
(
*
src
++
);
*
dst
+=
hex_to_bin
(
*
src
++
);
int
lo
=
hex_to_bin
(
*
src
++
);
dst
++
;
if
((
hi
<
0
)
||
(
lo
<
0
))
return
-
1
;
*
dst
++
=
(
hi
<<
4
)
|
lo
;
}
}
return
0
;
}
}
EXPORT_SYMBOL
(
hex2bin
);
EXPORT_SYMBOL
(
hex2bin
);
...
...
security/keys/encrypted-keys/encrypted.c
View file @
c6cb56fc
...
@@ -667,11 +667,19 @@ static int encrypted_key_decrypt(struct encrypted_key_payload *epayload,
...
@@ -667,11 +667,19 @@ static int encrypted_key_decrypt(struct encrypted_key_payload *epayload,
return
-
EINVAL
;
return
-
EINVAL
;
hex_encoded_data
=
hex_encoded_iv
+
(
2
*
ivsize
)
+
2
;
hex_encoded_data
=
hex_encoded_iv
+
(
2
*
ivsize
)
+
2
;
hex2bin
(
epayload
->
iv
,
hex_encoded_iv
,
ivsize
);
ret
=
hex2bin
(
epayload
->
iv
,
hex_encoded_iv
,
ivsize
);
hex2bin
(
epayload
->
encrypted_data
,
hex_encoded_data
,
encrypted_datalen
);
if
(
ret
<
0
)
return
-
EINVAL
;
ret
=
hex2bin
(
epayload
->
encrypted_data
,
hex_encoded_data
,
encrypted_datalen
);
if
(
ret
<
0
)
return
-
EINVAL
;
hmac
=
epayload
->
format
+
epayload
->
datablob_len
;
hmac
=
epayload
->
format
+
epayload
->
datablob_len
;
hex2bin
(
hmac
,
hex_encoded_data
+
(
encrypted_datalen
*
2
),
HASH_SIZE
);
ret
=
hex2bin
(
hmac
,
hex_encoded_data
+
(
encrypted_datalen
*
2
),
HASH_SIZE
);
if
(
ret
<
0
)
return
-
EINVAL
;
mkey
=
request_master_key
(
epayload
,
&
master_key
,
&
master_keylen
);
mkey
=
request_master_key
(
epayload
,
&
master_key
,
&
master_keylen
);
if
(
IS_ERR
(
mkey
))
if
(
IS_ERR
(
mkey
))
...
...
security/keys/trusted.c
View file @
c6cb56fc
...
@@ -779,7 +779,10 @@ static int getoptions(char *c, struct trusted_key_payload *pay,
...
@@ -779,7 +779,10 @@ static int getoptions(char *c, struct trusted_key_payload *pay,
opt
->
pcrinfo_len
=
strlen
(
args
[
0
].
from
)
/
2
;
opt
->
pcrinfo_len
=
strlen
(
args
[
0
].
from
)
/
2
;
if
(
opt
->
pcrinfo_len
>
MAX_PCRINFO_SIZE
)
if
(
opt
->
pcrinfo_len
>
MAX_PCRINFO_SIZE
)
return
-
EINVAL
;
return
-
EINVAL
;
hex2bin
(
opt
->
pcrinfo
,
args
[
0
].
from
,
opt
->
pcrinfo_len
);
res
=
hex2bin
(
opt
->
pcrinfo
,
args
[
0
].
from
,
opt
->
pcrinfo_len
);
if
(
res
<
0
)
return
-
EINVAL
;
break
;
break
;
case
Opt_keyhandle
:
case
Opt_keyhandle
:
res
=
strict_strtoul
(
args
[
0
].
from
,
16
,
&
handle
);
res
=
strict_strtoul
(
args
[
0
].
from
,
16
,
&
handle
);
...
@@ -791,12 +794,18 @@ static int getoptions(char *c, struct trusted_key_payload *pay,
...
@@ -791,12 +794,18 @@ static int getoptions(char *c, struct trusted_key_payload *pay,
case
Opt_keyauth
:
case
Opt_keyauth
:
if
(
strlen
(
args
[
0
].
from
)
!=
2
*
SHA1_DIGEST_SIZE
)
if
(
strlen
(
args
[
0
].
from
)
!=
2
*
SHA1_DIGEST_SIZE
)
return
-
EINVAL
;
return
-
EINVAL
;
hex2bin
(
opt
->
keyauth
,
args
[
0
].
from
,
SHA1_DIGEST_SIZE
);
res
=
hex2bin
(
opt
->
keyauth
,
args
[
0
].
from
,
SHA1_DIGEST_SIZE
);
if
(
res
<
0
)
return
-
EINVAL
;
break
;
break
;
case
Opt_blobauth
:
case
Opt_blobauth
:
if
(
strlen
(
args
[
0
].
from
)
!=
2
*
SHA1_DIGEST_SIZE
)
if
(
strlen
(
args
[
0
].
from
)
!=
2
*
SHA1_DIGEST_SIZE
)
return
-
EINVAL
;
return
-
EINVAL
;
hex2bin
(
opt
->
blobauth
,
args
[
0
].
from
,
SHA1_DIGEST_SIZE
);
res
=
hex2bin
(
opt
->
blobauth
,
args
[
0
].
from
,
SHA1_DIGEST_SIZE
);
if
(
res
<
0
)
return
-
EINVAL
;
break
;
break
;
case
Opt_migratable
:
case
Opt_migratable
:
if
(
*
args
[
0
].
from
==
'0'
)
if
(
*
args
[
0
].
from
==
'0'
)
...
@@ -860,7 +869,9 @@ static int datablob_parse(char *datablob, struct trusted_key_payload *p,
...
@@ -860,7 +869,9 @@ static int datablob_parse(char *datablob, struct trusted_key_payload *p,
p
->
blob_len
=
strlen
(
c
)
/
2
;
p
->
blob_len
=
strlen
(
c
)
/
2
;
if
(
p
->
blob_len
>
MAX_BLOB_SIZE
)
if
(
p
->
blob_len
>
MAX_BLOB_SIZE
)
return
-
EINVAL
;
return
-
EINVAL
;
hex2bin
(
p
->
blob
,
c
,
p
->
blob_len
);
ret
=
hex2bin
(
p
->
blob
,
c
,
p
->
blob_len
);
if
(
ret
<
0
)
return
-
EINVAL
;
ret
=
getoptions
(
datablob
,
p
,
o
);
ret
=
getoptions
(
datablob
,
p
,
o
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
ret
;
return
ret
;
...
...
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