summaryrefslogtreecommitdiff
path: root/include/interface
diff options
context:
space:
mode:
authorJi Luo <ji.luo@nxp.com>2018-10-29 10:33:45 +0800
committerNitin Garg <nitin.garg@nxp.com>2018-11-02 20:50:08 -0500
commitced616aa4adcde2b4712ff8070cd0f6df9e7bdb5 (patch)
tree3be77fd6c24bebbb88b85a941cccb88b53beb4ce /include/interface
parent6a2f2e4e07bce45f6244ba1b78731d423dc31440 (diff)
MA-13233 [trusty] Add service 'hwcrypto'
Add new service 'hwcrypto' to handle CAAM related work with Trusty OS. Add tipc interface to accelerate hash calculation with CAAM. Test: Service connect and message exchange with Trusty OS are ok. Change-Id: Ia870c3ad2ff30af987f327a9777a8b32f53593db Signed-off-by: Ji Luo <ji.luo@nxp.com>
Diffstat (limited to 'include/interface')
-rw-r--r--include/interface/hwcrypto/hwcrypto.h87
1 files changed, 87 insertions, 0 deletions
diff --git a/include/interface/hwcrypto/hwcrypto.h b/include/interface/hwcrypto/hwcrypto.h
new file mode 100644
index 0000000000..116bfe079f
--- /dev/null
+++ b/include/interface/hwcrypto/hwcrypto.h
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * Copyright NXP 2018
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#ifndef TRUSTY_INTERFACE_HWCRYPTO_H_
+#define TRUSTY_INTERFACE_HWCRYPTO_H_
+
+#include <trusty/sysdeps.h>
+
+#define HWCRYPTO_PORT "com.android.trusty.hwcrypto"
+#define HWCRYPTO_MAX_BUFFER_LENGTH 2048
+
+enum hwcrypto_command {
+ HWCRYPTO_REQ_SHIFT = 1,
+ HWCRYPTO_RESP_BIT = 1,
+
+ HWCRYPTO_HASH = (1 << HWCRYPTO_REQ_SHIFT),
+};
+
+/**
+ * enum hwcrypto_error - error codes for HWCRYPTO protocol
+ * @HWCRYPTO_ERROR_NONE: All OK
+ * @HWCRYPTO_ERROR_INVALID: Invalid input
+ * @HWCRYPTO_ERROR_INTERNAL: Error occurred during an operation in Trusty
+ */
+enum hwcrypto_error {
+ HWCRYPTO_ERROR_NONE = 0,
+ HWCRYPTO_ERROR_INVALID = 1,
+ HWCRYPTO_ERROR_INTERNAL = 2,
+};
+
+enum hwcrypto_hash_algo {
+ SHA1 = 0,
+ SHA256
+};
+/**
+ * hwcrypto_message - Serial header for communicating with hwcrypto server
+ * @cmd: the command. Payload must be a serialized buffer of the
+ * corresponding request object.
+ * @result: resulting error code for message, one of hwcrypto_error.
+ * @payload: start of the serialized command specific payload
+ */
+struct hwcrypto_message {
+ uint32_t cmd;
+ uint32_t result;
+ uint8_t payload[0];
+};
+
+/**
+ * hwcrypto_hash_msg - Serial header for communicating with hwcrypto server
+ * @in_addr: start address of the input buf.
+ * @in_len: size of the input buf.
+ * @out_addr: start addrss of the output buf.
+ * @out_len: size of the output buf.
+ * @algo: hash algorithm expect to use.
+ */
+typedef struct hwcrypto_hash_msg {
+ uint32_t in_addr;
+ uint32_t in_len;
+ uint32_t out_addr;
+ uint32_t out_len;
+ enum hwcrypto_hash_algo algo;
+} hwcrypto_hash_msg;
+
+#endif /* TRUSTY_INTERFACE_HWCRYPTO_H_ */