1 // SPDX-License-Identifier: BSD-2-Clause 2 /* 3 * Copyright 2018-2019 NXP 4 * 5 * Brief This driver interfaces TEE Cryptographic API crypto_* 6 */ 7 #include <crypto/crypto.h> 8 #include <drvcrypt.h> 9 #include <initcall.h> 10 11 static void *crypt_algo[CRYPTO_MAX_ALGO]; 12 13 TEE_Result drvcrypt_register(enum drvcrypt_algo_id algo_id, void *ops) 14 { 15 if (!crypt_algo[algo_id]) { 16 CRYPTO_TRACE("Registering module id %d with 0x%p", algo_id, 17 ops); 18 crypt_algo[algo_id] = ops; 19 return TEE_SUCCESS; 20 } 21 22 CRYPTO_TRACE("Fail to register module id %d with 0x%p", algo_id, ops); 23 return TEE_ERROR_GENERIC; 24 } 25 26 void drvcrypt_register_change(enum drvcrypt_algo_id algo_id, void *ops) 27 { 28 CRYPTO_TRACE("Change registered module id %d with 0x%p", algo_id, ops); 29 crypt_algo[algo_id] = ops; 30 } 31 32 void *drvcrypt_get_ops(enum drvcrypt_algo_id algo_id) 33 { 34 return crypt_algo[algo_id]; 35 } 36