def get_estimate_size(self): ''' returns the estimate size of the package on card ''' size = 0x00 if "Applet" in self.components.keys(): applet_component_str = self.components["Applet"] applet_comp_size = utils.getBytes(applet_component_str, 2, 2) size = size + int(applet_comp_size, 16) size = size + int(len(self.get_aid()) / 2) # class component class_comp_size = utils.getBytes(self.components["Class"], 2, 2) size = size + int(class_comp_size, 16) # method component method_comp_size = utils.getBytes(self.components["Method"], 2, 2) size = size + int(method_comp_size, 16) if "Export" in self.components.keys(): export_component_str = self.components["Applet"] export_comp_size = utils.getBytes(export_component_str, 2, 2) size = size + int(export_comp_size, 16) # static component static_comp_size = utils.getBytes(self.components["Staticfield"], 2, 2) size = size + int(static_comp_size, 16) return size
def get_version(self): ''' returns the load file version ''' # look into the header component header_component_str = self.components["Header"] # the minor and major version are byte 11 and 12 of the header component minor_version = utils.getBytes(header_component_str, 11) major_version = utils.getBytes(header_component_str, 12) return major_version + "." + minor_version
def get_aid(self): ''' returns the load file AID ''' # look into the header component header_component_str = self.components["Header"] # the package AIDlength is byte 13 of the header component aid_len = utils.getBytes(header_component_str, 13) aid = utils.getBytes(header_component_str, 14, int(aid_len, 16)) return aid
def get_jc_version(self): ''' returns the load file javacard version ''' # look into the header component header_component_str = self.components["Header"] # the minor and major version are byte 8 and 9 of the header component minor_version = utils.getBytes(header_component_str, 8) major_version = utils.getBytes(header_component_str, 9) return major_version + "." + minor_version
def get_pkg_name(self): ''' returns the load file package name ''' # look into the header component header_component_str = self.components["Header"] # the package name is after the package aid in the header component aid_len = utils.getBytes(header_component_str, 13) name_len_offset = 14 + int(aid_len, 16) + 1 name_len = utils.getBytes(header_component_str, name_len_offset) #package name is not always set (ie JC version 2.1) if name_len != '': name = utils.getBytes(header_component_str, name_len_offset + 1, int(name_len, 16)) else: name = "not set" return name
def get_applet_aid(self): ''' returns the aid of tha application if any ''' # look into the applet component applets_aid = [] if "Applet" in self.components.keys(): applet_component_str = self.components["Applet"] applet_count = utils.getBytes(applet_component_str, 4) offset = 5 for i in range(0, int(applet_count, 16)): aid_len = utils.getBytes(applet_component_str, offset) offset = offset + 1 aid = utils.getBytes(applet_component_str, offset, int(aid_len, 16)) offset = offset + int(aid_len, 16) applets_aid.append(aid) # by pass install method offset offset = offset + 2 return applets_aid
def get_import_pkg_aid(self): ''' return a list of tuple containing pkg_aid, version and eventually the name''' # look into the import component imported_pkg_aid = [] if "Import" in self.components.keys(): import_component_str = self.components["Import"] import_count = utils.getBytes(import_component_str, 4) offset = 5 for i in range(0, int(import_count, 16)): minor_version = utils.getBytes(import_component_str, offset) offset = offset + 1 major_version = utils.getBytes(import_component_str, offset) offset = offset + 1 aid_len = utils.getBytes(import_component_str, offset) offset = offset + 1 aid = utils.getBytes(import_component_str, offset, int(aid_len, 16)) offset = offset + int(aid_len, 16) imported_pkg_aid.append( (aid, major_version + "." + minor_version, constants.aid_dict.get(aid, ""))) return imported_pkg_aid
def get_int_support(self): ''' returns True if the load file use integer ''' # look into the header component header_component_str = self.components["Header"] flag = utils.getBytes(header_component_str, 10) return (int(flag, 16) & 0x01) == 0x01