A smart password key file storage method based on SKF standard

By adopting a chain file storage method based on SKF standard in smart password keys, the problem of fragmentation, query and write efficiency of smart password key data storage is solved, and efficient file storage and query are achieved.

CN116414785BActive Publication Date: 2025-04-11SHANDONG SINOCHIP SEMICON CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310328492.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-30
Publication Date
2025-04-11
Estimated Expiration
2043-03-30

AI Technical Summary

Technical Problem

Due to limited internal storage resources, smart password keys cannot use general file systems such as Fat, resulting in file storage methods that are continuously stored in bytes, which are inefficient in retrieval efficiency, easily fragmented space, and low writing and query efficiency.

Method used

The chain file storage method based on SKF standard is adopted to manage the data on the chip, and efficient file storage and query is achieved through the separation and mapping of directory tables, file allocation tables and data areas.

Benefits of technology

It effectively prevents the generation of fragmented space, improves query and write efficiency, and solves the problems of fragmentation, query and write efficiency, and low data chaotic data storage of smart password keys.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116414785B_ABST
    Figure CN116414785B_ABST
Patent Text Reader

Abstract

The present invention discloses a smart password key file storage method based on the SKF standard. The method divides the NORFLASH space into a directory table, a file allocation table, a data area, and a buffer zone, and defines the file system mapping process from the directory table to the file allocation table and then to the data area. For the reading of applications, containers, and files, the file allocation table position is first retrieved from the directory table, and then the file data in the data area is read according to the file allocation table. When writing a file, a linked list structure is adopted, and the current allocation table is sequentially set to record the next allocation table address, and the corresponding directory item is found according to the file name, and the first chain number of the file allocation table is obtained, and data is written to the data address corresponding to the file allocation table address until the writing is completed. The method implements chain file storage management for NORFLASH, implements file storage and access based on the SKF business standard, prevents the generation of fragmented space, and improves query and writing efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the field of file storage, and in particular to an intelligent password key file storage method based on the SKF standard. Background Art

[0002] Due to the limited internal storage resources, the smart password key cannot use general file systems such as Fat. The file storage method is to store files in a continuous order divided by bytes. When querying a certain record, it is necessary to traverse from the beginning, and the retrieval efficiency is very low. This storage method is prone to fragmented space. When a record in the middle is deleted, the newly stored data can only be a record with a smaller amount of data. After the record is stored, it will further generate small fragmented space that is difficult to continue to use. Summary of the invention

[0003] In view of the defects of the prior art, the present invention provides a smart password key file storage method based on the SKF standard, which adopts a chain file storage method to manage the on-chip data, thereby solving the problems of fragmentation, low query and write efficiency, and data confusion in the smart password key data storage.

[0004] In order to solve the technical problem, the technical solution adopted by the present invention is: a smart password key file storage method based on the SKF standard, comprising the following steps:

[0005] S01) Define the file system storage structure, divide the NORFLASH space into directory table, file allocation table, data area, and buffer zone. The directory table is used to store directory items. Each application, container, and file has its own target item. The directory item includes the ID number, the first chain number of the file allocation table, the type identifier, the file length, the write permission, the read permission, the name, the reuse and reserved parts; the file allocation table is used to store the file table, the data area is used to store data, and the buffer zone is a reserved storage space for buffering input or output data;

[0006] S02) Set the file system mapping process as directory table->file allocation table->data. For reading applications, containers and files, first retrieve the file allocation table location from the directory table, and then read the file data in the data area according to the file allocation table. The operation process is: directory table->file allocation table->data; the file allocation table chain physical serial number is bound to the sequential physical minimum mapping unit of the data area. Once the address of the file allocation table is determined, the corresponding data address can be found according to the offset.

[0007] S03), file writing process, the first chain number of the file allocation table in the directory entry of the file is the starting address of the file allocation table of the file. If this file only occupies one minimum mapping unit, the corresponding value of the starting address of the file allocation table is the end mark; if this file occupies more than one minimum mapping unit, a linked list structure is adopted, and the current file allocation table is placed with the index number of the next file allocation table, and so on. The corresponding value of the last file allocation table is set as the end mark; when writing a file, find the corresponding directory entry according to the file name, obtain the first chain number of the allocation table, write data to the data address corresponding to the address of the file allocation table, and then write to the second file allocation table address after writing, until the writing is completed;

[0008] S04), file deletion process, when a file is deleted, the directory entry, file allocation table and data corresponding to the file are erased;

[0009] S05) Design file system interface for file storage management;

[0010] S06) Implement functional modules according to SKF specifications.

[0011] Furthermore, in step S01), a root directory is created when the device is initialized, and when the device is recycled and reissued, the original operating system is deleted and the root directory is created again.

[0012] Furthermore, in step S02), the minimum mapping unit is 64 bytes.

[0013] Furthermore, the file interface designed in step S05) includes obtaining an empty directory entry, obtaining an empty file allocation table entry, obtaining the last record, obtaining the maximum record, and secure erasing.

[0014] Furthermore, the functional modules in step S06) include a device management module, an access control module, an application management module, a container management module, a file management module, and a password service module.

[0015] Furthermore, the process of implementing the functional module according to SKF specifications is as follows:

[0016] S61) Whether there is a request to implement the functional module, if not, return, if yes, proceed to the next step;

[0017] S62), check whether the function module already exists, if it does, return, if not, proceed to the next step;

[0018] S63), obtain an empty file allocation table;

[0019] S64), write file allocation table;

[0020] S65) Write directory entry;

[0021] S66) Write data into the data area pointed to by the file allocation table you want to obtain.

[0022] Beneficial effects of the present invention: The present invention implements chain file storage management for NORFLASH, implements file storage and access to module data such as applications, containers, and files based on SKF business standards, prevents the generation of fragmented space, and improves query and write efficiency. The present invention uses chain file storage to manage on-chip data, solves the problems of fragmentation of smart password key data storage, low query and write efficiency, and data confusion, and improves the performance and efficiency of smart password keys in the application process. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] Figure 1 This is a schematic diagram of NORFLASH storage space division;

[0024] Figure 2 This is a schematic diagram of file system mapping;

[0025] Figure 3 Write a schematic diagram to the file;

[0026] Figure 4 To create a container flow chart. DETAILED DESCRIPTION

[0027] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments.

[0028] Example 1

[0029] This embodiment discloses a smart password key file storage method based on the SKF standard. The smart password key in this method complies with GM / T 0016-2012 "Smart Password Key Password Application Interface Specification" (SKF standard specification for short) promulgated by the State Cryptography Administration. It has high security, ease of use and interoperability, meets the requirements of information security protection for hardware password devices, and is widely used in finance, communication, storage and other occasions where identity authentication is required.

[0030] As the core of the COS system, the intelligent password key file storage needs to store applications, files, containers, certificates, private keys and other information. This information is stored in the on-chip NORFLASH. Since NORFLASH is a continuous storage space, it is necessary to design file storage for this storage space.

[0031] This method implements chain file storage management for NORFLASH, and realizes file storage and access to module data such as applications, containers, and files based on SKF business standards, preventing the generation of fragmented space and improving query and write efficiency.

[0032] Specifically, this method provides the following functions:

[0033] 1. Provide operations such as file creation, deletion, reading, writing, file enumeration, and file information acquisition;

[0034] 2. Provide operations such as creating, enumerating, deleting, opening, and closing applications;

[0035] 3. Provide operations such as container creation, deletion, enumeration, opening, closing, obtaining container type, importing digital certificates, and exporting digital certificates.

[0036] The above functions are the implementation steps of this method:

[0037] 1) Design the file system storage structure

[0038] The root directory is created when the device is initialized. When the device is recycled and reissued, the original operating system is deleted and the root directory is created again. The root directory can be considered as an empty directory table. The presence of a root directory means that a file system has been created.

[0039] like Figure 1 As shown in the figure, the NORFLASH space is divided into a directory table, a file allocation table, a data area, and a buffer. The directory table is used to store directory entries of applications, containers, files, etc.; the file allocation table is used to store file tables; the data area is used to store data (such as private keys, certificates, etc.); the buffer is a reserved storage space used to buffer input or output data.

[0040] Each application, container, and file has its own directory entry. The directory entry structure is shown in Table 1, which contains members such as ID, FirstChain index, Type, Size, WriteRights, ReadRights, Name, Reserve, etc., a total of 100 bytes.

[0041] Table 1 Directory entry structure

[0042]

[0043] 2) Set the file system mapping process to directory table -> file allocation table -> data. For reading applications, containers and files, first retrieve the file allocation table location from the directory table, and then read the file data in the data area according to the file allocation table. The operation process is: directory table (Dir) -> file allocation table (Fat) -> data (Data). This process does not need to traverse all space data in sequence, which improves query and write efficiency.

[0044] The basic characteristics of Flash are that word (4 bytes) is the minimum write and read unit, sector (4K bytes) is the minimum erasable unit, and one quarter of a page, or 64 bytes, is a logical address, or the minimum mapping unit, that is, one data segment corresponds to 64 bytes.

[0045] The physical serial number of the file allocation table chain is bound to the sequential physical minimum mapping unit of the data area. Once the address of the file allocation table is determined, the corresponding data address can be found based on the offset. Figure 2 As shown, the correspondence between Fat and Data is: Fat1 corresponds to Data1, …, Fat n corresponds to Data n.

[0046] 3) File writing process

[0047] The First chain index in the directory entry of the file is the starting address of the file allocation table of the file. If the file only occupies one minimum mapping unit, the corresponding value of the starting address of the file allocation table is the end mark 0xEEEEEEEE; if the file occupies more than one minimum mapping unit, a linked list structure is used, and the current file allocation table is placed with the next file allocation table index number (that is, the next file allocation table address), and so on. The corresponding value of the last file allocation table is set to the end mark 0xEEEEEEEE. Figure 3 shown.

[0048] For example, when creating a file, first allocate the file space, then calculate the number of Data segments n (file size / minimum mapping unit 64) required to store the data according to the file size, and then obtain the corresponding empty file allocation table entries according to the number of segments n; for these n allocation tables, set the current allocation table to record the address of the next allocation table in turn, and the last allocation table address is 0xEEEEEEEE. Finally, write the first address of the allocation table to the First chain index in the directory entry. When writing a file, find the corresponding directory entry according to the file name, obtain the First chain index, write the data to the Data address corresponding to the Fat address, and then write to the second Fat address until the writing is completed.

[0049] 4) File deletion process

[0050] When a file is deleted, the corresponding directory entry, file allocation table, and data are all erased. The erased space can continue to be applied for use. The newly applied space is not subject to the size limit of the original applied space, and will not cause fragmented space.

[0051] 5) File system interface design

[0052] The operations involved in the file system include application, container, file, password service and other interface application operations. To facilitate file storage management, the following file system function interface is designed:

[0053] Table 2 Function interface design

[0054]

[0055] The internal implementation of each of the above interfaces is:

[0056] cos_get_free_index: Starting from the beginning of the directory table, loop through each directory entry. If the item has not been written (the value is 0xffffffff), the address is recorded as the free first address.

[0057] cos_get_free_fat: Starting from the beginning of the file allocation table, loop through each file allocation table, and if the item has not been written (the value is 0xffffffff), record the address as the free first address. The allocation table address is subsequently written into the First chain index field of the directory entry structure.

[0058] cos_get_last_record: Finds the last record in the specified range, used for operations such as obtaining file size, searching for free directory entries, and searching for free file allocation tables.

[0059] cos_get_max_id: Gets the corresponding maximum ID number based on the application, container, or file type.

[0060] cos_safe_erase: safely erase the data at the address according to the input address of fat file allocation table.

[0061] The files in 3), 4), and 5) above generally refer to applications, containers, and files.

[0062] 6) Implement functional modules according to SKF specifications

[0063] SKF standard interface includes modules such as device management, access control, application management, container management, file management, and password services. These functional modules need to be implemented in accordance with the specification requirements. The process of implementing these functional modules is as follows:

[0064] S61) Whether there is a request to implement the functional module, if not, return, if yes, proceed to the next step;

[0065] S62), check whether the function module already exists, if it does, return, if not, proceed to the next step;

[0066] S63), obtain an empty file allocation table;

[0067] S64), write file allocation table;

[0068] S65) Write directory entry;

[0069] S66) Write data into the data area pointed to by the file allocation table you want to obtain.

[0070] like Figure 4 As shown in the figure, taking the creation of a container in container management as an example, the process of creating a container is as follows:

[0071] There is a request to create a container;

[0072] Check whether the container already exists, return if it does, and continue with subsequent operations if it does not;

[0073] Get an empty file allocation table;

[0074] Write file allocation table;

[0075] Get an empty directory entry;

[0076] Write directory entries;

[0077] Write data to the data area pointed to by the obtained file allocation table.

[0078] What is described above are only the basic principles and preferred embodiments of the present invention. Improvements and substitutions made by those skilled in the art based on the present invention belong to the protection scope of the present invention.

Claims

1. A smart password key file storage method based on SKF standard, characterized by: The following steps are involved: S01) Define the file system storage structure, divide the NORFLASH space into directory table, file allocation table, and data area. The directory table is used to store directory items. Each application, container, and file has its own target item. The directory item includes the ID number, the first chain number of the file allocation table, the type identifier, the file length, the write permission, the read permission, the name, the reuse and reserved parts; the file allocation table is used to store the file table, and the data area is used to store data; S02) Set the file system mapping process as directory table->file allocation table->data. For reading applications, containers and files, first retrieve the file allocation table location from the directory table, and then read the file data in the data area according to the file allocation table. The operation process is: directory table->file allocation table->data; the file allocation table chain physical serial number is bound to the sequential physical minimum mapping unit of the data area. Once the address of the file allocation table is determined, the corresponding data address can be found according to the offset. S03), file writing process, the first chain number of the file allocation table in the directory entry of the file is the starting address of the file allocation table of the file. If this file only occupies one minimum mapping unit, the corresponding value of the starting address of the file allocation table is the end mark; if this file occupies more than one minimum mapping unit, a linked list structure is adopted, and the current file allocation table is placed with the index number of the next file allocation table, and so on. The corresponding value of the last file allocation table is set as the end mark; when writing a file, find the corresponding directory entry according to the file name, obtain the first chain number of the allocation table, write data to the data address corresponding to the address of the file allocation table, and then write to the second file allocation table address after writing, until the writing is completed; S04), file deletion process, when a file is deleted, the directory entry, file allocation table and data corresponding to the file are erased; S05) Design file system interface for file storage management; S06) Implement functional modules according to SKF specifications.

2. The method for storing smart password key files based on the SKF standard according to claim 1, characterized in that: In step S01), a root directory is created when the device is initialized, and when the device is recycled and reissued, the original operating system is deleted and the root directory is created again.

3. The intelligent password key file storage method based on the SKF standard according to claim 1 is characterized in that: In step S02), the minimum mapping unit is 64 bytes.

4. The method for storing smart password key files based on the SKF standard according to claim 1, characterized in that: Step S05) The file interface designed includes obtaining an empty directory entry, obtaining an empty file allocation table entry, obtaining the last record, obtaining the maximum record, and secure erasing.

5. The method for storing smart password key files based on the SKF standard according to claim 1, characterized in that: Step S06) The functional modules include a device management module, an access control module, an application management module, a container management module, a file management module, and a password service module.

6. The smart password key file storage method based on the SKF standard according to claim 1 or 5, characterized in that: The process of implementing the functional module according to SKF specifications is as follows: S61) Whether there is a request to implement the functional module, if not, return, if yes, proceed to the next step; S62), check whether the function module already exists, if it does, return, if not, proceed to the next step; S63), obtain an empty file allocation table; S64), write file allocation table; S65) Write directory entry; S66), write data to the data area pointed to by the acquired file allocation table.

7. The method for storing smart password key files based on the SKF standard according to claim 1, characterized in that: The NORFLASH space also includes a buffer, which is a reserved storage space used to buffer input or output data.