aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kocialkowski <contact@paulk.fr>2014-08-04 22:58:43 +0200
committerPaul Kocialkowski <contact@paulk.fr>2014-08-04 22:58:43 +0200
commit6f0dca4789a86efba377b34a7c780c68cf74671b (patch)
tree5f3d8fa59b405e69a583e44800c384e419629f9b
parent43f51e0121943699249af19b809ed8e3e812e4e3 (diff)
downloadexternal_libsamsung-ipc-6f0dca4789a86efba377b34a7c780c68cf74671b.zip
external_libsamsung-ipc-6f0dca4789a86efba377b34a7c780c68cf74671b.tar.gz
external_libsamsung-ipc-6f0dca4789a86efba377b34a7c780c68cf74671b.tar.bz2
sec: RSIM access extract helper
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
-rw-r--r--include/sec.h2
-rw-r--r--samsung-ipc/sec.c31
2 files changed, 33 insertions, 0 deletions
diff --git a/include/sec.h b/include/sec.h
index 882b586..c7c7000 100644
--- a/include/sec.h
+++ b/include/sec.h
@@ -177,6 +177,8 @@ size_t ipc_sec_rsim_access_size_setup(struct ipc_sec_rsim_access_request_header
const void *sim_io_data, size_t sim_io_size);
void *ipc_sec_rsim_access_setup(struct ipc_sec_rsim_access_request_header *header,
const void *sim_io_data, size_t sim_io_size);
+size_t ipc_sec_rsim_access_size_extract(const void *data, size_t size);
+void *ipc_sec_rsim_access_extract(const void *data, size_t size);
int ipc_sec_lock_infomation_setup(struct ipc_sec_lock_infomation_request_data *data,
unsigned char type);
diff --git a/samsung-ipc/sec.c b/samsung-ipc/sec.c
index 8ec633f..9919592 100644
--- a/samsung-ipc/sec.c
+++ b/samsung-ipc/sec.c
@@ -168,6 +168,37 @@ void *ipc_sec_rsim_access_setup(struct ipc_sec_rsim_access_request_header *heade
return data;
}
+size_t ipc_sec_rsim_access_size_extract(const void *data, size_t size)
+{
+ struct ipc_sec_rsim_access_response_header *header;
+
+ if (data == NULL || size < sizeof(struct ipc_sec_rsim_access_response_header))
+ return 0;
+
+ header = (struct ipc_sec_rsim_access_response_header *) data;
+ if (header->length == 0 || header->length > size - sizeof(struct ipc_sec_rsim_access_response_header))
+ return 0;
+
+ return (size_t) header->length;
+}
+
+void *ipc_sec_rsim_access_extract(const void *data, size_t size)
+{
+ struct ipc_sec_rsim_access_response_header *header;
+ void *rsim_data;
+
+ if (data == NULL || size < sizeof(struct ipc_sec_rsim_access_response_header))
+ return NULL;
+
+ header = (struct ipc_sec_rsim_access_response_header *) data;
+ if (header->length == 0 || header->length > size - sizeof(struct ipc_sec_rsim_access_response_header))
+ return NULL;
+
+ rsim_data = (void *) ((unsigned char *) data + sizeof(struct ipc_sec_rsim_access_response_header));
+
+ return rsim_data;
+}
+
int ipc_sec_lock_infomation_setup(struct ipc_sec_lock_infomation_request_data *data,
unsigned char type)
{