Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the invention, the technical scheme in the embodiment of the invention is clearly and completely described, obviously, described embodiment only is the present invention's part embodiment, rather than whole embodiment.Based on the embodiment among the present invention, those of ordinary skills belong to the scope of protection of the invention not making the every other embodiment that is obtained under the creative work prerequisite.
For when guaranteeing data security, improve the performance of smart card, the embodiment of the invention provides a kind of data processing method of smart card, as shown in Figure 1, comprising:
101,, determine effective word backup area and invalid character backup areas according to the backup area mark;
For example, be provided with two word backed item backup areas 0 and 1 in advance, these two word backed item backup areas are used for alternately backing up.And it is effective in order to identify the content of storing in current which word backed item backup area, a mark can be set in internal memory, for example, the setting mark value is that the content of storing in the directive backed item backup area 0 in 0 o'clock is effective, and mark value is that the content of storing in the directive backed item backup area 1 in 1 o'clock is effective.In embodiments of the present invention, this mark is called the backup area mark.With memory contents is that effective word backed item backup area is called the effective word backup area, is that invalid word backed item backup area is called invalid character backup areas with memory contents.
For example, suppose that current backup area mark value is 0, determine that then word backed item backup area 0 is effective backup area, word backed item backup area 1 is invalid backup area.
102, obtain the word backed item data of storing in the described effective word backup area, as the first word backed item data;
For example, the word backed item data in the word backed item backup area 0 are read in internal memory, with these word backed item data as the first word backed item data.
Wherein, word backed item data have certain storage format, and it is used for the information such as address, data, length and proof test value in record modification district.In embodiments of the present invention, revise the district and be meant that need carry out byte upgrades the zone of revising.
In the prior art, the storage organization of word backed item data as shown in Figure 2, when writing word backed item data successively according to this storage organization is unified, the interruption if write operation meets accident, though significant notation might appear comprising in these word backed item data in the backup area, but the infull situation of other data except that significant notation, these word backed item data can be considered to back up successfully effective because of comprising significant notation.Therefore, for avoiding above-mentioned situation, the data of wiping this backup area earlier write this backup area with other data except that significant notation, and then wipe the data of this backup area usually, and significant notation and above-mentioned other data are together write this backup area.
In embodiments of the present invention, in order to reduce the erasable number of times in the data backup process, the storage organization of word backed item data can be as shown in Figure 3, according to the unified word backed item data that write successively of this storage organization, promptly unified writing successively revised the data length of distinguishing in the word backup area, the data in described modification district, the address in described modification district, the data check in described modification district and and the significant notation of the word backed item in described modification district.Therefore, have only other data except that significant notation of word backed item data all to write this backup area, these word backed item data in the backup area just may comprise significant notation, have guaranteed the backup accuracy of word backed item data, have also reduced erasable number of times simultaneously.
103, according to described first word backed item data and the data from revise the district, obtained, obtain the second word backed item data;
For example, suppose to comprise in the first word backed item data the 1st~n the word backed item data of revising the district, can revise district's reading of data from n+1, obtain the corresponding word backed item data in this modification district according to the data that read, the first word backed item data and this are waited to revise the word backed item data organization integration in district, obtain the second word backed item data.
104, in described invalid character backup areas, write the described second word backed item data;
For example, in word backed item backup area 1, write the described second word backed item data.
105, wipe data in the described effective word backup area;
For example, wipe data in the word backed item backup area 0.
In addition, do not wipe clean problem for preventing in the erase operation process because of outage, can also be before execution in step 104, detection need write the backup area of the described second word backed item data, for example whether word backed item backup area 0 is wiped totally, clean if judgement is not wiped, and then this backup area is carried out an obliterated data operation, otherwise, directly carry out write operation.
106, the backup area that will write the described second word backed item data is as effective backup area, and the backup area of the described first word backed item data of storage as invalid backup area, is upgraded described backup area mark.
For example, the backup area mark value being updated to 1, is word backed item backup area 1 with indication effective backup area at this moment, and the invalid backup area of this moment is a word backed item backup area 0.
After cutting off the power supply, the backup area mark that is placed on internal memory can be lost, and at this moment need rejudge effective backup area behind electrification reset, and reset the backup area mark.Judge the effective word backup area, the method that word backup area mark is set is specifically as follows:
A, can judge preferentially whether word backup area 0 is effective.Wherein, the effective determination methods of word backup area is: it is correct all to satisfy significant notation as if all word backed item data in the word backup area, and proof test value is through verifying that then this word backup area is effective.
If b judges that word backup area 0 is invalid, the data of wiping word backup area 0 judge then whether word backup area 1 is effective.If judge that word backup area 1 is effective, backup area be set be labeled as 1; If judge that word backup area 1 is invalid, the data of wiping word backup area 1 are provided with backup area and are labeled as 1.
C if judge that word backup area 0 is effective, then judges word backup area 1.If judge that word backup area 1 is effective, then selecting the many backup areas of backed item is effective backup area.If judge that word backup area 1 is invalid, the data of wiping word backup area 1 are provided with backup area and are labeled as 0.
Data in all modifications district all back up, when promptly the word backed item data in all modifications district have all write in the effective word backup area, the data of revising in the district are upgraded.As shown in Figure 4, upgrading the method for revising the data of distinguishing can specifically comprise:
When 201, in the effective word backup area, having write the word backed item data in all modifications district, obtain the data of revising storage in the page or leaf, as the described raw data of revising page or leaf;
For example, with the 1st page or leaf of revising under the district, promptly the 1st all data reads of revising to store in the modification page or leaf in district are in internal memory, with these data of reading raw data as this modifications page.
202, obtain page backed item data according to the described raw data of revising page or leaf, described page or leaf backed item data comprise the described data check of revising page or leaf and;
Wherein, page or leaf backed item data can also comprise the described data length of revising page or leaf, the address of described modification page or leaf, the exclusive or check of described modification page or leaf and and the significant notation of described page or leaf backed item.
Describedly revise the data check of page or leaf and can calculate acquisition by following four algorithms at least: the summation that adds up that the described data of revising page or leaf are brought into; Described the 4th of each byte revising the data of page or leaf brought into the summation that adds up of position; With 13 pairs of described data deliverys of revising page or leaf, the delivery result is brought into the summation that adds up of position; With 17 pairs of described even address data deliverys of revising page or leaf,, the delivery result is brought into the summation that adds up of position with 97 pairs of described odd address data deliverys of revising page or leaf.
203, described page or leaf backed item data are write described page or leaf backed item backup area, the described raw data of revising page or leaf is write described exchange page or leaf;
Wherein, revise page or leaf and be meant the page or leaf of revising under distinguishing, and the exchange page or leaf is used for the old data of memory modify page or leaf, and page or leaf backed item backup area is used for memory page backed item data.
In embodiments of the present invention, for supporting the erasable chip of big page or leaf, can be in different backup areas with word backed item data and page or leaf backed item data storage, and will exchange page or leaf and a page or leaf backed item backup area be incorporated into one carry out in greatly page erasable.Therefore, can wipe or write exchange page or leaf and the uniform data in page backed item backup area, this just requires page backed item backup area effective with data or while in the exchange page or leaf, or all invalid.
In addition, the storage organization of this page backed item data can be as shown in Figure 5, according to the unified page backed item data that write successively of this storage organization, promptly unification writes the described data length of revising page or leaf successively in page or leaf backed item backup area, described address of revising page or leaf, the described exclusive or check of revising page or leaf and, the described data check of revising page or leaf and and the significant notation of described page or leaf backed item.Therefore, have only other data except that significant notation of page backed item data all to write this page backed item backup area, these word backed item data in this page backed item backup area just may comprise significant notation, have guaranteed the accuracy of page or leaf backed item data backup.
Can after described page or leaf backed item data write described page or leaf backed item backup area, the described raw data of revising page or leaf be write described exchange page or leaf.And, after power interruption recovering, can also describedly revise the data check of page or leaf and read in the internal memory what store in the data of storage in the described exchange page or leaf and the described page or leaf backed item backup area, with the data check that reads and as first data check and.Then, according to the data that from described exchange page or leaf, read carry out data check and computing, the data check that calculates and, be described second data check of revising page or leaf and.To this first data check and and second data check and comparing, if this two data verifications and equate that then the data in exchange page or leaf and the page or leaf backed item backup area are simultaneously effectively; Otherwise the data in exchange page or leaf and the page or leaf backed item backup area are simultaneously invalid.When the data in definite exchange page or leaf and page or leaf backed item backup area are all effective, recover the described data of revising in the page or leaf.
Therefore, if in the process of the raw data that writes described modification page or leaf, cut off the power supply, when power interruption recovering, the situation that the described raw data of revising page or leaf does not all write the exchange page or leaf may appear, in this case, second data check that obtains according to the data that from described exchange page or leaf, read and, with first data check that writes down in the page or leaf backed item data and unequal, data in this moment exchange page or leaf and the page or leaf backed item backup area are simultaneously invalid, thereby can guarantee to revise the accuracy of the raw data backup of page or leaf.
204, wipe the described data of revising in the page or leaf;
205,, obtain the described corresponding more new data of page or leaf of revising according to the raw data of described exchange page or leaf and the more new data in modification district;
Specifically, can in internal memory, revise the more new data that the corresponding legacy data in district is modified as this modification district in the raw data with described modification page or leaf, obtain the corresponding more new data of described modification page or leaf.
206, the described corresponding more new data of page or leaf of revising is write described modification page or leaf.
207, after upgrading successfully, unified data of wiping in exchange page or leaf and the page or leaf backed item backup area.
In addition, if in unified process of wiping the data in exchange page or leaf and the page or leaf backed item backup area, cut off the power supply, when power interruption recovering, data might occur exchanging in page or leaf and page backed item backup area and not wipe clean problem.Therefore, described page or leaf backed item data can also write described page or leaf backed item backup area, and the described raw data of revising page or leaf is being write before the described exchange page or leaf, judge whether data wipe totally in exchange page or leaf and page backed item backup area.If judge and not wipe totally that then unified data of wiping in exchange page or leaf and the page or leaf backed item backup area write described page or leaf backed item backup area with described page or leaf backed item data then, the described raw data of revising page or leaf is write described exchange page.
The data processing method of the smart card that present embodiment provides, after determining effective word backup area and invalid character backup areas according to the backup area mark, obtain new word backed item data according to word backed item data of from the effective word backup area, obtaining and the data from revise the district, obtained, and, the word backed item data that this is new write in the invalid character backup areas that data have been wiped free of, upgrade the backup area mark simultaneously.Therefore, if in word backed item data write the process of backup area, cut off the power supply, then can directly obtain the word backed item data that backed up from effective backup area, and the backed item data that do not need to revise the district from first begin to back up again, and adopt this alternately back mechanism can also reduce erasable number of times to backup area, and then when guaranteeing data security, improved the performance of smart card.
With said method accordingly, the embodiment of the invention also provides a kind of data processing equipment of smart card, as shown in Figure 6, comprising:
Enabledisable determining unit 301 is used for determining effective word backup area and invalid character backup areas according to the backup area mark;
Word backup acquiring unit 302 is used for obtaining the word backed item data that effective word backup areas that described enabledisable determining unit 301 determines are stored, with the word backed item data obtained as the first word backed item data; And, obtain the second word backed item data according to described first word backed item data and the data from revise the district, obtained;
Word backup units 303 is used for writing the second word backed item data that described word backup acquiring unit 302 obtains to described invalid character backup areas; Wipe the data in the described effective word backup area, upgrade described backup area mark.
Further, described word backed item data comprise the data length of revising the district, the data in described modification district, the address in described modification district, the data check in described modification district and and the significant notation of the word backed item in described modification district.Described word backup units 303 can also specifically comprise:
The word backup writes subelement, be used for the unified data length of revising the district that writes successively of invalid character backup areas after being wiped the subelement obliterated data by described invalid data, the data in described modification district, the address in described modification district, the data check in described modification district and and the significant notation of the word backed item in described modification district;
Invalid data is wiped subelement, is used for wiping the data of the backup area of storing the described first word backed item data;
The flag update subelement, be used for will write the backup area of the described second word backed item data as effective backup area, the backup area of the described first word backed item data of storage as invalid backup area, is upgraded described backup area mark.
Further, the data processing equipment of described smart card also comprises:
Page or leaf backup acquiring unit is used for when the effective word backup area has write the word backed item data in all modifications district, obtains the data of revising storage in the page or leaf, as the described raw data of revising page or leaf; And according to obtaining page backed item data from the described data of obtaining the page or leaf of revising, described page or leaf backed item data comprise the described data check of revising page or leaf and;
The page or leaf backup units is used for the page or leaf backed item data that described page or leaf backup acquiring unit obtains are write described page or leaf backed item backup area, and described page or leaf backup acquiring unit is write described exchange page or leaf from the described data of obtaining the page or leaf of revising;
Data updating unit, be used for after the data of wiping described modification page or leaf, revise the raw data of page or leaf and revise the more new data in district according to described, obtain the described corresponding more new data of page or leaf of revising, and after the corresponding more new data of described modification page or leaf writes described modification page or leaf, the unified data that exchange in page or leaf and the page or leaf backed item backup area of wiping.
Data recovery unit is used for when power interruption recovering, according to exchange page or leaf and page or leaf backup area data, recovers the described raw data of revising in the page or leaf.
Further, described data recovery unit can specifically comprise:
First verification and obtain subelement is used for when power interruption recovering, obtain store in the data of storage in the described exchange page or leaf and the described page or leaf backed item backup area described revise page or leaf data check and, with described data check and as first data check and;
Second verification and obtain subelement is used for the data obtained according to from described exchange page or leaf, obtain described second data check of revising page or leaf and;
The effective judgment sub-unit of page or leaf backup, be used for according to described first verification and obtain first data check that subelement obtains and and described second verification and obtain second data check that subelement obtains and, determine whether described exchange page and described page of backed item backup area effective;
Revise page or leaf and recover a subelement, be used at described exchange page or leaf and described page or leaf backed item backup area all effectively the time, recover the data in the described modification page.
Further, described page or leaf backed item data also comprise the described data length of revising page or leaf, the address of described modification page or leaf, the exclusive or check of described modification page or leaf and and the significant notation of described page or leaf backed item.Described page or leaf backup units can specifically comprise:
Revise page or leaf and write subelement, be used for and will revise data that page or leaf obtains and write described exchange page from described;
The page or leaf backup writes subelement, be used for to the unified data length that writes described modification page or leaf successively of described page or leaf backed item backup area, described address of revising page or leaf, the exclusive or check of described modification page or leaf and, the described data check of revising page or leaf and and the significant notation of described page or leaf backed item.
The data processing equipment of the smart card that the embodiment of the invention provides, after determining effective word backup area and invalid character backup areas according to the backup area mark, obtain new word backed item data according to word backed item data of from the effective word backup area, obtaining and the data from revise the district, obtained, and, the word backed item data that this is new write in the invalid character backup areas that data have been wiped free of, upgrade the backup area mark simultaneously.Therefore, if in word backed item data write the process of backup area, cut off the power supply, then can directly obtain the word backed item data that backed up from effective backup area, and the backed item data that do not need to revise the district from first begin to back up again, and adopt this alternately back mechanism can also reduce erasable number of times to backup area, and then when guaranteeing data security, improved the performance of smart card.
And,, make page backed item backup area integrated with the validity of the data of exchange page or leaf by increasing to revising the page data verification.When improving security, reduce one time erase operation.
In addition, by in word backed item data or page or leaf backed item data writing process, significant notation is placed at last writes, thereby in the backup accuracy that guarantees word backed item data or page or leaf backed item data, also reduced erasable number of times.
One of ordinary skill in the art will appreciate that all or part of flow process that realizes in the foregoing description method, be to instruct relevant hardware to finish by computer program, described program can be stored in the computer read/write memory medium, this program can comprise the flow process as the embodiment of above-mentioned each side method when carrying out.Wherein, described storage medium can be magnetic disc, CD, read-only storage memory body (Read-Only Memory, ROM) or at random store memory body (Random Access Memory, RAM) etc.
The above; only be the specific embodiment of the present invention, but protection scope of the present invention is not limited thereto, anyly is familiar with those skilled in the art in the technical scope that the present invention discloses; can expect easily changing or replacing, all should be encompassed within protection scope of the present invention.Therefore, protection scope of the present invention should be as the criterion with the protection domain of claim.