100 Commits

Author SHA1 Message Date
Dmitry Kasatkin
bddbd31a15 Provide random KMK example instead of fixed testing123
Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-02-17 16:21:52 +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
ef46876b10 Include only libraries to the package
Prevent including debug stuff to the main package.

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
86a605eb10 Remove verify_hash parameter
Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-01-24 15:59:24 +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
3299fba40d Move signature version checking to verify_hash()
Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-01-24 14:48:02 +02:00
Dmitry Kasatkin
906861a308 Move hash verification to separate function
Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-01-24 14:42:22 +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
018495c87f Initial library skeleton
Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-01-17 18:43:44 +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
323d81777d Script for generating self-signed certificate
Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-01-16 13:36:18 +02:00
Dmitry Kasatkin
73f10810c0 Provide spec file for gbs build system
GBS build system requires specfile before configuring the package.

Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-01-16 13:35:22 +02:00
Dmitry Kasatkin
504e1d4013 Move spec file to packaging directory
Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2014-01-16 13:34:48 +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
092d5cc15d scripts to generate ca and keys
Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
2013-11-01 01:30:40 +02:00
Dmitry Kasatkin
78ccd56afe License changed from LGPL to GPL as in COPYING
Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
v0.6
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