diff --git a/src/devtools/packer/mt2735/mipack.py b/src/devtools/packer/mt2735/mipack.py
new file mode 100644
index 0000000..8148381
--- /dev/null
+++ b/src/devtools/packer/mt2735/mipack.py
@@ -0,0 +1,879 @@
+#!/usr/bin/python
+# -*- coding: utf8 -*-
+
+import json
+import struct
+import sys
+import binascii
+import cryptoSB
+import copy
+
+from jsoncomment import JsonComment
+
+__Align = 16
+__Align_16_en = 0
+
+__TEST = 0
+
+__Align_pub_key_apend = 512
+__Align_sign_size = 512
+
+g_magic_size = 8
+g_total_len_size = 4
+g_bl_version_size = 4
+g_img_number_size = 4
+g_ls_cmd_number_size = 4
+g_mi_header_info_size = (g_magic_size + g_total_len_size + g_bl_version_size + g_img_number_size + g_ls_cmd_number_size)
+
+g_img_header_size = 96
+g_ls_cmd_size = 8
+
+g_img_oneoffset_table_size = 4
+g_img_onehash_table_size = 64
+
+g_public_key_size = __Align_pub_key_apend
+g_rsa_n_size = __Align_pub_key_apend
+g_sbc_auth_inf_size = 4
+g_sbc_auth_key_hash_size = 4
+g_sbc_auth_alg_size = 4
+g_sbc_auth_alg_hash_size = 4
+g_sbc_rsa_pad_sel_size = 4
+g_sbc_pub_key_len_size = 4
+g_sbc_size = (g_public_key_size + g_rsa_n_size + g_sbc_auth_inf_size + g_sbc_auth_key_hash_size + g_sbc_auth_alg_size + g_sbc_auth_alg_hash_size + g_sbc_rsa_pad_sel_size + g_sbc_pub_key_len_size)
+
+g_boot_hash_size = 64
+g_signature_size = __Align_sign_size
+g_auth_size = (g_boot_hash_size + g_signature_size)
+
+g_ck_magic_size = 16
+g_ck_soc_id_size = 32
+g_ck_pub_key_size = __Align_pub_key_apend
+g_ck_auth_algo_size = 4
+g_ck_put_key_len_size = 4
+g_ck_signature_size = __Align_sign_size
+g_ck_size = (g_ck_magic_size + g_ck_soc_id_size + g_ck_pub_key_size + g_ck_auth_algo_size + g_ck_put_key_len_size + g_ck_signature_size)
+
+def to_int(s):
+    if isinstance(s, (str, unicode)):
+        return int(s, 0)
+    else:
+        return s
+
+def byte_to_int(bytes):
+    result = 0
+
+    for b in bytes:
+        result = result*256 + ord(b)
+
+    return result
+
+def read_desc(mi_desc_fn):
+    #desc = json.load(open(mi_desc_fn))
+
+    parser = JsonComment(json)
+    desc = parser.loads(open(mi_desc_fn).read())
+
+    for img in desc['images']:
+        img['img_enc_alg'] = to_int(img['img_enc_alg'])
+        img['img_enc_inf'] = to_int(img['img_enc_inf'])
+
+        '''0627 remove int assign avoid key start is (0x00..)'''
+        #img['img_iv'] = to_int(img['img_iv'])
+
+    return desc
+
+
+def gen_ver_magic(major, minor, revision):
+    major = to_int(major)
+    minor = to_int(minor)
+    revision = to_int(revision)
+
+    x = major ^ 0xaa
+    y = minor ^ 0x55
+    z = revision ^ 0x99
+    checksum = (x + y + z) & 0xff
+
+    return (major << 0) | (minor << 8) | (revision << 16) | (checksum << 24)
+
+def my_gen_ver_magic(major, minor, revision):
+    major = to_int(major)
+    minor = to_int(minor)
+    revision = to_int(revision)
+
+    x = major ^ 0xaa
+    y = minor ^ 0x55
+    z = revision ^ 0x99
+    checksum = (x + y + z) & 0xff
+
+    highmagic = byte_to_int(b'\x27\x21\xca\xfe')
+    #print(hex(highmagic))
+
+    return (major << 0) | (minor << 8) | (revision << 16) | (checksum << 24), highmagic
+
+def my_gen_mtk_magic(magic):
+    magic_str = my_to_bytes(magic, g_magic_size, endianess='little')
+
+    lowmagic = byte_to_int(magic_str[4:8])
+    highmagic = byte_to_int(magic_str[0:4])
+
+    return lowmagic, highmagic
+
+def pad_to_align(align, current_size):
+    if not align:
+        return ''
+
+    pad_size = (align - current_size % align) % align
+    pad = '\0' * pad_size
+
+    return pad
+
+
+def dump(data):
+    for i in range(0, len(data)):
+        if(i%16 == 0):
+            print("[%04X]" % i),
+
+        print("%02x" % ord(data[i])),
+        if(((i+1)%16) == 0):
+            print
+
+def pack_load_script(mi_desc):
+    ls_script = []
+    reserved = 0
+    images = mi_desc['images']
+    img_num = len(images)
+
+    ls_cmds = mi_desc['load_srcipt_cmd']
+    ls_cmds_num = len(ls_cmds)
+    #print("ls_cmds_num: %d" %ls_cmds_num)
+
+    for i in range(ls_cmds_num):
+        ls_cmd = ls_cmds[i]
+        cmd = ls_cmd['cmd']
+
+        if cmd == "LOAD":
+            cmd_id = 0
+            img_file = ls_cmd['img_file']
+            addr = to_int(ls_cmd['addr'])
+
+            img_id = -1
+            for j in range(img_num):
+                img = images[j]
+                img_binary_name = img['img_file']
+                if img_file == img_binary_name:
+                    img_id = j
+                    break
+
+            if img_id == -1:
+                print("Please check img file name")
+                return
+
+            packed_cmd = struct.pack('<BBHI', cmd_id, img_id, reserved, addr)
+            #dump(packed_cmd)
+            #print
+        elif cmd == "MCU-ENTRY":
+            cmd_id = 2
+            mcu_id =  ls_cmd['mcu_id']
+            addr = to_int(ls_cmd['addr'])
+            packed_cmd = struct.pack('<BBHI', cmd_id, mcu_id, reserved, addr)
+            #dump(packed_cmd)
+            #print
+        elif cmd == "MCU_RESET-ENTRY":
+            cmd_id = 1
+            mcu_id =  ls_cmd['mcu_id']
+            addr = to_int(ls_cmd['addr'])
+            packed_cmd = struct.pack('<BBHI', cmd_id, mcu_id, reserved, addr)
+            #dump(packed_cmd)
+            #print
+        else:
+            print("unknown command: %s" %cmd)
+            return
+
+        ls_script += packed_cmd
+
+    #print("load script:")
+    #dump(ls_script)
+
+    return ls_script
+
+def rsa_data_parser(mi_desc, sbc_rsa_pad_sel):
+    rsa_dict = {"n":'', "e":'', "d":''}
+    rsa_parse = []
+
+    if(sbc_rsa_pad_sel == 0):
+        rsa_d = mi_desc['rsa_data']
+        rsa_data = rsa_d[0]
+
+        rsa_dict['n'] = rsa_data['n']
+        rsa_dict['e'] = rsa_data['e']
+        rsa_dict['d'] = rsa_data['d']
+        rsa_parse.append(rsa_dict)
+        #print(rsa_parse)
+    
+        #rsa_parse.append(rsa_data['n'])
+        #rsa_parse.append(rsa_data['e'])
+        #rsa_parse.append(rsa_data['d'])
+        rsa_parse.append(rsa_data['msg2hash'])
+        rsa_parse.append(rsa_data['signvalue'])
+        rsa_parse.append(rsa_data['shafunc'])
+        rsa_parse.append(rsa_data['msgtest'])
+        print("dump rsa_data_parser")
+        #print(rsa_parse)
+        #print(rsa_parse[0])
+    else:
+        rsa_d = mi_desc['rsa_data_pss']
+        rsa_data = rsa_d[0]
+
+        rsa_dict['n'] = rsa_data['n']
+        rsa_dict['e'] = rsa_data['e']
+        rsa_dict['d'] = rsa_data['d']
+        rsa_parse.append(rsa_dict)
+    
+        rsa_parse.append(rsa_data['msg2hash'])
+        rsa_parse.append(rsa_data['signvalue'])
+        rsa_parse.append(rsa_data['salt'])
+        rsa_parse.append(rsa_data['shafunc'])
+        rsa_parse.append(rsa_data['msgtest'])
+        print("dump rsa_data_parser")
+        print(rsa_parse)
+
+    return rsa_parse
+
+def ck_rsa_data_parser(mi_desc, sbc_rsa_pad_sel):
+    rsa_dict = {"n":'', "e":'', "d":''}
+    rsa_parse = []
+
+    if(sbc_rsa_pad_sel == 0):
+        rsa_d = mi_desc['ck_rsa_data']
+        rsa_data = rsa_d[0]
+
+        rsa_dict['n'] = rsa_data['n']
+        rsa_dict['e'] = rsa_data['e']
+        rsa_dict['d'] = rsa_data['d']
+        rsa_parse.append(rsa_dict)
+        #print(rsa_parse)
+
+        #rsa_parse.append(rsa_data['n'])
+        #rsa_parse.append(rsa_data['e'])
+        #rsa_parse.append(rsa_data['d'])
+        rsa_parse.append(rsa_data['msg2hash'])
+        rsa_parse.append(rsa_data['signvalue'])
+        rsa_parse.append(rsa_data['shafunc'])
+        rsa_parse.append(rsa_data['msgtest'])
+        print("dump rsa_data_parser")
+        #print(rsa_parse)
+        #print(rsa_parse[0])
+    else:
+        rsa_d = mi_desc['ck_rsa_data_pss']
+        rsa_data = rsa_d[0]
+
+        rsa_dict['n'] = rsa_data['n']
+        rsa_dict['e'] = rsa_data['e']
+        rsa_dict['d'] = rsa_data['d']
+        rsa_parse.append(rsa_dict)
+
+        rsa_parse.append(rsa_data['msg2hash'])
+        rsa_parse.append(rsa_data['signvalue'])
+        rsa_parse.append(rsa_data['salt'])
+        rsa_parse.append(rsa_data['shafunc'])
+        rsa_parse.append(rsa_data['msgtest'])
+        print("dump rsa_data_parser")
+        print(rsa_parse)
+
+    return rsa_parse
+
+def my_pack_images(mi_desc, privk, enckey, align=None, img_dir=''):
+    '''
+    mipack_file
+        mi_header_info
+            u32 magic
+            u32 total_len
+            u32 bl_version
+            u32 img_number (N)
+            u32 load_script_cmd_number (M)
+
+        img_info[1]~img_info[N]
+            u32     img_length
+            u32     img_offset
+            64Byes  img_hash
+            u32     img_enc_inf
+            u32     img_enc_alg
+            16Bytes img_iv
+
+        load_script_cmd[1]~load_script_cmd[M]
+            u64     cmd
+
+        sbc data
+            512Bytes sbc_pub_key
+            512Bytes sbc_rsa_n
+            u32     sbc_auth_info
+            u32     sbc_key_hash 
+            u32     sbc_auth_algo_dsa
+            u32     sbc_auth_algo_hash
+            u32     sbc_rsa_pad_sel
+            u32     sbc_pub_key_len
+
+        auth data
+            64Bytes boothash
+            512Bytes signature
+
+        [img binary 1]
+        ...
+        [img binary 1]
+    '''
+
+    key_mode = 0
+
+    mi_header_struct = struct.Struct('<IIIIII')
+    sbc_struct = struct.Struct('<IIIIII')
+    ck_struct = struct.Struct('<II')
+
+
+    #run hash
+    hash = cryptoSB.HASH()
+
+    # ver_magic
+    #version = mi_desc['version']
+    #major, minor, revision = version.split('.')
+    #ver_magic_l, ver_magic_h = my_gen_ver_magic(major, minor, revision)
+
+    ver_magic_l, ver_magic_h = my_gen_mtk_magic(to_int(mi_desc['magic_num']))
+
+    # bl region
+    bl_version = mi_desc['bl_version']
+    images = mi_desc['images']
+    img_num = len(images)
+    ls_cmds = mi_desc['load_srcipt_cmd']
+    ls_cmds_num = len(ls_cmds)
+
+    '''size of bl + imgl + sbc + auth'''
+    # Fixed size section: mi_header, sbc data, auth data
+    # Non-fixed size section: img_info, load script
+    bl_total_len = g_mi_header_info_size + g_sbc_size + g_auth_size
+    #bl_total_len = g_mi_header_info_size + g_sbc_size + g_auth_size + g_ck_size
+    bl_total_len += img_num * g_img_header_size
+    bl_total_len += ls_cmds_num * g_ls_cmd_size
+
+
+    #print("==== multi-image header size ====")
+    #print("g_mi_header_info_size=%d, g_sbc_size=%d, g_auth_size=%d, bl_total_len = %d" %(g_mi_header_info_size, g_sbc_size, g_auth_size, bl_total_len))
+
+    #img_header_table = []
+    img_headers = []
+    bins = []
+    sbc_region = []
+    hashtable = []
+    imagetmp = [[], [], [], [], [], [], [], [], [], []]
+    packtmp = []
+    blh_hash = []
+    signaturelist = []
+    ck_region = []
+    cksignaturelist = []
+
+    imagesize = []
+
+
+    sbc_auth_alg = mi_desc['sbc_auth_alg']
+    sbc_rsa_pad_sel = mi_desc['sbc_rsa_pad_sel']
+    ''' parer rsa test pattern '''
+    rsa_parse = rsa_data_parser(mi_desc, sbc_rsa_pad_sel)
+
+    # sbc region
+    ##pub_key = to_int(mi_desc['public_key'])
+    ##public_key = my_binify(pub_key)
+    '''20180627 remove int assign avoid key start is (0x00..)'''
+    pub_key = (mi_desc['public_key'])
+    public_key = cryptoSB.strip_key(pub_key)
+    pubk = b'\x04' + public_key
+
+    rsa_e = cryptoSB.my_a2b_hex(rsa_parse[0]['e'])
+    rsa_n = cryptoSB.my_a2b_hex(rsa_parse[0]['n']) 
+    if((sbc_auth_alg == 0) or (sbc_auth_alg == 1) or (sbc_auth_alg == 2)):
+        public_key_append = my_pad_to_align(public_key, __Align_pub_key_apend)
+        sbc_region.append(public_key_append)
+
+        #sbc_rsa_n = (mi_desc['sbc_rsa_n'])
+        #rsa_modulus = cryptoSB.strip_key(sbc_rsa_n)
+        rsa_modulus_append = my_pad_to_align(rsa_n, __Align_pub_key_apend)
+        sbc_region.append(rsa_modulus_append)
+    elif((sbc_auth_alg == 3) or (sbc_auth_alg == 4) or (sbc_auth_alg == 5)):
+        rsa_e_append = my_pad_to_align(rsa_e, __Align_pub_key_apend)
+        sbc_region.append(rsa_e_append)
+        rsa_n_append = my_pad_to_align(rsa_n, __Align_pub_key_apend)
+        sbc_region.append(rsa_n_append)
+
+
+    #print("======= sbc region =========")
+    sbc_auth_inf = mi_desc['sbc_auth_inf']
+    #print("sbc_auth_inf = 0x%x" %sbc_auth_inf)
+    sbc_key_hash = mi_desc['sbc_key_hash']
+    sbc_auth_alg = mi_desc['sbc_auth_alg']
+    #print("sbc_auth_alg = 0x%x" %sbc_auth_alg)
+    sbc_auth_alg_hash = mi_desc['sbc_auth_alg_hash']
+    sbc_rsa_pad_sel = mi_desc['sbc_rsa_pad_sel']
+    sbc_pub_key_len = mi_desc['sbc_pub_key_len']
+    sbc = sbc_struct.pack(sbc_auth_inf, sbc_key_hash, sbc_auth_alg, sbc_auth_alg_hash, sbc_rsa_pad_sel, sbc_pub_key_len)
+    sbc_region.append(sbc)
+
+	#print("======= ck region =========")
+    ck_mg = (mi_desc['ck_magic_num'])
+    ck_magic = cryptoSB.strip_key(ck_mg)
+    ck_region.append(ck_magic)
+    ck_sid = (mi_desc['ck_soc_id'])
+    ck_soc_id = cryptoSB.strip_key(ck_sid)
+    ck_region.append(ck_soc_id)
+    ck_pkey = (mi_desc['ck_pub_key'])
+
+    ck_pub_key = cryptoSB.strip_key(ck_pkey)
+    ck_pub_key_append = my_pad_to_align(ck_pub_key, __Align_pub_key_apend)
+    ck_region.append(ck_pub_key_append)
+    ck_pubk = b'\x04' + ck_pub_key
+
+    ck_rsa_n = (mi_desc['ck_rsa_n'])
+    ck_rsa_modulus = cryptoSB.strip_key(ck_rsa_n)
+    ck_rsa_modulus_append = my_pad_to_align(ck_rsa_modulus, __Align_pub_key_apend)
+    ck_region.append(ck_rsa_modulus_append)
+
+    ck_auth_algo = mi_desc['ck_auth_algo']
+    ck_pub_key_len = mi_desc['ck_pub_key_len']
+    ck = ck_struct.pack(ck_auth_algo, ck_pub_key_len)
+    ck_region.append(ck)
+
+    ck_en = mi_desc['change_key_en']
+    sign_ck_priv_key = mi_desc['sign_ck_priv_key']
+    signckprivk = cryptoSB.strip_key(sign_ck_priv_key)
+
+    # pad before 1st image
+
+    #pad = pad_to_align(64, expected_size)
+    #bins.append(pad)
+    #expected_size += len(pad)
+
+
+    # images
+    # 512 bytes aligned (20200310)
+    img_offset = (bl_total_len + 511) & (~511)
+    img_offset_table = []
+
+    for i in range(img_num):
+        #print("\n\n======== Start image step: =========")
+
+
+        img = images[i]
+        img_file = img['img_file']
+        img_enc_inf = img['img_enc_inf']
+        img_enc_alg = img['img_enc_alg']
+        #print("img_enc_inf=0x%x" %img_enc_inf)
+
+        bin = open(img_dir + '/' + img_file, 'rb').read()
+
+        iv_int = img['img_iv']
+        #iv = my_binify(iv_int)
+        '''0627 remove int assign avoid key start is (0x00..)'''
+        iv = cryptoSB.strip_key(iv_int)
+        iv0= int(iv[0:4].encode('hex'), 16)
+        iv1= int(iv[4:8].encode('hex'), 16)
+        iv2= int(iv[8:12].encode('hex'), 16)
+        iv3= int(iv[12:16].encode('hex'), 16)
+        #print type(iv)
+        #print("IV:")
+        #cryptoSB.dump(iv)
+
+
+        if(img_enc_inf == 1):
+            '''image encrypt'''
+            out = cryptoSB.my_img_enc(bin, enckey, iv, img_enc_alg, __Align)
+            bins.append(out)
+            #bins = out
+        elif(img_enc_inf == 2):
+            '''image encrypt'''
+            out = cryptoSB.my_img_enc(bin, enckey, iv, img_enc_alg, __Align)
+            bins.append(out)
+            #bins = out
+        else:
+            '''plaintext image'''
+            out = my_pad_to_align(bin, __Align)
+            bins.append(out)
+            #bins = out
+
+        # binary length should be 16 bytes aligned
+        length = len(out)
+
+        imagesize.append(length)
+        #print("")
+        #print("image[%d] offset : 0x%x" %(i, img_offset))
+        #print("image[%d] size   : 0x%x" %(i, imagesize[i]))
+
+        imagetmp[i] = copy.copy(bins)
+
+        img_str = ''.join(bins)
+        #print type(img_str)
+        #print("========= image[%d] binary ==========" %i)
+        #cryptoSB.dump(img_str)
+
+
+        # hash each (image header + image binary)
+        #print('')
+        #print("========= image[%d] binary hash ==========" %i)
+        hashvalue = cryptoSB.sb_hash(img_str, sbc_auth_alg_hash)
+        imghash = my_pad_to_align(hashvalue, g_boot_hash_size)
+        #cryptoSB.dump(imghash)
+
+        # img_header
+        img_hdr = struct.pack('<II',
+                                length,
+                                img_offset)
+        img_hdr += "".join(imghash)
+        '''20180719 fix IV order fail'''
+        img_hdr += struct.pack('<II16s',
+                                img_enc_inf,
+                                img_enc_alg,
+                                iv)
+
+
+        img_offset_table.append(str(img_offset))
+        length = (length + 511) & (~511)
+        img_offset += length
+        #img_offset_table.append(my_to_bytes(img_offset, 4, endianess='little'))
+
+        #print("\n=====>")
+        #print("image[%d] header info :" %i)
+        #cryptoSB.dump(img_hdr)
+        img_headers.append(img_hdr)
+
+        #img_headers.remove(img_hdr)
+        while len(bins) > 0:
+            bins.pop()
+
+
+    #print("\n\nSTART to pack all sections ...")
+    pack = []
+
+    #print("======== append mi_header info ==========")
+    total_len = int(img_offset_table[img_num-1]) + int(imagesize[img_num-1])
+
+    mi_header = mi_header_struct.pack(
+                        ver_magic_l,
+                        ver_magic_h,
+                        total_len,
+                        bl_version,
+                        img_num,
+                        ls_cmds_num)
+
+
+    pack.append(mi_header)
+
+    # append image info
+    for i in range(img_num):
+        pack += img_headers[i]
+
+
+    ls_script = pack_load_script(mi_desc)
+    if ls_script == None:
+        print("pack_load_script fail")
+        return
+
+    # append load script
+    pack += ls_script
+
+    # append sbc data
+    pack += sbc_region
+
+    # for easy view. please remove it while release final
+    '''align for (bl + imgl + sbc)'''
+    if(__Align_16_en == 1):
+        padnum = pad_to_align(16, len(''.join(pack)))
+        pack.append(padnum)
+
+    #print("======== append mi_header hash: ==========")
+    bl_header = ''.join(pack)
+    #cryptoSB.dump(bl_header)
+    blh = copy.copy(bl_header)
+    boothash = cryptoSB.sb_hash(blh, sbc_auth_alg_hash)
+    boothash_append = my_pad_to_align(boothash, g_boot_hash_size)
+    #cryptoSB.dump(boothash_append)
+    blh_hash.append(boothash_append)
+
+    # append hash
+    pack += blh_hash
+
+    #print("======== append mi_header signature: =========")
+    #privk = "\xc1\xbe\xe4\xfa\x86\xaf\x86\x84\x67\x7c\xae\xee\xa8\x8a\xb0\x72\x3e\x55\x4a\xef\x01\x60\xb8\xfc\x65\x3c\x0e\x00\x08\x0f\x4f\x78"
+    #pubk = "\x04\x14\xc1\xcf\x10\x99\x9d\x3a\x98\xf3\x71\xb8\xd8\x9b\x3b\x26\xb2\x9e\xe1\xbd\x99\xf3\xe0\x39\x3d\x34\x21\x6a\x6f\x49\x58\x7a\xb1\xdd\x8a\xba\x7a\x9d\x02\x99\x5f\xda\xa0\xb8\x62\x82\xae\xc2\xd0\xc6\x88\xc2\x26\x03\x97\x86\x65\x46\xbb\x20\xc9\xd1\x44\xb9\x84"
+
+    if sbc_auth_inf == 0:
+        padbytes = '\0' * g_signature_size
+        signaturelist.append(padbytes)
+    else:
+        pem_key_format = mi_desc['pem_key_format']
+        if(pem_key_format == 1):
+            '''PEM format'''
+            key_mode = 1
+        elif(pem_key_format == 2):
+            '''DER format'''
+            key_mode = 2
+        else:
+            '''String format'''
+            key_mode = 0
+
+        #ecdsa = cryptoSB.ECDSA()
+        #signature = ecdsa.sign(privk, pubk, boothash, sbc_auth_alg)
+        ''' 20180616 fix the sb_sign msg error : not boothash -> blh is right'''
+        if(ck_en == 0):
+            print("original format: no change key:")
+            signature = cryptoSB.sb_sign(privk, pubk, blh, sbc_auth_alg, sbc_auth_alg_hash, rsa_parse, sbc_rsa_pad_sel, key_mode)
+        else:
+            signature = cryptoSB.sb_sign(signckprivk, pubk, blh, sbc_auth_alg, sbc_auth_alg_hash, ck_rsa_parse, sbc_rsa_pad_sel, key_mode)
+
+        #print("signature size = %d" %len(signature))
+        signature_append = my_pad_to_align(signature, g_signature_size)
+        #cryptoSB.dump(signature_append)
+        signaturelist.append(signature_append)
+
+        #check verify
+        #ret = ecdsa.verify(pubk, boothash, signature, sbc_auth_alg)
+        #print("ecdsa verify: %s" %ret)
+
+
+    #dump("".join(signaturelist))
+    # append signature
+    pack += signaturelist
+
+    # for easy view, please remove it while release final
+    '''align for (bl + imgl + sbc + auth + ck)'''
+    if(__Align_16_en == 1):
+        padnum = pad_to_align(16, len(''.join(pack)))
+        pack.append(padnum)
+
+    # append ck field
+    ''' Skipped: no use on 2735
+    pack += ck_region
+
+    ck_field = ''.join(ck_region)
+    cryptoSB.dump(ck_field)
+    ckf = copy.copy(ck_field)
+
+    ck_signature = cryptoSB.sb_sign(privk, pubk, ckf, sbc_auth_alg, sbc_auth_alg_hash, rsa_parse, sbc_rsa_pad_sel, key_mode)
+    #print("ck_signature size = %d" %len(ck_signature))
+    ck_signature_append = my_pad_to_align(ck_signature, g_signature_size)
+    #cryptoSB.dump(ck_signature_append)
+    cksignaturelist.append(ck_signature_append)
+
+    pack += cksignaturelist
+    '''
+    # end append ck field
+
+    # append image binary
+    for i in range(img_num):
+        offset = int(img_offset_table[i])
+        pad_num = offset - len(''.join(pack))
+        #print("offset = %d" %offset)
+        #print("pad_num = %d" %pad_num)
+
+        padbytes = '\0' * pad_num
+        pack.append(padbytes)
+        pack += imagetmp[i]
+
+    #print(len(''.join(pack)))
+
+    # clear list
+    while len(signaturelist) > 0:
+        signaturelist.pop()
+
+
+    return ''.join(pack)
+
+'''support to_bytes to python 2.7'''
+def my_to_bytes(n, length, endianess='big'):
+    h = '%x' % n
+    s = ('0'*(len(h) % 2) + h).zfill(length*2).decode('hex')
+    return s if endianess == 'big' else s[::-1]
+
+'''long to byte string'''
+def my_binify(x):
+    h = hex(x)[2:].rstrip('L')
+    return binascii.unhexlify(h)
+
+def my_binify2(x):
+    if(hex(x)[0:2] == '0x'):
+        h = hex(x)[2:].rstrip('L')
+    else:
+        h = hex(x).rstrip('L')
+
+    return binascii.unhexlify(h)
+
+def my_pad_to_align(x, align):
+    if(align == 0):
+        return x
+    else:
+        size = len(x)
+        #print("size 0x%x" %size)
+        pad_size = (align - size % align) % align
+        for i in range(0, pad_size, 1):
+            x += b'\x00'
+
+        #cryptoSB.dump(x)
+        return x
+
+
+def img_enc(mi_desc, key, align=None):
+
+    images = mi_desc['images']
+    img_num = len(images)
+
+    img = images[0]
+    #load_addr = img['load_addr']
+    #entrypoint = img['entrypoint']
+    img_file = img['img_file']
+    img_enc_alg = img['img_enc_alg']
+    #print(img_enc_alg)
+    img_enc_inf = img['img_enc_inf']
+    #print(img_enc_inf)
+    iv = img['img_iv']
+    iv = my_binify(iv)
+    #print type(iv)
+    #print("img_enc dump:")
+    #cryptoSB.dump(iv)
+
+    bin = open(img_file, 'rb').read()
+    #cryptoSB.dump(bin)
+
+    #align
+    bin = my_pad_to_align(bin, 64)
+
+    aes = cryptoSB.AESCipher(key, 16)
+    encmsg = aes.aes_encrypt(bin)
+    #print("result image enc:")
+    #cryptoSB.dump(encmsg)
+
+    return encmsg
+
+
+
+
+if __name__ == '__main__':
+    import os, sys, getopt
+
+
+    def print_usage():
+        print ('usage:', os.path.basename(sys.argv[0]), "[options] <image config>.json\n", \
+            'options:\n', \
+            '\t[-o | --output out.img]\n', \
+            '\t[-h | --help]\n', \
+            '\t[-i | --input]\n', \
+            '\t[-k | --prikey hexkey e.g. 0x0102..]\n', \
+            '\t[-s | --enckey hexkey e.g. 0x0102..]\n', \
+            '\t[-p | --pemdir <pem path>\n', \
+            '\t[-d | --imgdir <image path>\n')
+
+
+    def main():
+        opts, args = getopt.getopt(sys.argv[1:],
+                                   'ho:a:i:k:s:p:d:',
+                                   ['help', 'output=', 'align=', 'input=',
+                                    'prikey=', 'enckey=', 'pemdir=', 'imgdir=']
+                                  )
+
+        out_name = None
+        align = 0
+        infile_name = None
+        aeskey = None
+        pubkey = None
+        privk = None
+        pem_dir = "binfile"
+        img_dir = ''
+
+        for o, a in opts:
+            if o in ('-h', '--help'):
+                print_usage()
+                sys.exit()
+            elif o in ('-o', '--output'):
+                out_name = a
+            elif o in ('-a', '--align'):
+                align = int(a)
+            elif o in ('-i', '--input'):
+                ## doesn't need currently
+                infile_name = a
+            elif o in ('-k', '--prikey'):
+                privkey = a
+            elif o in ('-s', '--enckey'):
+                aeskey = a
+            elif o in ('-p', '--pemdir'):
+                pem_dir = a
+            elif o in ('-d', '--imgdir'):
+                img_dir = a
+            else:
+                print_usage()
+                sys.exit(1)
+
+        if len(args) >= 1:
+            mi_desc_fn = args[0]
+        else:
+            print_usage()
+            sys.exit(1)
+
+        if not out_name:
+            fn, ext = os.path.splitext(mi_desc_fn)
+            out_name = fn + '.img'
+
+        """ read json script """
+        mi_desc = read_desc(mi_desc_fn)
+
+        #mipack = pack_images(mi_desc, align)
+
+        #print 'output: %s (%d bytes)' % (out_name, len(mipack))
+        #open(out_name, 'wb').write(mipack)
+
+        cmd_line_key = mi_desc['cmd_line_key']
+        sign_priv_key = mi_desc['sign_priv_key']
+        aes_enc_sym_key = mi_desc['aes_enc_sym_key']
+
+        """ Where is the key input from """
+
+        pem_key_format = mi_desc['pem_key_format']
+        if(pem_key_format == 1):
+            sbc_auth_alg = mi_desc['sbc_auth_alg']
+            if(sbc_auth_alg == 0):
+                key_path = pem_dir + "/ecdsa_p256_private.pem"
+                #print(key_path)
+                privk = open(key_path,"rb").read()
+                #privk = open("binfile/ecdsa_p256_private.pem","rb").read()
+                #pubk_pem = open("binfile/ecdsa_p256_public.pem","rb").read()
+            elif(sbc_auth_alg == 1):
+                privk = open("binfile/ecdsa_p384_private.pem","rb").read()
+
+            key = cryptoSB.strip_key(aes_enc_sym_key)
+
+        else:
+            if(cmd_line_key == 1):
+                key = cryptoSB.strip_key(aeskey)
+                privk = cryptoSB.strip_key(privkey)
+                #print("dump privkey:")
+                #cryptoSB.dump(privk)
+            elif(cmd_line_key == 0):
+                key = cryptoSB.strip_key(aes_enc_sym_key)
+                privk = cryptoSB.strip_key(sign_priv_key)
+                #print("dump privkey:")
+                #cryptoSB.dump(privk)
+            else:
+                prnit("ERROR: please check cmd_line_key json")
+
+
+
+        #run hash
+        #hash = cryptoSB.HASH()
+        #imghash = hash.hash_sha256(enc_data)
+        #cryptoSB.dump(imghash)
+
+        mipack = my_pack_images(mi_desc, privk, key, align, img_dir)
+        if mipack == None:
+            print("my_pack_images fail")
+            return
+
+        #out_name = 'my_' + fn + '.img'
+        #out_name = fn + '.img'
+        print('output: %s (%d bytes)' % (out_name, len(mipack)))
+        open(out_name, 'wb').write(mipack)
+
+    main()
+
