summaryrefslogtreecommitdiff
path: root/src/manager
AgeCommit message (Collapse)AuthorFilesLines
2019-05-20Forbid HashAlgorithm::NONE for DSA & ECDSA signaturesKrzysztof Jackiewicz2-1/+13
Openssl uses SHA1 if no hash algorithm is provided for DSA & ECDSA signatures. TZ does not support that option at all. It's better to forbid it. This commit changes the API behavior and may lead to errors in clients that used HashAlgorithm::NONE with DSA or ECDSA which is highly unlikely. Change-Id: I8522e8f157b5ef2d6599bb672ef790ee8ea48644
2019-05-20Setup verification algorithm if not providedKrzysztof Jackiewicz1-1/+1
Verification API has no knowledge about the algorithm type. It has to be derived from the key type. Change-Id: I2e0d094372e4bf8c28275544204e431c4023e391
2019-05-20Be prepared for no data from TAKrzysztof Jackiewicz1-8/+18
Deserialization may return an empty buffer with no error. Adjust code to handle that case. Change-Id: Ife80b4d35914eda700798e0515812b3b638e735e
2019-05-20tz-backend: Implement asymmetric operationsLukasz Kostyra8-94/+753
Change-Id: Ie98b4e72addb257c2a8de1de57097fe077fff380
2019-05-20tz-backend: Add serialization wrapperKrzysztof Jackiewicz3-179/+352
Change-Id: I304452444887de48d808a6aa11eb42a1de385bf0
2019-05-20decider: Allow multiple policies for more complex logicLukasz Kostyra6-69/+81
When generating asymmetric keys, ckm-logic selected less restrictive policy out of two provided and selected key store this way. Now, both policies are supplied to Decider, which will allow for more complex backend selection logic. Change-Id: Id2b845326cae7bbf5d90bb575645c8af36c20d0f
2019-05-17Get rid of misleading SCHEMA_INFO errorKrzysztof Jackiewicz2-39/+31
During startup the key-manager attempts to read a table SCHEMA_INFO to get the information about the database version. In older versions of the database that table is missing. Key-manager properly handles that case but produces 3 lines of error log which may suggest that something went wrong. This commit checks the existence of the table before attempting to use it. Whole operation is enclosed in a transaction. Change-Id: Ie7f1fbe1182c2add5965f8e5ddada262ffcb42fe
2019-05-15Merge "Increase backlog for listening sockets" into tizenKrzysztof Jackiewicz1-1/+1
2019-05-14Increase backlog for listening socketsDariusz Michaluk1-1/+1
When systemd's socket activaction is utilized, the default backlog parameter passed to the listen() function is set to SOMAXCONN, which is equal to 128. In distributions where systemd is not used for socket activation, the default UNIX socket implementation sets the backlog value to 5. This may lead to rare overflow of an internal connection queue. This manifests itself as the -EAGAIN error returned by connect(). To mitigate the issue, the backlog parameter has been set to SOMAXCONN, which is a default value used by systemd. Change-Id: I906cd4de478b0dac0eaf860550fccd2f9cd6e184
2019-05-13Fix file name in file headerTomasz Swierczek1-2/+2
Change-Id: I3e087729762d16b84327863317643387c304ef88
2019-05-08Fix svace defectsKonrad Lipinski1-16/+18
va_start / va_end must be called in the same function Change-Id: I5176fc2686a62eb0a21e6eb9a5f737dbc3880056
2019-03-27Check fs errors before saving the fileKrzysztof Jackiewicz1-3/+10
GetFd(os) on a non-existing file causes segfault. Change-Id: I8365dfbddace160ae99b1e7d1f6070ee1032f6cd
2019-03-13Change contact information to Mr Dongsun LeeTomasz Swierczek11-22/+22
bj.im@samsung.com is no longer a valid email address. Change-Id: I81103542e0d23e80a71d5f1e86cc263f92ab78b0
2019-03-11Replace time(NULL) with monotonic clock usageTomasz Swierczek1-5/+15
Calculating timeout for socket connections should use monotonic clock. Change-Id: If9c3d573b70d1faa1cf46b9215048a5853abbaaa
2019-03-01Fix memory leak/corruptionDariusz Michaluk1-12/+13
Change-Id: I8f9bed07752fde26f629cca6931231dab5fd8980
2019-02-26Add API for CKM return code descriptionsTomasz Swierczek2-0/+67
In rare case when DB tool was used for db inspection, and db could not be opened, the commandline interface returned raw error code, without any explanation. Change-Id: If7a29842ae5a7fc2e99a2d991545539704647f3c
2019-02-22CKMC API: Add option to list aliases with information about password protectionErnest Borowski3-7/+177
Change-Id: I02ff75a9f6c60bdcd4b3450a135a4047bbbc05f0 Signed-off-by: Ernest Borowski <e.borowski@partner.samsung.com>
2019-02-22Add option to list aliases with password protection statusesErnest Borowski9-18/+268
Change-Id: I045174602edd51dc7efcc8d79eb1beed76215b10 Signed-off-by: Ernest Borowski <e.borowski@partner.samsung.com>
2019-02-22replace strcpy with strncpy for fixing SVACE(WGID=411075,411076)submit/tizen/20190222.041951accepted/tizen/unified/20190222.134051Dongsun Lee1-2/+2
Change-Id: I26207f412d5aeee68f6c90131d6c62978233c5f5 Signed-off-by: Dongsun Lee <ds73.lee@samsung.com>
2019-02-19Refactor PKEK2 related functionsKrzysztof Jackiewicz2-11/+12
PKEK2 is used to derive both DB DEK and APP DEK. Currently, variable names and comments are a bit misleading. This commit refactors the variable names and comments to better describe the actual purpose of this key. Change-Id: If8ee266ec2da63c929f498f1ed009df5d79c134f
2019-02-19Add a common function for zeroing sensitive dataKrzysztof Jackiewicz4-8/+46
Encryption keys and passwords are sensitive data and as such should be cleared when no longer used to prevent memory attacks. According to the "as-if" rule, the compiler is allowed to perform any changes to the program as long as the observable behavior of the program is not changed. Since the contents of unused memory are not considered an observable behavior the compiler is allowed to optimize out the call to memset(). The following solutions were considered: - Reading the memory after overwriting it with memset(). Since reading the memory has no observable effects it's perfectly legal for the compiler to remove both operations. - Using volatile asembly code to prevent optimization. It may prevent some compilers from optimizing but there's no guarantee. - Using volatile funtion pointer to memset. Apparently, it can be optimized as well during LTO. - Using memcpy_s(). The function is not widely available yet. It may be missing so we still need a fallback solution. - Locally disabling optimization with #pragma GCC optimize("O0"). It's GCC specific and it's not clear whether GCC will try to optimize it with "O0". Empirical test showed that memset() call is not removed. This commit applies the last solution adding a new unoptimized wrapper for memset(). Note that this commit will not prevent the processor from creating another copy of the sensitive data in registers, on the stack, in swap or in cache memory. It will only limit the number of places in memory where the secret data can be found. Change-Id: I80fe8ce8ce3d808b423858254d6fd23f491d2674
2019-02-13Free the context in case of openssl failureKrzysztof Jackiewicz1-20/+19
Change-Id: Ia2e387f70a50b090641f6bf6fb509d7d54dfdd8f
2019-02-13Add helpers for domain KEK encryption/decryptionKrzysztof Jackiewicz2-118/+73
Change-Id: I048649f8a9a3450f6cefcbd9d2d75c8445f46277
2019-02-13Add helper randomization function in key-provider.cppKrzysztof Jackiewicz1-5/+12
Change-Id: I657ac68ce8e9253ca63187132eef3fb769d8426a
2019-02-13Make encrypt/decrypt local functions of key-provider.cppKrzysztof Jackiewicz2-96/+80
Change-Id: I0dfceda850c69b09a92d26254642357838ea7cb5
2019-02-13Use common function for PKEK1&2 generationKrzysztof Jackiewicz2-156/+70
Change-Id: Ic9c6286b3672836c2bde976adb1b79ba34793918
2019-02-13Validate encrypted DKEKKrzysztof Jackiewicz2-26/+31
- Make sure that the length of the encrypted DKEK received in WrapperKeyAndInfoContainer() does not exceed the size of the key buffer. - Check client id NULL termination. - Get rid of unnecessary dynamic allocations. - Update tests. Change-Id: I9f5b494a8ea3d0d8f438a50bb49b55d57d1a3e67
2018-12-03Fix SVACE and C++ issuesKrzysztof Jackiewicz5-5/+12
Change-Id: Idfed338ad6f632556585e5749817bb882cbe0251
2018-10-19Remove "secret" key for software backendBartlomiej Grzelewski4-277/+0
This key was used by example software implementation of encrypted initial-values feature which has been replaced by hardware backed implementation. Change-Id: Id8358a70459fb6ddd8ebb43fc8e987dc4d586f63
2018-10-12Some TZ backend fixes.r.tyminski3-6/+8
- pass TEEC_Context by reference, not by value. - print return origin from TEEC_InvokeCommand Change-Id: Ib26415d0dfb454540c0f0b85d2dc50466f63ae14
2018-10-08Add RO location for initial valuesKrzysztof Jackiewicz1-6/+24
RO location will be processed before RW if a flag file is present. After import the flag will be removed but xml files will be left untouched. Change-Id: Id11c982ee4a055871e4af6841c23a11cbf139239
2018-10-08Overwrite existing initial valuesKrzysztof Jackiewicz1-0/+3
Delete any existing values of given name before saving new one. Change-Id: I4cf23efad7cff6ef453f1ed7e4bfcda76d2fdc69
2018-10-04Support for encrypted initial-valuesBartlomiej Grzelewski15-34/+105
Add tag attribute in xml schema Change-Id: Idc058e756ab6053103e1477292cacbacf57a9879
2018-10-03Reduce number of import methods in tz-backendBartlomiej Grzelewski5-177/+90
Change-Id: I44fe9737dd34d8b61d2ab099c3f611903a5cc9a1
2018-10-03Unification of import methods in gstoreBartlomiej Grzelewski12-55/+44
Change-Id: I31dca502533360b759d6aea20e75a9e823eccc34
2018-10-03Add parser support of new schema versionBartlomiej Grzelewski11-91/+64
Version 1 of xml with initial values is not supported from now. From now software backend will not support encrypted data. Allow parser to accept xml version 2. Initial values files will contain information about type of backend that should be used to store data. Change-Id: Ib3a73b14148a2476ab288ca364fffe9289400ebd
2018-09-26Introduce Key class in tz backendKrzysztof Jackiewicz2-10/+19
Add an intermediate Key class that removes the need to keep credentials from binary data object (BData). Change-Id: I638de81aedf47bc51421a7c362459ced801fd650
2018-09-26Add support for TrustZone backend data storageTomasz Swierczek6-13/+367
Change-Id: Idfd0909d03e40b7e5cd5aeb1116b844be1901cf1
2018-09-26Simplify key related functions in tz-backendKrzysztof Jackiewicz3-22/+12
- Use proper parameter for tag length - Move default param values to TrustZoneContext where possible - Remove unnecessary arguments Change-Id: I00f8909ede4f80b77a937b52a5bce5698d4516a5
2018-08-28Add log for invalid system service owner idKrzysztof Jackiewicz1-1/+3
System services (uid < 5000) should always use "/System" owner id. Eiter by explicitly adding it to the alias or by running with "System" label. Add log to make the reason of the failure more apparent. Change-Id: I1be9861eadcae6eadd6d682b4cc66972c93d1728
2018-08-28Unify alias namingKrzysztof Jackiewicz40-596/+612
Get rid of all references to smack labels except database scheme. alias = owner_id + name Simplify db permissions processing Change-Id: I36c3dbb3ee605fb00e5e4e6bcbada6400a0cbcab
2018-08-16Add protection against memory leaking during deserializationTomasz Swierczek1-25/+35
Change-Id: I1fbcd7daf1674dd1ad6b9eaffdba76263bda370b
2018-08-16Add Apache 2.0 license headersPawel Kowalski3-0/+48
Change-Id: Ia61efbc57ce93ed3714dafe9edada7cb244c54d3
2018-08-06Test version of ckm_db_mergeBartlomiej Grzelewski1-3/+3
ckm_db_merge allows to read database and copy it's contents to other one. ckm_db_merge supports db since versions 0.1.14. Please note: both databases will be automatically migrated to the newest schema. Change-Id: I5cec9dfdc2ab75a2ccd5156b0bb05cb46d134480
2018-05-08Fix coverity defectsubmit/tizen/20180508.050430accepted/tizen/unified/20180508.134803Dongsun Lee1-3/+8
- 120541 : improper use of nagative value Change-Id: Ic93d890a08def810a8f09ed6bbb8171e440438df Signed-off-by: Dongsun Lee <ds73.lee@samsung.com>
2018-04-19Disable default build with tz-backendsubmit/tizen/20180502.043224submit/tizen/20180430.063346submit/tizen/20180419.050559accepted/tizen/unified/20180502.111600Tomasz Swierczek1-2/+14
Migration to VD causes build breaks because of missing optee dependency. Relation between key-manager and key-manager-ta needs to be re-worked. For now it will be disabled. Change-Id: I5312db283e3514d7c54dfa7caffd6738b5568e2f
2018-03-30Fix coverity defectssubmit/tizen/20180418.034402submit/tizen/20180416.041718submit/tizen/20180413.092019submit/tizen/20180403.094824Dongsun Lee3-4/+12
- 105284: Buffer not null terminated - 108955: Big parameter passed by value - 109815: Uncaught exception Change-Id: I303a652d6ae0540f7d6daa833a30ef0fb691ffb8 Signed-off-by: Dongsun Lee <ds73.lee@samsung.com>
2018-03-12Properly detect the presence of TAKrzysztof Jackiewicz1-23/+10
Tef-simulator and optee use different TA file name formats. Key-manager was detecting the presence of TA by checking the existence of TA file with hardcoded format. It worked with tef-simulator but it failed to detect the TA presence in case of optee. This commit replaces the TA file presence checking with an attempt to open a session using libteec. If an attempt succeeds the decider selects TZ backend. Otherwise, it falls back to SW backend. Change-Id: I840d6b58a1ffa39885a4b8ded0ff70f4147c3de0
2018-03-07Remove redundant libcrypto dependencyDariusz Michaluk1-1/+0
openssl pkg-config requires libcrypto and libssl Change-Id: I222e458a26e0dc15d82654d35fdccc126411000f
2018-03-07Updated documentation headers - typos fixsubmit/tizen/20180308.062734Tomasz Swierczek1-1/+1
Change-Id: I8ad994a7164f6d85573030e0aeb340c1f0e50d14