1
0
mirror of https://git.code.sf.net/p/linux-ima/ima-evm-utils synced 2025-04-28 14:43:37 +02:00

86 Commits

Author SHA1 Message Date
Dmitry Kasatkin
c958062023 Fix setting correct hash header
'ima_hash -a sha256' and 'sign -a sha256 --imahash' commands did set
incorrect xattr header for hash algos other than sha1.

Fix it.

Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-06-24 15:54:37 +03:00
Dmitry Kasatkin
9bc24ee556 Use defined xattr types
Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-06-24 15:54:37 +03:00
Zbigniew Jasinski
c5a2992bc8 Fix resource leak
Signed-off-by: Zbigniew Jasinski <z.jasinski@samsung.com>
2014-06-24 15:54:37 +03:00
Dmitry Kasatkin
dddef9172e make it possible to provide keyring id in hexadecimal format
Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-06-13 12:59:14 +03:00
Dmitry Kasatkin
dde9e21a4a Fix parameter name in help output
Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-05-02 18:51:15 +03:00
Dmitry Kasatkin
6ec61ab9cb Remove unused 'x' parameter
'-x' option was removed a while ago, but 'x' was not removed
from getopt_long() parameter. Remove it.

Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-05-02 18:43:45 +03:00
Dmitry Kasatkin
2b893135be Update license text with OpenSSL exception clause
Ubuntu/Debian requires to provide OpenSSL exception clause.
This patch fixes it.

Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-05-02 17:19:47 +03:00
Mimi Zohar
8feba3f462 Add support for signing a file hash
In a number of situations, the file hash has already been calculated.
Instead of reading a file to calculate the file hash, read the file hash
from stdin; and instead of writing the signature as an xattr or creating
a .sig file, output the signature as ascii-hex to stdout.

For example, piping the output of sha256sum <pathname> to evmctl would
display the original sha256 output with the file signature appended.

Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
2014-03-26 14:50:20 +02:00
Mimi Zohar
b0da7e69e0 Define symbolic keyring name
Currently evmctl supports importing keys onto a particular keyring
based on a numeric keyring identifier.  This patch adds support
for importing keys based special values as defined by keyctl.

   Thread keyring: @t (-1)
   Process keyring: @p (-2)
   Session keyring: @s (-3)
   User specific keyring: @u (-4)
   User default session keyring: @us (-5)
   Group specific keyring: @g (-6)

Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
2014-03-05 13:03:36 +02:00
Dmitry Kasatkin
c7042472e8 Limit includes in imaevm.h
Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-02-17 15:56:07 +02:00
Dmitry Kasatkin
12af148131 Rename library, header file and export it.
Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-02-17 15:56:07 +02:00
Dmitry Kasatkin
ca6b42ab17 Use --m32 and --m64 parameters also in HMAC signing code
Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-02-17 15:56:07 +02:00
Dmitry Kasatkin
5e8564d155 Provide target architecture size parameter
'--m32|--m64' parameter can be specified to label images for different
architecture size than host.

Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-02-17 15:56:07 +02:00
Dmitry Kasatkin
f3cef2c047 Provide additional debug info for hmac_misc
Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-02-17 15:56:07 +02:00
Dmitry Kasatkin
5f30ed1da6 Remove experimental module signing functionality
Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-01-24 16:04:47 +02:00
Dmitry Kasatkin
fd7e949c29 Remove x509 library parameter
Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-01-24 15:37:54 +02:00
Dmitry Kasatkin
e92cbe4756 Remove user_hash_algo
Use always hash algo from signature like kernel does.

Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-01-24 15:27:49 +02:00
Dmitry Kasatkin
86d8772653 Use EVM v2 HMAC format by default
Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-01-24 15:25:05 +02:00
Dmitry Kasatkin
317fa60467 Do use x509 by default
Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-01-24 15:20:54 +02:00
Dmitry Kasatkin
f9a3d7c378 Select signing function in single place
Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-01-24 15:01:17 +02:00
Dmitry Kasatkin
454350d294 Select verification function version in the library code
Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-01-24 14:57:16 +02:00
Dmitry Kasatkin
4578679081 Remove user_sig_type flag
Always use signature type from signature header - like kernel does.

Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-01-24 14:54:59 +02:00
Dmitry Kasatkin
ff5f07e171 Use verify_hash() for EVM verification as well
Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-01-24 14:50:09 +02:00
Dmitry Kasatkin
6aabda5b65 Move signature verification implementation to the library
Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-01-24 13:59:18 +02:00
Dmitry Kasatkin
3dc656bc6f Implement recursive IMA signing
Recursive signing is needed when doing filesystem image signing.
Using script is very slow due to multiple forking and executing.
C-based implementation provides about 7 times performance improvements.
It is very significant when doing large image signing.

Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-01-17 15:27:20 +02:00
Dmitry Kasatkin
5b852c0fbb Rename de_type to search_type
Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-01-17 15:27:20 +02:00
Dmitry Kasatkin
e4e0cabc21 Move file type checking to separate function
Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-01-17 15:27:20 +02:00
Dmitry Kasatkin
51dbb77c4f Implement recursive EVM signing
Recursive signing is needed when doing filesystem image signing.
Using script is very slow due to multiple forking and executing.
C-based implementation provides about 7 times performance improvements.
It is very significant when doing large image signing.

Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-01-17 15:27:12 +02:00
Dmitry Kasatkin
eda8a164e0 Export find() declaration for the following patches
Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-01-17 14:56:19 +02:00
Dmitry Kasatkin
6c0ebe2be6 Prevent reading of inode generation for special files in HMAC signing
Kernel API does not support at the momement reading of inode generation
number of special files, so do not do it also when do HMAC signing.

Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-01-17 14:56:19 +02:00
Dmitry Kasatkin
fd08fdeeb5 Prevent reading of inode generation for special files
Kernel API does not support at the momement reading of
generation number of special files, so do not do it.

Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-01-17 14:56:19 +02:00
Dmitry Kasatkin
05017f3e98 Use lgetxattr() instead of getxattr()
IMA/EVM extended attributes should be get for symbolic links themselves,
not to the entries pointed by them. setxattr() dereference symbolic links.
It is necessary to use lgetxattr().

Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-01-17 14:56:19 +02:00
Dmitry Kasatkin
33ff9595e5 Use lsetxattr() instead of setxattr()
IMA/EVM extended attributes should be set for symbolic links themselves,
not to the entries pointed by them. setxattr() dereference symbolic links.
It is necessary to use lsetxattr().

Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-01-17 12:47:47 +02:00
Dmitry Kasatkin
7045d70a1e Implement recursive efficient IMA fixing
Using scripts which do many forking and execution is very slow on
embedded/mobile devices. C based implementation is about 7 times faster.

Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-01-17 12:43:03 +02:00
Dmitry Kasatkin
08043fc800 IMA measurement list verification (experimental)
PCR aggregate value is reconstructed using IMA measurement list and is compared
against TPM PCR-10. It also performs signature verification if it is available in
the measurement list. ima_measurement_new.c (Mimi Zohar) was used as an example.

Example:
  evmctl ima_measurement /sys/kernel/security/ima/binary_runtime_measurements

Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-01-15 18:19:35 +02:00
Dmitry Kasatkin
afcef2b493 Define __packed
Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2013-11-12 19:27:36 +02:00
Dmitry Kasatkin
20f1837d51 Provide hexdump functions without new line
Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2013-11-12 19:20:58 +02:00
Dmitry Kasatkin
6918bfbf20 split signature verification function for passing signature as an argument
Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2013-11-12 18:35:16 +02:00
Dmitry Kasatkin
78ccd56afe License changed from LGPL to GPL as in COPYING
Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2013-09-04 16:51:44 +03:00
Dmitry Kasatkin
f1ba3e7b45 Version 0.6 release
Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2013-08-28 16:37:52 +03:00
Dmitry Kasatkin
d7d74e5648 Fix cleanup in the case of errors
Proper memory cleanup is not really necessary for command line
utility because all memory is cleaned up when it quits. But as
code does it most of the cases, fix other places.

Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2013-08-28 15:20:16 +03:00
Dmitry Kasatkin
15dab873b5 fix the crash when key file is not found
Error in error handling caused crash when key file is not found.

Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2013-08-27 15:44:18 +03:00
Dmitry Kasatkin
971b286169 make --imahash or --imasig optional for EVM signing
One might not want to change/set IMA xattr value when performing
EVM signing.

Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2013-08-13 16:55:14 +03:00
Dmitry Kasatkin
2406322914 perform uuid format checking and error handling
Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2013-08-13 16:55:14 +03:00
Dmitry Kasatkin
b3a5fcbca2 make argument for '-u' option as optional
-u required to provide uuid or '-', which was confusing.
Now -u does not require '-' argument to read uuid automatically.

Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2013-08-13 16:55:10 +03:00
Vivek Goyal
59ef0a0b99 Save full security.ima attribute to a file
Right now if -f option is passed in, we only save the actual signature to
a file and not the full security.ima attribute.

I think it makes more sense to save full security.ima attribute so that
it can act as detached signatures and one can install signature later.
That is signing can take place on build server and detached signatures
can be generated and these signatures can be installed later on target.

One can use following steps.

evmctl ima_sign -f -x -a sha256 /tmp/data.txt

hexdump -v -e '1/1 "%02x"' /tmp/data.txt.sig > /tmp/data.txt.sig.hex
printf "# file: /tmp/data.txt\nsecurity.ima=0x" | cat - /tmp/data.txt.sig.hex | setfattr --restore -

evmctl ima_verify /tmp/data.txt

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
2013-08-09 15:57:26 +03:00
Vivek Goyal
ab18c60ec1 Get signature version from the header
Currently we assume signature version is v1 until and unless -x is
specified on kernel command line. Given the fact that signature version
information is available in signature itself, it is much better to get
it from there and not require user to pass -x during verification phase.

If user passed -x on command line, then honor it.

Now one can do following.

	evmctl ima_sign -x /tmp/data.txt
	evmctl ima_verify /tmp/data.txt

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
2013-08-09 15:57:26 +03:00
Vivek Goyal
d9678295b9 Move key file selection to later phase
Following patch reads signature version from header and based
on that key file needs to be selected.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
2013-08-09 15:57:18 +03:00
Vivek Goyal
0df73005a3 Use enums for signature versions
Using enums for fixed values looks cleaner. Also I am planning to use
version field in more places in next patch. So use enums intead of
numbers like 1 and 2.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
2013-08-09 15:55:53 +03:00
Vivek Goyal
b49e2251a0 Let user specified hash algo take precedence
After applying previous patch, we will always get hash algo info from
signature and if user specified one on command line, that will be overridden.

This is like breaking old behavior. So keep track whether user specified
hash algo on command line or not. If user did not specify one then get
hash algo info from signature otherwise use the one user provided.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
2013-08-09 15:55:49 +03:00