platform/core/security/yaca.git
3 years agoFix segfault found by fuzzer. 63/255163/1 accepted/tizen_6.5_unified tizen_6.5 accepted/tizen/6.5/unified/20211028.114551 accepted/tizen/unified/20210318.055920 submit/tizen/20210317.121852 submit/tizen_6.5/20211028.162401 tizen_6.5.m2_release
Dariusz Michaluk [Fri, 12 Mar 2021 18:26:53 +0000 (19:26 +0100)]
Fix segfault found by fuzzer.

Unsigned int(input_len) is casted to int(flen), this can lead to using negative value,
unfortunately openssl doesn't check it.

According to openssl documentation, input_len is limited by RSA key size,
let's validate it in yaca to avoid segfault.

Change-Id: I8e821b94794f1b5d7231df16c591fe88c12c84e2

3 years agoFix coverage generation in rpm 4.14.1 88/254488/1
Tomasz Swierczek [Wed, 3 Mar 2021 13:53:20 +0000 (14:53 +0100)]
Fix coverage generation in rpm 4.14.1

Debug source package directories now have different names.

Change-Id: I73062559cf76dbecbcfaedb549e507ba9d56cc69

3 years agoAdditional OpenSSL error codes that should be handled gracefully 26/251526/2
Lukasz Pawelczyk [Thu, 24 Dec 2020 14:17:28 +0000 (15:17 +0100)]
Additional OpenSSL error codes that should be handled gracefully

Change-Id: I13e4457cecfc5faf6d5d9f65394ab72ac671cec7

3 years agoFix build with updated RPM tool 27/251227/3 accepted/tizen/unified/20210113.121022 submit/tizen/20210112.121630 submit/tizen/20210113.004724
Tomasz Swierczek [Mon, 11 Jan 2021 06:05:08 +0000 (07:05 +0100)]
Fix build with updated RPM tool

Pre-4.14 RPM tools used to compile the spec file properly when
this syntax:

(1) %if %{build_type}

was used in Requires section and this syntax:

(2) %if "%{build_type}"

was used in %files/%packages section.

In RPM 4.14 version, this doesn't compile. Similarly, removing the ""
in (2) doesn't work in pre-4.14 RPM, just like adding "" in (1).

This patch changes combination of syntax in these %if statements
that can be succesfully compiled under both: pre-4.14 and 4.14 RPM in Tizen.

Change-Id: If8bf4410623a8fc693dda169fea467283c6f4cfc

3 years agoFix spec file for python 3.9.1 upgrade 39/251239/1 accepted/tizen/unified/20210112.031145 submit/tizen/20210112.020339
Dongsun Lee [Tue, 12 Jan 2021 02:00:31 +0000 (11:00 +0900)]
Fix spec file for python 3.9.1 upgrade

Change-Id: Iceabbee8e355233b1784307cccbac576573e64cd
Signed-off-by: Dongsun Lee <ds73.lee@samsung.com>
3 years agoFix all accidentally valid padding cases in tests 95/250795/2 accepted/tizen/unified/20210111.024859 submit/tizen/20210108.104941
Krzysztof Jackiewicz [Mon, 4 Jan 2021 10:31:18 +0000 (11:31 +0100)]
Fix all accidentally valid padding cases in tests

Another occasionally failing test has been observed. The reason was
again a correctly padded buffer generated during decryption with
invalid parameters. Statistically, this may happen in more than 1 per
256 cases and is an expected behavior when different key, iv, bcm or
ciphertext is used during decryption.

Hopefully all remaining cases related to accidentally valid padding
have been fixed by adding a length check if padding was ok.

Hepler function added.

Verify by running T303 and T604 in a loop.
while true; do yaca-unit-tests -t <GROUP>/<TEST> 2>&1 | grep fatal; done

Change-Id: I90c0d1322745de6341a8df13c83f9a34f6694fbe

3 years agoFix wrong key decryption test 34/248834/1
Krzysztof Jackiewicz [Wed, 2 Dec 2020 13:55:23 +0000 (14:55 +0100)]
Fix wrong key decryption test

The test T604 fails from time to time at test_encrypt.cpp:738. The
reason is that the wrong key used for decryption can generate a properly
padded buffer with quite high probability (more than 1/256).

Fix by adding a length check in above case.

Also remove an outdated comment related to invalid decryption.

Change-Id: I22f7c837dc30c605dadd5c7ba8fa6b025f3396e0

3 years agoFix style, coding rules and overall esthetics of log formatter code 04/248704/2
Lukasz Pawelczyk [Tue, 1 Dec 2020 16:52:09 +0000 (17:52 +0100)]
Fix style, coding rules and overall esthetics of log formatter code

Change-Id: I96da85bbe6b24f37a79d76365a69707afd430752

3 years agoFix colour log formatter compatibility with boost 1.65 87/248687/1
Dariusz Michaluk [Tue, 1 Dec 2020 10:38:19 +0000 (11:38 +0100)]
Fix colour log formatter compatibility with boost 1.65

Change-Id: I855eed7f331163e0edc3dee9644e7c673b063377

3 years agoCategorize neutral tests as positive 91/248591/1
Dariusz Michaluk [Mon, 30 Nov 2020 10:16:59 +0000 (11:16 +0100)]
Categorize neutral tests as positive

Change-Id: I5fdd9344850e781a6625539cde9a350b8c932713

3 years agoAdd colour log formatter 35/248435/3
Dariusz Michaluk [Thu, 26 Nov 2020 11:18:10 +0000 (12:18 +0100)]
Add colour log formatter

Change-Id: I2f5febb66b26107e092c72cfadccf6a91ab8a976

3 years agoAdd a static library 03/247703/1
Lukasz Pawelczyk [Fri, 13 Nov 2020 14:36:58 +0000 (15:36 +0100)]
Add a static library

Change-Id: Ic8ff0e863787bbb49dbdf59a05258e1f4bc79e70

3 years agoAdd a cmake option to not build tests 02/247702/1
Lukasz Pawelczyk [Fri, 13 Nov 2020 14:36:38 +0000 (15:36 +0100)]
Add a cmake option to not build tests

Change-Id: Ifb5e887c2086df3e7e53920334e14d409ca98198

3 years agoFix typo in python 17/247417/1
Lukasz Pawelczyk [Tue, 10 Nov 2020 13:28:57 +0000 (14:28 +0100)]
Fix typo in python

Change-Id: Ia15e71dbd32e62ad74eca315dd321eb5a4f23410

3 years agoAutomate code coverage measurement 19/243019/6
Dariusz Michaluk [Wed, 2 Sep 2020 11:37:14 +0000 (13:37 +0200)]
Automate code coverage measurement

To gather unit tests coverage report:
- use COVERAGE build_type,
- instal yaca-coverage rpm,
- run yaca-coverage.sh script.

Change-Id: Ia3dd921d12e86cf0541252d9b1d224ce52a2d428

3 years agoFix errors in public api headers 75/243075/1 submit/tizen/20200903.050120
Dongsun Lee [Thu, 3 Sep 2020 03:56:32 +0000 (12:56 +0900)]
Fix errors in public api headers

Change-Id: Icd6bdf804d3df8c0e3dae5aab7b878dde5589c5f
Signed-off-by: Dongsun Lee <ds73.lee@samsung.com>
3 years agoTest for empty plain and cipher texts in simple API 71/242971/2
Lukasz Pawelczyk [Wed, 2 Sep 2020 06:29:42 +0000 (08:29 +0200)]
Test for empty plain and cipher texts in simple API

Change-Id: I71a702b8f70ba862f06e0a49f8b5868f084a7bf9

3 years agoReindent recently added files and fix file modes 93/242893/1
Lukasz Pawelczyk [Tue, 1 Sep 2020 19:05:28 +0000 (21:05 +0200)]
Reindent recently added files and fix file modes

Change-Id: Ie66b299be62061dea2f204f897ba03fafd94c4cf

3 years agoRelease 0.0.6 02/238802/3 accepted/tizen_6.0_unified_hotfix tizen_6.0_hotfix accepted/tizen/6.0/unified/20201030.115321 accepted/tizen/6.0/unified/hotfix/20201103.003114 accepted/tizen/unified/20200720.125609 submit/tizen/20200717.105954 submit/tizen_6.0/20201029.205104 submit/tizen_6.0_hotfix/20201102.192504 submit/tizen_6.0_hotfix/20201103.114804 tizen_6.0.m2_release
Tomasz Swierczek [Fri, 17 Jul 2020 09:56:58 +0000 (11:56 +0200)]
Release 0.0.6

* many small fixes uncovered during work on unit tests
* new, great unit tests that cover almost entire code of the library

Change-Id: I05c0b6c37d55942f1ab7d10dc58abc673f8097a3

3 years agoFix static analysis issue 01/238801/3
Tomasz Swierczek [Fri, 17 Jul 2020 09:35:10 +0000 (11:35 +0200)]
Fix static analysis issue

src/key.c: openssl_password_cb

according to openssl examples, password is considered a null-terminated string
(https://www.openssl.org/docs/man1.1.1/man3/SSL_CTX_set_default_passwd_cb.html)

Change-Id: I3b2fc13043e4adb7f5885d4140453297311e74f3

3 years agoUnit and system tests for YACA using OpenSSL mockup 96/232596/16
Lukasz Pawelczyk [Wed, 6 May 2020 12:35:53 +0000 (14:35 +0200)]
Unit and system tests for YACA using OpenSSL mockup

Those tests use OpenSSL mockup to test behaviour of YACA when OpenSSL
fails. This code covers remaining ~16% of YACA's code.

Change-Id: I1c22097155dc37a56c397b024abbc04a1c60faba

3 years agoOpenSSL and libc mockup infrastructure implementation 42/232442/16
Lukasz Pawelczyk [Mon, 4 May 2020 15:23:09 +0000 (17:23 +0200)]
OpenSSL and libc mockup infrastructure implementation

Most of the OpenSSL functions used in YACA now have their mockups that
the tests can control.

In every YACA src file 3 lines has been added (conditional include of
a redefine header).

In the tests one can fail a specific or nth OpenSSL function by
setting special global variables.

Functions excluded from mockup are functions returning void and few
specific functions use in initialization.

Change-Id: I815f5fecd3a3fc7427e9f5b2d443fdba18d3d2ee

3 years agoUnit and system tests for YACA 84/229084/38
Lukasz Pawelczyk [Thu, 2 Apr 2020 15:41:05 +0000 (17:41 +0200)]
Unit and system tests for YACA

Tests that aim to thoroughly test and cover YACA's code. Whole
functionality, most combinations of correct and incorrect parameters.

Those tests cover >80% of the code, leaving only error handlers from
OpenSSL errors.

Change-Id: Ieb29f7adaf1edeb30f653c43fb46a2324bdcb040

3 years agoAssert prime_len instead of error check 57/236957/2
Lukasz Pawelczyk [Tue, 23 Jun 2020 12:27:00 +0000 (14:27 +0200)]
Assert prime_len instead of error check

It's impossible now that it'll be larger than INT_MAX. No need to
check that.

Change-Id: I64bd04d13a46430cef3e969e79b60e2fb8a77e1b

3 years agoAssert instead of error check EVP_CIPHER_CTX_cipher() 56/236956/2
Lukasz Pawelczyk [Tue, 23 Jun 2020 12:23:16 +0000 (14:23 +0200)]
Assert instead of error check EVP_CIPHER_CTX_cipher()

Functions/macros like EVP_CIPHER_CTX_mode() or EVP_CIPHER_CTX_nid()
never error check for cipher inside context being NULL. If ctx is
initialized properly (EVP_CIPHER_CTX_new() + EVP_CipherInit_ex())
cipher will not be NULL. If it is it's yaca's error. So assert instead
of error check.

This error check caused problems for mocking up because the code
assumed in this place that EVP_CIPHER_CTX_cipher() can return NULL,
while in other it assumed that it cannot (inside EVP_CIPHER_CTX_mode()
which is a macro that uses EVP_CIPHER_CTX_cipher()).

Change-Id: I1775b85c0949d66e48e157ea8d602ae3c1298d82

3 years agoClarify bit_length for yaca_key_generate 55/236955/2
Lukasz Pawelczyk [Fri, 19 Jun 2020 15:32:18 +0000 (17:32 +0200)]
Clarify bit_length for yaca_key_generate

Add info about symmetric keys and fix DH prime length that has to be
>= 256 (OpenSSL requires that).

Change-Id: Ic5704d88a103a30dd5c8742a87f4e08e2f54c5f7

3 years agoClarify calling update only once with CCM 25/236725/3
Lukasz Pawelczyk [Fri, 19 Jun 2020 13:48:48 +0000 (15:48 +0200)]
Clarify calling update only once with CCM

When using BCM_CCM yaca update function can be called only once for
the plaintext or ciphertext regardless of using AAD. Clarify that in
the docs.

Change-Id: I350404dd0be10dd7c70d565e60a73497b6601de7

3 years agoClarify possible AAD length 24/236724/3
Lukasz Pawelczyk [Fri, 19 Jun 2020 13:35:07 +0000 (15:35 +0200)]
Clarify possible AAD length

Change-Id: I86f83db0c144508fbca593be27bb9c558a69a195

3 years agoDistinguish different cases with the same OpenSSL error code 23/236723/3
Lukasz Pawelczyk [Fri, 19 Jun 2020 13:25:52 +0000 (15:25 +0200)]
Distinguish different cases with the same OpenSSL error code

When importing a key with a wrong password and decrypting data with
wrong key/bcm or simply broken data OpenSSL can return exactly the
same error code (ERR_LIB_EVP, EVP_F_EVP_DECRYPTFINAL_EX,
EVP_R_BAD_DECRYPT). As we need to distinguish INVALID_PARAM and
INVALID_PASS in import_key, but decryption cannot return INVALID_PASS
handle this manually in the decryption.

Change-Id: Iba2b5fccfb1660c20b76a345bc799a0b145d700c

3 years agoPadding has to be set before update in case of decryption 22/236722/3
Lukasz Pawelczyk [Thu, 18 Jun 2020 15:53:32 +0000 (17:53 +0200)]
Padding has to be set before update in case of decryption

When doing encrypt/seal padding can be set before finalize as was
before. But it appears that decrypt behaves differently. In that case
padding has to be set before update or the decryption will be
incorrect.

Change-Id: I86ede38d0d79d401329c25c656e5c6b4c92e02cb

3 years agoHandle errors from EVP_PKEY_CTX_set_* 21/236721/2
Lukasz Pawelczyk [Wed, 17 Jun 2020 16:19:54 +0000 (18:19 +0200)]
Handle errors from EVP_PKEY_CTX_set_*

Not every error from EVP_PKEY_CTX_set_* is INTERNAL. Some should be
handled lightly like trying to set DH key with bit_len < 256.

Change-Id: I5993c8d04600ae1e5b0851d924087704c58c0f9c

3 years agoRemove unused OpenSSL RAND methods 60/233160/3
Lukasz Pawelczyk [Tue, 12 May 2020 12:57:29 +0000 (14:57 +0200)]
Remove unused OpenSSL RAND methods

According to docs we can pass NULL to the functions we don't want/need
in RAND_METHOD struct. As we don't use them, drop those unneeded.

RAND_pseudo_bytes() was deprecated in OpenSSL 1.1.0.

Change-Id: Id28795119d6efdd11664d1d81be0524d87e987cf

3 years agoRemove support for OpenSSL 1.0.x, it's EOL 43/233043/4
Lukasz Pawelczyk [Mon, 11 May 2020 16:26:16 +0000 (18:26 +0200)]
Remove support for OpenSSL 1.0.x, it's EOL

Change-Id: If860fb8c5f3ea3fc128d52860e923e0cff582cd2

3 years agoBetter error handling in encrypt_ctx_init() and encrypt_ctx_setup_iv() 36/232936/5
Lukasz Pawelczyk [Fri, 8 May 2020 08:38:43 +0000 (10:38 +0200)]
Better error handling in encrypt_ctx_init() and encrypt_ctx_setup_iv()

Some calls to encrypt_ctx_init() and encrypt_ctx_setup_iv() asserts
their return code that it cannot be EINVAL. But the OpenSSL functions
there (namely EVP_CIPHER_CTX_set_key_length() and EVP_CIPHER_CTX_ctrl)
can fail because of other reasons. Handle this properly.

Side effect of this change is that while setting wrong IVLEN for CCM
it's impossible to distinguish error codes, as OpenSSL does not set
them in most cases. Handle this internally.

Change-Id: Ib82871c8f4bf348c9ff4b90467886edcc19f6f9e

3 years agoAdd yaca's include deps to examples 19/232819/6
Lukasz Pawelczyk [Thu, 7 May 2020 11:36:35 +0000 (13:36 +0200)]
Add yaca's include deps to examples

Change-Id: I3dbaf43351efe3bec426503e5181d549415dadd3

3 years agoChange key_copy API, it's only used in one place 94/232594/7
Lukasz Pawelczyk [Wed, 6 May 2020 16:16:31 +0000 (18:16 +0200)]
Change key_copy API, it's only used in one place

Only simple keys are copied and only in one place. Simplify it to a
specialized function and put it as static where it's needed.

Change-Id: I4d83ab4b3290ad9758315045345450f7d5cf2d3b

3 years agoHandle errors properly in various key.c functions 41/232441/7
Lukasz Pawelczyk [Mon, 4 May 2020 15:16:00 +0000 (17:16 +0200)]
Handle errors properly in various key.c functions

BIO_flush()
BIO_read()
BIO_write()
BIO_reset()
EVP_aes_256_cbc()
EVP_PKEY_up_ref()

Change-Id: Id74d0710ce8a12f982d0011b83d46880fe2b6116

3 years agoClarify the code that caused many sleepless engineers 88/232288/6
Lukasz Pawelczyk [Wed, 29 Apr 2020 16:29:53 +0000 (18:29 +0200)]
Clarify the code that caused many sleepless engineers

We have to stop this madness.

Change-Id: I7407efe46ac02c0c2427966eb4bd52db180522fc

3 years agoAdd all debug functions to debug.h 56/232156/6
Lukasz Pawelczyk [Tue, 28 Apr 2020 15:33:44 +0000 (17:33 +0200)]
Add all debug functions to debug.h

Add translate_error that was not available.
Move others from internal.
Include debug.h in internal.h.

The reason for that is to make it easier to test debug functions by
only including debug.h. internal.h is not includable by C++ code.

Both those headers are internal and nothing changes in terms of public
API.

Change-Id: Ica6886c9253d45a5f131a36b457044132daee14a

3 years agoUnify errors treating from OpenSSL functions. 55/232155/6
Lukasz Pawelczyk [Tue, 28 Apr 2020 14:33:25 +0000 (16:33 +0200)]
Unify errors treating from OpenSSL functions.

Have 3 lines block almost everywhere where we call OpenSSL function
and want to handle its error code. Always ERROR_DUMP in such a case.

Also some other unification of OpenSSL returns where we don't care
about its errors (loading keys where errors are expected due to
autodetection).

Change-Id: Ie9e2f19bae099cfaddaa9c45a6de985f09b3f97b

3 years agoTreat OPEN same way as DECRYPT in case of a CipherUpdate/Final error 54/232154/7
Lukasz Pawelczyk [Tue, 28 Apr 2020 13:09:18 +0000 (15:09 +0200)]
Treat OPEN same way as DECRYPT in case of a CipherUpdate/Final error

Without this change Decrypt returned INVALID_PARAM, while Open
returned INTERNAL in the same case (e.g. wrong key).

Change-Id: I8aaf77b4a550303a68834dd0ace9fa5a52130868

3 years agoHandle keys in seal a little bit better 96/231896/8
Lukasz Pawelczyk [Fri, 24 Apr 2020 17:18:13 +0000 (19:18 +0200)]
Handle keys in seal a little bit better

Change-Id: Ibf5ed3502da10003c7489a7d1ca3e327dea0615e

3 years agoHandle unreachable code in different ways 08/231708/9
Lukasz Pawelczyk [Thu, 23 Apr 2020 13:24:52 +0000 (15:24 +0200)]
Handle unreachable code in different ways

The idea is to remove unreachable code where possible. To change it to
asserts where it makes sense. To mark it with explicit assert(false)
where unreachable code can't be removed.

There are cases where unreachable code needs to exist to silence
compiler warnings. Eg. default cases for switch. Mark them with
assert(false) so it's immediately visible that the flow should never
reach them (e.g. because the check has been performed earlier and it's
internal function).

Change-Id: I7d53c9772fe54b5c4dfd0f7205eec633fe4b9c20

3 years agoIf data_len is strange here it's OpenSSL's fault, not inputs 94/231894/7
Lukasz Pawelczyk [Fri, 24 Apr 2020 16:41:40 +0000 (18:41 +0200)]
If data_len is strange here it's OpenSSL's fault, not inputs

Change-Id: I9441cb0e3f9753ad04e59a8e6673839dbc23718f

3 years agoAdd clarification comment for key_import 93/231893/7
Lukasz Pawelczyk [Fri, 24 Apr 2020 15:58:44 +0000 (17:58 +0200)]
Add clarification comment for key_import

Change-Id: I37f43f15692c596fdfac91ef8f37bccac9bbf3c8

3 years agoRemove unreachable function 92/231892/7
Lukasz Pawelczyk [Fri, 24 Apr 2020 15:37:49 +0000 (17:37 +0200)]
Remove unreachable function

Use the default callback in its place and return 0 immediately (u ==
NULL).

Change-Id: I34e15acd52dd352197f16a1dee93df14023ac6ae

3 years agoAdd more errors to invalid parameter in error_handle 90/231890/6
Lukasz Pawelczyk [Fri, 24 Apr 2020 14:14:21 +0000 (16:14 +0200)]
Add more errors to invalid parameter in error_handle

RSA: It happens when we give wrong RSA key for asymmetric decryption.
PEM: It happens when importing broken PEM.

Change-Id: I64b39566d7b17a52bafe2b94bb84daec51edaeee

3 years agoThose functions can be static now 07/231707/5
Lukasz Pawelczyk [Thu, 23 Apr 2020 14:12:21 +0000 (16:12 +0200)]
Those functions can be static now

I suppose they were used in seal previously. They're only used
directly from encrypt.c now.

Also move some structs to encrypt.c that are not used anywhere else as
well.

Change-Id: I64fbac4c7f011fedde6fdf5b3263f253ab863802

3 years agoAdd extern C for debug.h 06/231706/5
Lukasz Pawelczyk [Thu, 23 Apr 2020 12:59:45 +0000 (14:59 +0200)]
Add extern C for debug.h

Change-Id: I9124353e1a0e5a6f4c71c23f41952aac161a0515

3 years agoFix checking input params for get_iv_length 60/231160/5
Lukasz Pawelczyk [Fri, 17 Apr 2020 15:56:25 +0000 (17:56 +0200)]
Fix checking input params for get_iv_length

Without this change it was possible to trigger an assert using top
level API.

Unify wording for key_bit_len param "divisible by 8".

Change-Id: Iba4a121c38ce3dc78a7531a1df984c014edf84da

3 years agoUse TEMP_FAILTURE_RETRY instead of checking EINTR by hand 84/230384/4
Lukasz Pawelczyk [Thu, 9 Apr 2020 15:51:15 +0000 (17:51 +0200)]
Use TEMP_FAILTURE_RETRY instead of checking EINTR by hand

Change-Id: Ic1c97915c98bfa26cc04f28adf3d3292ef157aa2

3 years agoChange the way coverage is triggered in spec 83/229683/4
Lukasz Pawelczyk [Thu, 2 Apr 2020 15:40:16 +0000 (17:40 +0200)]
Change the way coverage is triggered in spec

Use --define "build_type COVERAGE". This way I can set -O0 which is
required for reliable results. Also removed unused CMAKE variable.

Change-Id: I8a1540d0ea9966f8aa49cf6d24509dcfb5bf65bd

3 years agoFix yaca_memcmp() properly returning INVALID_PARAMETER 81/229381/4
Lukasz Pawelczyk [Tue, 31 Mar 2020 15:02:20 +0000 (17:02 +0200)]
Fix yaca_memcmp() properly returning INVALID_PARAMETER

Change-Id: I6c788d0a28b170b2dd97ee4866b4fd61dba068ca

4 years agoFix issues with deallocation of keys in example code 76/224976/1 accepted/tizen/unified/20200216.215221 submit/tizen/20200214.123128
Tomasz Swierczek [Fri, 14 Feb 2020 10:17:55 +0000 (11:17 +0100)]
Fix issues with deallocation of keys in example code

Change-Id: I317500fe8d5e6f1cde396dcd9ecfeb225bf3401b

4 years agoMake gcov package when --define 'gcov ON' is given 50/217250/1 accepted/tizen/unified/20191108.142953 submit/tizen/20191108.073429
Dongsun Lee [Fri, 8 Nov 2019 03:00:28 +0000 (12:00 +0900)]
Make gcov package when --define 'gcov ON' is given

Change-Id: I2268f6cbf22565b712a7af5038ceb6d222a06772
Signed-off-by: Dongsun Lee <ds73.lee@samsung.com>
4 years agoFix build error at python 3.7.3 aarch64 11/215811/1 accepted/tizen_5.5_unified_mobile_hotfix accepted/tizen_5.5_unified_wearable_hotfix tizen_5.5_mobile_hotfix tizen_5.5_tv tizen_5.5_wearable_hotfix accepted/tizen/5.5/unified/20191031.022057 accepted/tizen/5.5/unified/mobile/hotfix/20201027.090004 accepted/tizen/5.5/unified/wearable/hotfix/20201027.112644 accepted/tizen/unified/20191017.105741 submit/tizen/20191017.060053 submit/tizen_5.5/20191031.000004 submit/tizen_5.5_mobile_hotfix/20201026.185104 submit/tizen_5.5_wearable_hotfix/20201026.184304 tizen_5.5.m2_release
DongHun Kwak [Wed, 16 Oct 2019 06:46:43 +0000 (15:46 +0900)]
Fix build error at python 3.7.3 aarch64

Change python macro at spec file
 python3-sitelib -> python3-sitearch

Change-Id: I2158ac6151fa6cd09397ef35f630f83db743049e
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
4 years agoRelease 0.0.5 18/215718/1 accepted/tizen/unified/20191015.012036 submit/tizen/20191014.132010
Krzysztof Jackiewicz [Mon, 14 Oct 2019 12:42:10 +0000 (14:42 +0200)]
Release 0.0.5

Change-Id: If8d3f1f0bc6bb0439366600a46082e15c02d82e0

4 years agoFix memory leak reported by Coverity 91/215691/1
Krzysztof Jackiewicz [Mon, 14 Oct 2019 08:33:52 +0000 (10:33 +0200)]
Fix memory leak reported by Coverity

Change-Id: I2c9642848897fab2994ad612ef41a9703a529d11

4 years agoRelease 0.0.4 95/210395/1 accepted/tizen/unified/20190724.130059 submit/tizen/20190719.120437 submit/tizen/20190724.083537
Dariusz Michaluk [Thu, 18 Jul 2019 15:13:54 +0000 (17:13 +0200)]
Release 0.0.4

Change-Id: I93f168da700c155b3267c5a47970edbb4bf0fa63

4 years agoMigrate to openssl 1.1 79/206979/2
Konrad Lipinski [Wed, 29 May 2019 15:48:39 +0000 (17:48 +0200)]
Migrate to openssl 1.1

Change-Id: I07c36154ada7a74d59ba1e8d784309475157db33

5 years agoFix TYPO in document 84/198484/1
Dongsun Lee [Fri, 25 Jan 2019 00:25:06 +0000 (09:25 +0900)]
Fix TYPO in document

Change-Id: I9e9f5fff90b9f51151773e5d75bd7c44992d27e5
Signed-off-by: Dongsun Lee <ds73.lee@samsung.com>
5 years agoFix pycodestyle issue 77/181877/1
Lukasz Pawelczyk [Mon, 18 Jun 2018 11:41:52 +0000 (13:41 +0200)]
Fix pycodestyle issue

pycodestyle: E741 ambiguous variable name 'l'

Change-Id: Id70e425e51da8bcd10afd579080d20b2cc9c9d4c

5 years agoFix some pylint issues 39/180539/2
Lukasz Pawelczyk [Wed, 30 May 2018 12:30:56 +0000 (14:30 +0200)]
Fix some pylint issues

- not using len(seq) as a condition
- too wide wildcard import

Change-Id: I546ccc68729f2ba831dd0f73714aa234cc7254d1

6 years agoPython3 bindings for YACA 14/161314/8
Lukasz Pawelczyk [Fri, 17 Nov 2017 13:51:46 +0000 (14:51 +0100)]
Python3 bindings for YACA

Change-Id: Ia7e7bf329d6b2e87c6587481dfe5c870ef482e54

6 years agoRelease 0.0.3 56/172556/1 submit/tizen/20180315.113946
Dariusz Michaluk [Wed, 14 Mar 2018 11:22:32 +0000 (12:22 +0100)]
Release 0.0.3

Change-Id: Ibafba8ab1f73392aa7a27483c468fafb33245dca

6 years agoClarification for key_derive_dh, EC keys are also accepted 96/160696/1
Lukasz Pawelczyk [Fri, 17 Nov 2017 14:20:36 +0000 (15:20 +0100)]
Clarification for key_derive_dh, EC keys are also accepted

Change-Id: I763712bb97de47267ebd1303bc3718c573edb164

6 years agoHandle special use case of EVP_DigestSignFinal() 72/160672/1
Lukasz Pawelczyk [Fri, 17 Nov 2017 10:34:07 +0000 (11:34 +0100)]
Handle special use case of EVP_DigestSignFinal()

EVP_DigestSignFinal() does not behave the same as other OpenSSL *Final
functions in regards to its length param. Handle this use case so its
different behaviour is not propagated onto YACA.

Change-Id: Iac9338e00a39a986049d1504791ff5e409da96f1

6 years agoFix possible segfault in seal_initialize 71/160671/1
Lukasz Pawelczyk [Fri, 17 Nov 2017 10:32:26 +0000 (11:32 +0100)]
Fix possible segfault in seal_initialize

The iv is not mandatory. It depends on bcm mode and is already checked
in this function. Don't blindly write to *iv because in some cases it
might be NULL.

Change-Id: Ieddf81b77482d2aec49d1cde3291c08d702b7c43

6 years agoSome additional API usage clarifications regarding keys 70/160670/1
Lukasz Pawelczyk [Fri, 17 Nov 2017 10:31:23 +0000 (11:31 +0100)]
Some additional API usage clarifications regarding keys

Change-Id: I375ff08deedfdc4669f40dbf6a7473d216e531ed

6 years agoFix: yaca_context_get_property() implementation unconsistent with documentation 64/160164/1
Dariusz Michaluk [Tue, 14 Nov 2017 15:27:57 +0000 (16:27 +0100)]
Fix: yaca_context_get_property() implementation unconsistent with documentation

Change-Id: I5ffd12d68b2bc2764da50d7e7bc5dd1b92eb5ebb

7 years agoInstall license file 42/119842/1
Krzysztof Jackiewicz [Mon, 20 Mar 2017 08:47:05 +0000 (09:47 +0100)]
Install license file

Change-Id: I1e80b2686d46e369084d062f2b0ef3c0e9e1d76d

7 years agoRemove unused code in CMakeLists 94/113394/2
Piotr Sawicki [Tue, 7 Feb 2017 09:15:56 +0000 (10:15 +0100)]
Remove unused code in CMakeLists

Change-Id: I31210f92e62e5fce7035b4e5693c58fda8b29e5a

7 years agoApply the reviewed API documentation 91/112891/2
sangwan.kwon [Fri, 3 Feb 2017 06:33:14 +0000 (15:33 +0900)]
Apply the reviewed API documentation

Change-Id: I071343de3d70cf0bcc4b1bf10b53ea878ff3da5d
Signed-off-by: sangwan.kwon <sangwan.kwon@samsung.com>
7 years agoYACA : Make capi-base-common an optional dependency 74/99874/5
Mateusz Forc [Wed, 23 Nov 2016 12:04:57 +0000 (13:04 +0100)]
YACA : Make capi-base-common an optional dependency

Change-Id: I6cc9995fecc7a5bf9849fb4d0e2d5e2c26058fa1

7 years agoReplace spaces with tabs 98/95998/2 accepted/tizen_4.0_unified accepted/tizen_5.0_unified accepted/tizen_common accepted/tizen_ivi accepted/tizen_mobile accepted/tizen_tv accepted/tizen_wearable accepted/tizen/4.0/unified/20170816.011448 accepted/tizen/4.0/unified/20170829.020006 accepted/tizen/5.0/unified/20181102.020909 accepted/tizen/common/20161108.131525 accepted/tizen/ivi/20161108.001450 accepted/tizen/mobile/20161108.001352 accepted/tizen/tv/20161108.001407 accepted/tizen/unified/20170309.033544 accepted/tizen/wearable/20161108.001429 submit/tizen/20161107.233654 submit/tizen_4.0/20170811.094300 submit/tizen_4.0/20170828.100004 submit/tizen_4.0/20170828.110004 submit/tizen_5.0/20181101.000004 submit/tizen_unified/20170308.100409 tizen_4.0.IoT.p1_release tizen_4.0.IoT.p2_release tizen_4.0.m1_release tizen_4.0.m2_release
Krzysztof Jackiewicz [Mon, 7 Nov 2016 08:21:36 +0000 (09:21 +0100)]
Replace spaces with tabs

Tab policy [IDT_M_TAB] have changed from optional to mandatory and whole code
has to be adjusted.
doc/coding_rules.txt updated.
File access rights fixed

Change-Id: I7b855be9560e9b4f134294a1f97a70a50af578c1

7 years agoRelease 0.0.2 21/92721/1
Dariusz Michaluk [Tue, 18 Oct 2016 07:24:32 +0000 (09:24 +0200)]
Release 0.0.2

Change-Id: I62a0ff6fff1b3a3b4cdfa611c59a310555b9e001

7 years agoRemove outdated TODO's 00/91800/1
Dariusz Michaluk [Tue, 11 Oct 2016 11:02:21 +0000 (13:02 +0200)]
Remove outdated TODO's

Change-Id: I2a0d00923ffa4f105461a7ee2bc6bb025c6bdb82

7 years agoInclude examples in documentation. 73/91073/2
Dariusz Michaluk [Wed, 5 Oct 2016 12:37:49 +0000 (14:37 +0200)]
Include examples in documentation.

Change-Id: Ifeb8ae0e322eae37bc9642dbc166c3ee68c694cc

7 years agoSimplify and unify examples. 74/90874/6
Dariusz Michaluk [Mon, 3 Oct 2016 16:04:57 +0000 (18:04 +0200)]
Simplify and unify examples.

Change-Id: I6f6f7997c3c04af686b4ec0202cde3027d630e9f

7 years agoProperly address function arguments in documentation 01/89401/8
Dariusz Michaluk [Fri, 23 Sep 2016 09:40:43 +0000 (11:40 +0200)]
Properly address function arguments in documentation

Change-Id: Icb8e9928cf38b88b1697f3c676007a2fa117e354

7 years agoReplace EVP_CIPHER_CTX_type() with EVP_CIPHER_CTX_nid(). 45/89145/8
Dariusz Michaluk [Thu, 22 Sep 2016 11:25:57 +0000 (13:25 +0200)]
Replace EVP_CIPHER_CTX_type() with EVP_CIPHER_CTX_nid().

Both functions returns NID, so always use only one of them.

Change-Id: I8471b45b7b26af0f7c29f86a4fe29f10eec57b60

7 years agoFix minor sign API errors. Fix documentation. 99/88199/9
Dariusz Michaluk [Wed, 14 Sep 2016 11:11:38 +0000 (13:11 +0200)]
Fix minor sign API errors. Fix documentation.

OpenSSL errors:
 - dsa routines:PKEY_DSA_CTRL:invalid digest type
 - elliptic curve routines:PKEY_EC_CTRL:invalid digest type
 - rsa routines:RSA_sign:digest too big for rsa key
 - rsa routines:CHECK_PADDING_MD:invalid x931 digest
 - rsa routines:PKEY_RSA_SIGN:key size too small

Change-Id: I87a51e39168885600a4ab68b754bea650411a903

7 years agoDon't check *digest_len in yaca_digest_finalize() 43/90143/3
Krzysztof Jackiewicz [Wed, 28 Sep 2016 12:31:35 +0000 (14:31 +0200)]
Don't check *digest_len in yaca_digest_finalize()

It's an [out] argument and value pointed by it shouldn't be checked.

Change-Id: I15e9b7c1e5e7e3de5cbaa4a4492b41b3929a0f28

7 years agoIncrease minimal RSA keysize from 256 to 512 bits 03/89003/4
Dariusz Michaluk [Wed, 21 Sep 2016 09:40:19 +0000 (11:40 +0200)]
Increase minimal RSA keysize from 256 to 512 bits

Change-Id: I87fd19881867c560ae8684341e182fe85f14304f

7 years agoHandle sign/digest API call order 00/88200/6
Dariusz Michaluk [Wed, 14 Sep 2016 11:16:32 +0000 (13:16 +0200)]
Handle sign/digest API call order

Change-Id: Idf64e1b9c3d6dbbe319dbce54786407c941db90a

7 years agoFix: ECB and CBC with padding always needs yaca_decrypt_update() 32/88232/4
Dariusz Michaluk [Thu, 15 Sep 2016 09:09:46 +0000 (11:09 +0200)]
Fix: ECB and CBC with padding always needs yaca_decrypt_update()

In case of empty message encryption we can skip yaca_encrypt_update(),
then yaca_encrypt_finalize() returns encrypted block at the output.
During decryption, we can't skip yaca_decrypt_update().

Change-Id: Ib4a5d06f03560ea8b26f6bec674721a62fe1f72b

7 years agoFix TYPO for removing warning during doxygen generation 40/89240/1 accepted/tizen/3.0/ivi/20161011.070302 accepted/tizen/3.0/mobile/20161015.034257 accepted/tizen/3.0/tv/20161016.005901 accepted/tizen/3.0/wearable/20161015.084629 accepted/tizen/common/20160926.154101 accepted/tizen/ivi/20160927.020858 accepted/tizen/mobile/20160927.020840 accepted/tizen/tv/20160927.020646 accepted/tizen/wearable/20160927.020823 submit/tizen/20160926.005548 submit/tizen_3.0_common/20161104.104000 submit/tizen_3.0_ivi/20161010.000008 submit/tizen_3.0_mobile/20161015.000007 submit/tizen_3.0_tv/20161015.000006 submit/tizen_3.0_wearable/20161015.000007
Dongsun Lee [Fri, 23 Sep 2016 01:12:47 +0000 (10:12 +0900)]
Fix TYPO for removing warning during doxygen generation

Change-Id: I1a971b00b321a56e6ea59d03f3c51056494f16ab
Signed-off-by: Dongsun Lee <ds73.lee@samsung.com>
7 years agoRemove get_sign_property() functionality 93/88093/2
Dariusz Michaluk [Tue, 13 Sep 2016 08:14:31 +0000 (10:14 +0200)]
Remove get_sign_property() functionality

Change-Id: Iadecd8f919eff7a3aa6efe6f4cdc096b5539ace5

7 years agoDescribe padding usage for sign/verify operations 14/88114/2
Lukasz Pawelczyk [Tue, 13 Sep 2016 11:03:16 +0000 (13:03 +0200)]
Describe padding usage for sign/verify operations

Change-Id: I4efa09f2a57c7fcd5f81124fc57bcbf890b484d4

7 years agoRevert "Fix svace defects" 65/87865/2
Kyungwook Tak [Mon, 12 Sep 2016 01:30:53 +0000 (10:30 +0900)]
Revert "Fix svace defects"

This reverts commit 60428c2b10ccec13afe901d21b87ac949ffafa4c.

2 Svace defects (141053, 142079) is handled as `won't fix`, defended by
assert() checking and logically

Change-Id: I4d29b8e0c430929a57767293ec9c0d442e2f44e4
Signed-off-by: Kyungwook Tak <k.tak@samsung.com>
7 years agoGCM and CCM fixes. 57/86757/7
Dariusz Michaluk [Fri, 2 Sep 2016 13:58:07 +0000 (15:58 +0200)]
GCM and CCM fixes.

Change-Id: I0ddb50041c871bac78f44f34844df2259618a01f

7 years agoFix OpenSSL 1.1 issues 72/87372/3
Krzysztof Jackiewicz [Wed, 7 Sep 2016 14:21:18 +0000 (16:21 +0200)]
Fix OpenSSL 1.1 issues

- 3DES CFB1 implementation is fixed but function that checks buffer overlapping
  ignores the input data length unit resulting in an error. It's impossible to
  create a code that works with both version so #if was used.
- OpenSSL 1.1's EVP_CIPHER_CTX_flags() gets flags from EVP_CIPHER instead of
  EVP_CIPHER_CTX. Call replaced with EVP_CIPHER_CTX_test_flags().

Change-Id: Ic43fd9e02b982bc767259ad3a818314a6e319eb7

7 years agoAdapt YACA to work with OpenSSL 1.1 preserving 1.0 compatibility 65/86965/9
Lukasz Pawelczyk [Mon, 5 Sep 2016 16:50:36 +0000 (18:50 +0200)]
Adapt YACA to work with OpenSSL 1.1 preserving 1.0 compatibility

Change-Id: I27e199659666d2d87b17fcb9882b0e70f751c628

7 years agoUse getrandom(2) for CSPRNG instead of OpenSSL's one 03/85703/8
Lukasz Pawelczyk [Fri, 26 Aug 2016 14:29:26 +0000 (16:29 +0200)]
Use getrandom(2) for CSPRNG instead of OpenSSL's one

In case the getrandom syscall is not available use /dev/urandom directly.

Change-Id: Id1f6889fcb0db0fdd8fefbe13f4fd72c0a8fd5b9

7 years agoFix svace defects 29/87229/1
Kyungwook Tak [Wed, 7 Sep 2016 05:56:45 +0000 (14:56 +0900)]
Fix svace defects

using assert() to check null is good for development
but if it is used partly (using both of assert() and if condition)
SVACE system detects it as defect because to checking it by if condition
means there is probability that it could be null.
So we should choose only one of them(To use assert() or if condition) on
entire of code.

Change-Id: I0da13027c650e11f88f5b06fa35d8f86d43ee879
Signed-off-by: Kyungwook Tak <k.tak@samsung.com>
7 years agoUse proper input length in encryption examples 03/86303/1 accepted/tizen/common/20160901.143419 accepted/tizen/ivi/20160901.065526 accepted/tizen/mobile/20160901.065440 accepted/tizen/tv/20160901.065447 accepted/tizen/wearable/20160901.065507 submit/tizen/20160901.024233
Krzysztof Jackiewicz [Wed, 31 Aug 2016 11:11:43 +0000 (13:11 +0200)]
Use proper input length in encryption examples

Change-Id: I0a20faf41bf2b5e7670baf6100742f851b3420ff

7 years agoConvert yaca_padding_e to value acceptable by OpenSSL 67/86267/1
Krzysztof Jackiewicz [Wed, 31 Aug 2016 09:21:43 +0000 (11:21 +0200)]
Convert yaca_padding_e to value acceptable by OpenSSL

Change-Id: I771de0745f9779c6058199e7edc0edc858dd6d3c

7 years agoFix coding style. 17/86117/3
Dariusz Michaluk [Tue, 30 Aug 2016 13:56:45 +0000 (15:56 +0200)]
Fix coding style.

Change-Id: I7e40fdd1b08c7d73c607971d87565d4c6d122842

7 years agoFix yaca_key_import() memory leak. 52/86052/3
Dariusz Michaluk [Tue, 30 Aug 2016 08:45:21 +0000 (10:45 +0200)]
Fix yaca_key_import() memory leak.

Change-Id: Iec2ee8d01922e0e4b63fc6963071de3eff0b6979

7 years agoAllow 1B longer input in PKCS1 padding 25/86125/3
Krzysztof Jackiewicz [Tue, 30 Aug 2016 14:15:45 +0000 (16:15 +0200)]
Allow 1B longer input in PKCS1 padding

OpenSSL documentation states that for PKCS1 padding the length of encrypted
input must be less than RSA_size(rsa) - 11. In fact the code itself allows less
or equal input length. Also this is what PKCS #1 standard says.

Change-Id: Iab7c7e4b3c3c3c64854f9c9ec67f18f2d7c0b01c