[Feature]add MT2731_MP2_MR2_SVN388 baseline version

Change-Id: Ief04314834b31e27effab435d3ca8ba33b499059
diff --git a/src/bsp/lk/lib/hmac/hmac.c b/src/bsp/lk/lib/hmac/hmac.c
new file mode 100644
index 0000000..8300268
--- /dev/null
+++ b/src/bsp/lk/lib/hmac/hmac.c
@@ -0,0 +1,83 @@
+#include <stdlib.h>
+#include <string.h>
+#include <hmac.h>
+/**
+   Initialize an HMAC context.
+   @param hmac     The HMAC state
+   @param hash     The hash for HMAC
+   @param key      The secret key
+   @param keylen   The length of the secret key
+   @return 0 if successful
+*/
+int hmac_init(hmac_state *hmac, hash_param *hash, const unsigned char *key,
+          unsigned long keylen)
+{
+    unsigned int i;
+    unsigned char *buf;
+
+    hmac->hash = hash;
+
+    hmac->key = malloc(hmac->hash->blocksize);
+    buf = malloc(hmac->hash->blocksize);
+
+    /* assume keylen <= hmac blocksize */
+    memcpy(hmac->key, key, keylen);
+    memset(hmac->key + keylen, 0, hmac->hash->blocksize - keylen);
+
+    for (i = 0; i < hmac->hash->blocksize; i++)
+        buf[i] = hmac->key[i] ^ 0x36;
+
+    hmac->hash->init(hmac->hash->hash_state);
+    hmac->hash->process(hmac->hash->hash_state, buf, hmac->hash->blocksize);
+
+    free(buf);
+
+    return 0;
+}
+
+/**
+  Process data through HMAC
+  @param hmac    The hmac state
+  @param in      The data to send through HMAC
+  @param inlen   The length of the data to HMAC
+  @return 0 if successful
+*/
+int hmac_process(hmac_state *hmac, const unsigned char *in, unsigned long inlen)
+{
+    return hmac->hash->process(hmac->hash->hash_state, in, inlen);
+}
+
+/**
+   Terminate an LTC_HMAC session
+   @param hmac    The LTC_HMAC state
+   @param out     [out] The destination of the LTC_HMAC authentication tag
+   @param outlen  [in/out]  The max size and resulting size of the LTC_HMAC authentication tag
+   @return CRYPT_OK if successful
+*/
+int hmac_done(hmac_state *hmac, unsigned char *out, unsigned long *outlen)
+{
+    unsigned int i;
+    unsigned char *buf, *isha;
+
+    buf = malloc(hmac->hash->blocksize);
+    isha = malloc(hmac->hash->hashsize);
+
+    hmac->hash->done(hmac->hash->hash_state, isha);
+
+    for (i = 0; i < hmac->hash->blocksize; i++)
+        buf[i] = hmac->key[i] ^ 0x5c;
+
+    hmac->hash->init(hmac->hash->hash_state);
+    hmac->hash->process(hmac->hash->hash_state, buf, hmac->hash->blocksize);
+    hmac->hash->process(hmac->hash->hash_state, isha, hmac->hash->hashsize);
+    hmac->hash->done(hmac->hash->hash_state, buf);
+
+    for (i = 0; i < hmac->hash->hashsize && i < (unsigned int)*outlen; i++)
+        out[i] = buf[i];
+
+    *outlen = i;
+
+    free(isha);
+    free(buf);
+    return 0;
+}
diff --git a/src/bsp/lk/lib/hmac/include/hmac.h b/src/bsp/lk/lib/hmac/include/hmac.h
new file mode 100644
index 0000000..5efe2b1
--- /dev/null
+++ b/src/bsp/lk/lib/hmac/include/hmac.h
@@ -0,0 +1,24 @@
+#ifndef HMAC_H
+#define HMAC_H
+
+typedef struct Hash_param {
+    void *hash_state;
+    int (*init)(void *hash_state);
+    int (*process)(void *hash_state, const unsigned char *in, unsigned int inlen);
+    int (*done)(void *hash_state, unsigned char *out);
+    unsigned int hashsize;
+    unsigned int blocksize;
+} hash_param;
+
+typedef struct Hmac_state {
+    hash_param     *hash;
+    unsigned char  *key;
+} hmac_state;
+
+int hmac_init(hmac_state *hmac, hash_param *hash, const unsigned char *key,
+              unsigned long keylen);
+int hmac_process(hmac_state *hmac, const unsigned char *in,
+                 unsigned long inlen);
+int hmac_done(hmac_state *hmac, unsigned char *out, unsigned long *outlen);
+
+#endif /* HMAC_H */
diff --git a/src/bsp/lk/lib/hmac/rules.mk b/src/bsp/lk/lib/hmac/rules.mk
new file mode 100644
index 0000000..37fe032
--- /dev/null
+++ b/src/bsp/lk/lib/hmac/rules.mk
@@ -0,0 +1,8 @@
+LOCAL_DIR := $(GET_LOCAL_DIR)
+
+MODULE := $(LOCAL_DIR)
+
+MODULE_SRCS := \
+	$(LOCAL_DIR)/hmac.c
+
+include make/module.mk