[Feature]Upload Modem source code
Change-Id: Id4294f30faced84d3e6fd6d5e61e1111bf287a37
diff --git a/mcu/protocol/layer4/sim/include/auth/aes.h b/mcu/protocol/layer4/sim/include/auth/aes.h
new file mode 100644
index 0000000..e964771
--- /dev/null
+++ b/mcu/protocol/layer4/sim/include/auth/aes.h
@@ -0,0 +1,42 @@
+/*
+ * AES functions
+ * Copyright (c) 2003-2006, Jouni Malinen <j@w1.fi>
+ * Copyright (C) 2015 MediaTek Inc.
+ *
+ *
+ * This program is free software; this software is distributed under
+ * the terms of 3-clause BSD license.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+#define AES_BLOCK_SIZE 16
+#define AES_PRIV_SIZE (4 * 44)
+
+void* aes_encrypt_init(const kal_uint8 *key, kal_int32 len);
+void aes_encrypt(void *ctx, const kal_uint8 *plain, kal_uint8 *crypt);
+void aes_encrypt_deinit(void *ctx);
+void* aes_decrypt_init(const kal_uint8 *key, kal_int32 len);
+void aes_decrypt(void *ctx, const kal_uint8 *crypt, kal_uint8 *plain);
+void aes_decrypt_deinit(void *ctx);
diff --git a/mcu/protocol/layer4/sim/include/auth/aes_wrap.h b/mcu/protocol/layer4/sim/include/auth/aes_wrap.h
new file mode 100644
index 0000000..009b0f3
--- /dev/null
+++ b/mcu/protocol/layer4/sim/include/auth/aes_wrap.h
@@ -0,0 +1,65 @@
+/*
+ * AES-based functions
+ *
+ * - AES Key Wrap Algorithm (128-bit KEK) (RFC3394)
+ * - One-Key CBC MAC (OMAC1) hash with AES-128
+ * - AES-128 CTR mode encryption
+ * - AES-128 EAX mode encryption/decryption
+ * - AES-128 CBC
+ *
+ * Copyright (c) 2003-2007, Jouni Malinen <j@w1.fi>
+ * Copyright (C) 2015 MediaTek Inc.
+ *
+ *
+ * This program is free software; this software is distributed under
+ * the terms of 3-clause BSD license.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+
+
+kal_int32 aes_wrap(const kal_uint8 *kek, int n, const kal_uint8 *plain, kal_uint8 *cipher);
+kal_int32 aes_unwrap(const kal_uint8 *kek, int n, const kal_uint8 *cipher, kal_uint8 *plain);
+kal_int32 omac1_aes_128_vector(const kal_uint8 *key, size_t num_elem,
+ const kal_uint8 *addr[], const size_t *len,
+ kal_uint8 *mac);
+kal_int32 omac1_aes_128(const kal_uint8 *key, const kal_uint8 *data, size_t data_len,
+ kal_uint8 *mac);
+kal_int32 aes_128_encrypt_block(const kal_uint8 *key, const kal_uint8 *in, kal_uint8 *out);
+kal_int32 aes_128_ctr_encrypt(const kal_uint8 *key, const kal_uint8 *nonce,
+ kal_uint8 *data, size_t data_len);
+kal_int32 aes_128_eax_encrypt(const kal_uint8 *key,
+ const kal_uint8 *nonce, size_t nonce_len,
+ const kal_uint8 *hdr, size_t hdr_len,
+ kal_uint8 *data, size_t data_len, kal_uint8 *tag);
+kal_int32 aes_128_eax_decrypt(const kal_uint8 *key,
+ const kal_uint8 *nonce, size_t nonce_len,
+ const kal_uint8 *hdr, size_t hdr_len,
+ kal_uint8 *data, size_t data_len, const kal_uint8 *tag);
+kal_int32 aes_128_cbc_encrypt(const kal_uint8 *key, const kal_uint8 *iv, kal_uint8 *data,
+ size_t data_len);
+kal_int32 aes_128_cbc_decrypt(const kal_uint8 *key, const kal_uint8 *iv, kal_uint8 *data,
+ size_t data_len);
diff --git a/mcu/protocol/layer4/sim/include/auth/milenage.h b/mcu/protocol/layer4/sim/include/auth/milenage.h
new file mode 100644
index 0000000..028c632
--- /dev/null
+++ b/mcu/protocol/layer4/sim/include/auth/milenage.h
@@ -0,0 +1,47 @@
+/*
+ * UMTS AKA - Milenage algorithm (3GPP TS 35.205, .206, .207, .208)
+ * Copyright (c) 2006-2007 <j@w1.fi>
+ * Copyright (C) 2015 MediaTek Inc.
+ *
+ *
+ * This program is free software; this software is distributed under
+ * the terms of 3-clause BSD license.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+void milenage_generate(const kal_uint8 *opc, const kal_uint8 *amf, const kal_uint8 *k, const kal_uint8 *sqn, const kal_uint8 *_rand, kal_uint8 *autn, kal_uint8 *ik, kal_uint8 *ck, kal_uint8 *res, kal_uint32 *res_len);
+
+kal_int32 milenage_auts(const kal_uint8 *opc, const kal_uint8 *k, const kal_uint8 *_rand, const kal_uint8 *auts, kal_uint8 *sqn);
+
+kal_int32 gsm_milenage(const kal_uint8 *opc, const kal_uint8 *k, const kal_uint8 *_rand, kal_uint8 *sres, kal_uint8 *kc);
+
+kal_int32 milenage_check(const kal_uint8 *opc, const kal_uint8 *k, const kal_uint8 *sqn, const kal_uint8 *_rand, const kal_uint8 *autn, kal_uint8 *ik, kal_uint8 *ck, kal_uint8 *res, kal_uint32 *res_len, kal_uint8 *auts);
+
+kal_int32 milenage_f1(const kal_uint8 *opc, const kal_uint8 *k, const kal_uint8 *_rand, const kal_uint8 *sqn, const kal_uint8 *amf, kal_uint8 *mac_a, kal_uint8 *mac_s);
+
+kal_int32 milenage_f2345(const kal_uint8 *opc, const kal_uint8 *k, const kal_uint8 *_rand, kal_uint8 *res, kal_uint8 *ck, kal_uint8 *ik, kal_uint8 *ak, kal_uint8 *akstar);
+
+kal_int32 milenage_opc_gen(kal_uint8 *opc, const kal_uint8 *k, const kal_uint8 *op);