summaryrefstree
path: root/kernel/scripts/fmp/fips_fmp_integrity.py
blob: 29ab8a73e03301e7bae4376befe1081d97f642d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
This script is needed for buildtime integrity routine.
It calculates and embeds HMAC and other needed stuff for in terms of FIPS 140-2
"""

import os
import sys
from IntegrityRoutine import IntegrityRoutine
from Utils import Utils


__author__ = "Vadym Stupakov"
__copyright__ = "Copyright (c) 2017 Samsung Electronics"
__credits__ = ["Vadym Stupakov"]
__version__ = "1.0"
__maintainer__ = "Vadym Stupakov"
__email__ = "v.stupakov@samsung.com"
__status__ = "Production"


sec_sym = {".text":     ["first_fmp_text", "last_fmp_text"],
           ".rodata":   ["first_fmp_rodata", "last_fmp_rodata"],
           "init.text": ["first_fmp_init",   "last_fmp_init"]
           }

module_name = "fmp"

if __name__ == "__main__":
    if len(sys.argv) != 2:
        print("Usage " + sys.argv[0] + " elf_file")
        sys.exit(-1)

    elf_file = os.path.abspath(sys.argv[1])
    modules = sys.argv[2:]

    utils = Utils()
    utils.paths_exists([elf_file])

    integrity = IntegrityRoutine(elf_file)
    integrity.make_integrity(sec_sym=sec_sym, module_name=module_name, debug=False, print_reloc_addrs=False,
                             sort_by="address", reverse=False)