Support PLATFORM=<platform>-<flavor>

When $(PLATFORM) contains a hyphen, parse it as
$(PLATFORM)-$(PLATFORM_FLAVOR). Then, one can use:
$ make PLATFORM=vexpress-fvp ...
instead of:
$ make PLATFORM=vexpress PLATFORM_FLAVOR=fvp ...

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
Add crypto provider internal API

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Import libcrypto source code from OpenSSL 1.0.1i

$ md5sum openssl-1.0.1i.tar.gz
c8dc151a671b9b92ff3e4c118b174972  openssl-1.0.1i.tar.gz

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
openssl: AES-XTS: allow updates with partial buffers

This commit modifies CRYPTO_xts128_encrypt() so that tweak information
is saved in the context for the next call. As a result, EVP_EncryptUpdate()
or EVP_DecryptUpdate() can be called multiple times with partial buffers.
libutils, kernel: add standard functions needed by OpenSSL

Prepare for building OpenSSL libcrypto.
1. Add the following to libutils:
- isdigit(), isspace(), isalpha(), isalnum(), isxdigit(), isupper(),
  islower(), toupper(), tolower(): basic ASCII-only implementation
- atoi(), sscanf() (stub!), strtoul(), strncmp(), strcpy(), strncpy(),
  strchr(), strcat()
2. Add abort() and time() to core/kernel.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Add support for $(lib-use-ld) and $(lib-ldflags)

When building a static library, set lib-use-ld := y to use $(LD) instead of
$(AR). Link flags may be passed in $(lib-ldflags).

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Add support for $(cflags-lib-y)

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Implement OpenSSL crypto provider (WITH_CRYPTO=openssl)

Set the WITH_CRYPTO build option to 'openssl' to use the OpenSSL libcrypto
library for cryptographic services. When WITH_CRYPTO is not set, or set to
'tomcrypt', LibTomCrypt is used.

Usage example:
  $ make CROSS_COMPILE=arm-linux-gnueabihf- \
         PLATFORM=vexpress PLATFORM_FLAVOR=fvp \
         WITH_CRYPTO=openssl

Tested with xtest (e7cda93) on Foundation_v8 (PLATFORM_FLAVOR=fvp) and QEMU
(PLATFORM_FLAVOR=qemu_virt).

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Create tee_cryp_utl.{h,c}

These files contain miscellaneous cryptographic utility functions that do not
belong to tee_svc_cryp.c.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Remove useless cflags-remove-y

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
tee_ltc_provider.c: add missing AE optimization

Fix forgotten code when rebasing, from commit:
03c4278 CCM Authentication optimization

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Crypto: replace 'x == NULL' with '!x'

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Revert OpenSSL changes that are not needed

Thanks to incremental linking and --gc-sections, a number of files do not need
to be included in the build. Therefore we can revert any changes made to these
files after commit 'Import libcrypto source code from OpenSSL 1.0.1i'.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Use cflags-lib-y instead of cppflags-lib-y in openssl/sub.mk

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Travis: add build command with OpenSSL crypto enabled

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>