diff mbox

[API-NEXT,PATCHv3,3/4] linux-generic: crypto: implement crypto capabilities and random kind

Message ID 1477499966-30632-3-git-send-email-bill.fischofer@linaro.org
State New
Headers show

Commit Message

Bill Fischofer Oct. 26, 2016, 4:39 p.m. UTC
Add random kind related values to odp_crypto_capability() and implement
this selector field in odp_random_data(). Since odp-linux uses the
OpenSSL RAND_bytes() API, the highest kind of random data supported by
this implementation is ODP_RANDOM_CRYPTO.

Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>

---
 platform/linux-generic/odp_crypto.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

-- 
2.7.4
diff mbox

Patch

diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c
index c7431e6..fdd65b3 100644
--- a/platform/linux-generic/odp_crypto.c
+++ b/platform/linux-generic/odp_crypto.c
@@ -618,6 +618,8 @@  int odp_crypto_capability(odp_crypto_capability_t *capa)
 
 	capa->max_sessions = MAX_SESSIONS;
 
+	capa->max_random_kind = ODP_RANDOM_CRYPTO;
+
 	return 0;
 }
 
@@ -872,9 +874,13 @@  int odp_crypto_term_global(void)
 }
 
 int32_t
-odp_random_data(uint8_t *buf, int32_t len, odp_bool_t use_entropy ODP_UNUSED)
+odp_random_data(uint8_t *buf, int32_t len, odp_random_kind_t kind)
 {
 	int32_t rc;
+
+	if (kind > ODP_RANDOM_CRYPTO)
+		return -1;
+
 	rc = RAND_bytes(buf, len);
 	return (1 == rc) ? len /*success*/: -1 /*failure*/;
 }