Summary of the invention
The technical issues that need to address of the present invention provide a kind of storage card identity identifying method and system thereof, utilize file system api to realize the authentication of cross-platform operation system, further can shield cache in the file system api.
Above-mentioned first technical matters of the present invention solves like this, and a kind of storage card identity identifying method is provided, and it is characterized in that, may further comprise the steps:
1.1) set up data interaction passage between host computer application software and the storage card by the special file on the call operation system file system API reading and writing memory card;
1.2) utilize the data interaction on the described data interaction passage and the authentication process of host computer application software and storage card end to finish authentication.
According to authentication method provided by the invention, described special file is defined as the authentication file; Described file system is arranged in the operating system that application software is moved; Described storage card is the customization storage card.
According to authentication method provided by the invention, this authentication method comprises that also the restriction of described storage card is without authentication or authenticate file in unsanctioned host computer accessible with application software other all or part storage cards except that described special file; Described restriction includes but not limited to forbid; The situation of described part is to provide the interior a part of space of storage card as the communal space.
According to authentication method provided by the invention, the size of described special file should be greater than file system cache capacity.
According to authentication method provided by the invention, described data interaction is a transmitting-receiving authentication Extended Protocol message, and this message is the self-defined structure message of arranging mutually.
According to authentication method provided by the invention, described authentication Extended Protocol message adopts to be encrypted and verification, is used to guarantee the integrality of the security and the transmission of data interaction.
According to authentication method provided by the invention, described authentication Extended Protocol message comprises heading and message body; Wherein:
Described message body comprises instruction name and message content; Described message content is random number, identifying algorithm result of calculation or comparative result.
Described heading comprises uplink and downlink synchronometer digital section; Described data interaction comprises initial synchronisation setting and follow-up synchronous comparison, counts and put described synchronometer digital section synchronously, is used to guarantee the integrality of session, the influence of shielding file system cache; Corresponding specific implementation method can multiplely change, and wherein: relatively two ends all must be carried out synchronously, and counting can carry out simultaneously at storage card end, host computer application software end or two ends synchronously, is that example describes to count synchronously at the storage card end below:
(1) application software
When receiving described authentication Extended Protocol uplink message, whether the value of the down-going synchronous counter at first should more described authentication Extended Protocol uplink message is changed to invalid value, and whether the value of the uplink synchronous counter in the described authentication Extended Protocol uplink message is consistent with the local Counter Value of application software, when two conditions satisfy simultaneously, represent that a complete file write order, file read command process all are stored card and receive and handle; Otherwise or the file read command hit by file system cache, or file write commands hit by file system cache, or the two is all hit by file system cache;
When storage card sends described authentication Extended Protocol downlink message, need to upgrade earlier the value (generally being) of the local counter of application software, then the value of local counter is inserted the down-going synchronous counter and the uplink synchronous counter field of described authentication Extended Protocol downlink message from adding one;
(2) storage card
When receiving described authentication Extended Protocol downlink message, if the down-going synchronous counter in the described authentication Extended Protocol downlink message is effective value with the value of uplink synchronous counter and equates, and local Counter Value greater than storage card, with the local Counter Value of the replacement of the down-going synchronous Counter Value in described authentication Extended Protocol downlink message storage card, then described authentication Extended Protocol downlink message is done subsequent treatment; Otherwise, just abandon this downlink message;
When application software sends described authentication Extended Protocol uplink message, it is invalid the down-going synchronous counter of described authentication Extended Protocol uplink message should to be changed to, and the local Counter Value of storage card is inserted the uplink synchronous counter field of described authentication Extended Protocol uplink message;
(3) handle
When the read write command to described special file is hit by file system cache, can differentiate by described uplink synchronous counter and down-going synchronous counter, and retransmit, till file write commands, file read command to described special file are stored card and really receive and do respective protocol and handle.
Wherein:
Described authentication Extended Protocol downlink message is carried by file write commands by application software and is handed down to storage card; Described authentication Extended Protocol uplink message is carried by the file read command of responding application software by storage card and issues application software, and application software is read by file, obtains the message from storage card.
The invalid value of described uplink synchronous counter and down-going synchronous counter is 0xFFFFFFFF; The local Counter Value of described application software is the counter value when sending authentication Extended Protocol downlink message last time, and initial value is 0; The local Counter Value of described storage card is the thus up counter value when sending authentication Extended Protocol uplink message last time, and initial value is 0.
According to authentication method provided by the invention, described operating system includes, but are not limited to WINDOWS, UNIX, LINUX, WINCE or UC/OSII system.
Above-mentioned another technical matters of the present invention solves like this, and a kind of storage card identity authorization system is provided, and specifically comprises:
The host computer of operation application software, the built-in upper computer end authentication process of this application software device, call operation system file system API transmitting-receiving is also handled authentication Extended Protocol message, finishes the authentication process;
The storage card of customization, preset authentication file and card end authentication process device, handle described authentication Extended Protocol message, finish the authentication process, and before by authentication, restriction host computer application software is to the visit of other all or part file except described authentication file in the storage card; Described restriction includes but not limited to forbid; The situation of described part is to provide the interior a part of space of storage card as the communal space.
According to Verification System provided by the invention, described authentication file is a special file.
Storage card identity identifying method provided by the invention and system thereof, have following effect: 1. guarantee to have only the application software by authentication could the storage card of customization be conducted interviews, the related application critical data that prevents to customize in the storage card is stolen by illegal upper computer software; 2. only utilize file system api just can set up reliable data interaction passage, finish the authentication process with storage card.Need not to pay close attention to the difference of bottom Storage Card Drivers, need not to be concerned about the difference of different operating system platform, reduced development workload, also greatly degree has reduced the difficulty of compatible debugging work, thereby effectively shortens exploitation and later stage debug time, has improved efficient.
Embodiment
At first, core concept of the present invention and points for attention are described:
(1) core concept
Usually, the common development interface that each operating system offers application software can only be file system layer API, and the expansion of agreement just can only consider that also framework is on the read-write operation to file;
(2) points for attention
But file system has cache usually, causes the file read-write order may not can to convert bottom layer driving sector read write command immediately to and is handed down to storage card.In this case, need a kind of effective method, the assurance application software is only utilized file system api, and the influence of shielding file system cache is set up reliable data interaction passage with storage card, finishes the authentication process.
In second step, the crucial concrete implementation step of the present invention is described:
(1) utilize file system api to set up the data channel of authentication Extended Protocol message
As shown in Figure 1, comprise host computer 1 and customization storage card 2, wherein:
For host computer 1: the bottom service comprises operating system, cache management, Storage Card Drivers, and this part is for upper layer application, and its specific implementation is that each is discrepant, also is sightless; Common interface comprises file system, and this part is the difference with the difference of bottom service not; Upper layer application can comprise types of applications software;
For customization storage card 2, the bottom service comprises Storage Card Drivers; Upper layer application comprises authentication software;
Utilize this common interface of file system like this, can shield the difference of bottom service, set up the data channel of the authentication Extended Protocol message of spanning operation system platform.
(2) data interaction
As shown in Figure 2, the master data exchange method is as follows:
1) application software is when carrying out write operation to special authentication file, need to upgrade earlier the local Counter Value (for example: add 1) of upper computer end, and make the local Counter Value of upper computer end after the down-going synchronous Counter Value of descending authentication Extended Protocol message and uplink synchronous Counter Value equal to upgrade, after assembling descending authentication Extended Protocol message, the input parameter that descending authentication Extended Protocol message is operated as " writing " is handed down to the customization storage card;
2) the customization storage card is when receiving " writing " operation (being converted into the sector by the operating system bottom layer driving writes), the local counter that needs to customize storage card is earlier compared with down-going synchronous counter and uplink synchronous counter in the descending authentication Extended Protocol message, have only down-going synchronous Counter Value and uplink synchronous Counter Value in the descending authentication Extended Protocol message to be effective value and to equate, and all greater than the local Counter Value that customizes storage card, just then handle descending authentication Extended Protocol message, and replace the local counter of customization storage card with the down-going synchronous Counter Value in the descending authentication Extended Protocol message; Otherwise think that this descending authentication Extended Protocol message was once hit by the cache of file system, abandoned this descending authentication Extended Protocol message.
3) application software is carried out the authentication internal logic and is handled, and calls file system api to the read operation of issuing the documents of customization storage card.
4) the customization storage card is when responding " reading " operation (being converted into the sector by the operating system bottom layer driving reads), it is invalid to need earlier the down-going synchronous counter in the up authentication Extended Protocol message to be changed to, and make uplink synchronous Counter Value in the up authentication Extended Protocol message equal to customize the local Counter Value of storage card, after assembling up authentication Extended Protocol message, up authentication Extended Protocol message is passed to application software as " reading " operation return data;
5) application software is when the special authentication file read operation of acquisition is responded, whether the value of the down-going synchronous counter at first should more up authentication Extended Protocol message is invalid, and whether the value of uplink synchronous counter is consistent with the local counter of upper computer end, represents when two conditions satisfy simultaneously that a complete read-write process all is customized storage card and receives and handle; Otherwise or read operation hit by file system Cache, or write operation hit by file system Cache, or the two is all hit by file system Cache, needs this moment to adopt certain retransmission policy to retransmit.
6) when application software has arrived end of file to the read-write of special authentication file, will restart read-write from the section start of this special authentication file.
7) for reducing the probability that the file write operation is hit by file system Cache, special authentication file is carried out the size of write operation should be greater than 2K or 4K at every turn.
8) repeating step 1 repeatedly)-5), can utilize file system api, the influence of shielding file system cache is set up reliable data interaction passage at application software and customization storage card, finishes the authentication process.
At last, describe the present invention in detail with concrete an application " verification process of navigation application software and customization SD card ":
(1) Ding Zhi SD card need be pre-created special authentication file, and this document size should be greater than the Cache size of file system, such as desirable 256K.Because being customization SD card, creates in advance by special authentication file, card end itself is the Sector Range that can know this document place, thereby can effectively control the visit of upper computer end to the card end, except the sector in the limited range, its sector of customization SD khaki all can not be accessed not by authentication the time.Thereby can realize: special authentication file can not be deleted, can not be formatted, can not arbitrarily be rewritten, and only be used for navigation application software and the authentication that customizes the SD card; By the authentication before, this special authentication file be unique can be by the file of upper computer end file system access, other file can not be accessed.
(2) form of up-downgoing authentication Extended Protocol message comprises heading, data volume and proof test value.Wherein heading comprises down-going synchronous counter, uplink synchronous counter or the like.Data volume can comprise instruction name, customization SD card sequence number, computational data and result or the like, for data security, preferably adopts cryptographic algorithm to encrypt.Proof test value is the proof test value to data volume, to guarantee the correctness of data transmission.
Convenient for following description, the instruction name is done following simple agreement:
1) instruction name: 0x30, presentation directives is called " generation random number ";
2) instruction name: 0x50, presentation directives is called " execution identifying algorithm ";
3) instruction name: 0x70, presentation directives is called " loopback comparative result ";
(3) ideally, customization SD card as shown in Figure 3, specifically comprises the identification step of navigation application software:
1) upper computer end is at first initiated, and the local Counter Value of navigation application software is initially set to 0x00000000, to the read operation of issuing the documents of customization SD card.
2) when init state, the local Counter Value of customization SD card is 0x00000000, when receiving the file read operation, then transfers " producing the random number state " to from " init state ", produces a random number; It is invalid making the down-going synchronous Counter Value in the up authentication Extended Protocol message, it is 0xFFFFFFFF that the down-going synchronous Counter Value promptly is set, simultaneously, make the uplink synchronous Counter Value equal to customize the local Counter Value of SD card, the instruction in the up authentication Extended Protocol message is called 0x30; With down-going synchronous Counter Value, uplink synchronous Counter Value, instruction name, card sequence number, random number etc. are inserted respective field, and data volume encrypted, produces form up authentication Extended Protocol message behind the proof test value, as the response of file read operation.
3) navigation application software is received the response of file read operation, whether the uplink synchronous Counter Value whether the down-going synchronous Counter Value in the at first more up authentication Extended Protocol message is changed in invalid (0xFFFFFFFF) and the up authentication Extended Protocol message equals the local Counter Value of navigation application software, does not satisfy condition and then abandons this message; Satisfied then carry out subsequent treatment: the local Counter Value of navigation application software adds 1, then up authentication Extended Protocol message data body is carried out verification and deciphering after, carry out identifying algorithm with the random number of receiving; Then make the value of down-going synchronous counter in the descending authentication Extended Protocol message and uplink synchronous counter be equal to the local Counter Value of navigation application software, make the instruction 0x50 by name in the descending authentication Extended Protocol message, with down-going synchronous Counter Value, uplink synchronous Counter Value, instruction name, carry out the authentication calculations value that obtains behind the identifying algorithm etc. and insert respective field, and data volume encrypted, produces form descending authentication Extended Protocol message behind the proof test value, send the file write operation to customization SD card.
When 4) customization SD card is received the file write operation, whether the down-going synchronous Counter Value in the at first more descending authentication Extended Protocol message equals the uplink synchronous Counter Value, and whether it all is effective value (promptly being not equal to 0xFFFFFFFF), and greater than the local Counter Value of customization SD card, then do not abandon this message if do not satisfy condition, customization SD card state, local counter do not change; Then carry out subsequent treatment if satisfy condition: the local Counter Value that upgrades customization SD card with the down-going synchronous Counter Value in the descending authentication Extended Protocol message of receiving, it is the local Counter Value of SD card=down-going synchronous Counter Value, then descending authentication Extended Protocol message data body is carried out verification, after the deciphering, compare with authentication calculations value of receiving and the local calculated value of customization SD card, customization SD card is transferred to " relatively execution algorithm result phase " by " producing the random number state ", authenticate if comparative result is identical and to pass through, the corresponding zone bit of set, comparative result then authentification failure inequality, corresponding zone bit is constant.
5) navigation application software is after distributing the descending authentication Extended Protocol message that comprises " execution identifying algorithm " instruction name, to the read operation of issuing the documents of customization SD card.
When 6) customization SD is stuck in " relatively execution algorithm result phase ", receive the file read operation, then transfer " loopback comparative result state " to from " relatively execution algorithm result phase ", it is invalid making the down-going synchronous Counter Value in the up authentication Extended Protocol message, even the down-going synchronous Counter Value is 0xFFFFFFFF, make the uplink synchronous Counter Value equal to customize the local Counter Value of SD card, make the instruction 0x70 by name in the up authentication Extended Protocol message; Whether pass through from the corresponding marker bit authentication query, fill in comparative result; With down-going synchronous Counter Value, uplink synchronous Counter Value, instruction name, comparative result etc. are inserted the respective field of up authentication Extended Protocol message, and data volume encrypted, produces form up authentication Extended Protocol message behind the proof test value, as the response of file read operation.
7) navigation application software is received the response of file read operation, whether the down-going synchronous Counter Value in the at first more up authentication Extended Protocol message is changed to invalid (0xFFFFFFFF), and whether the uplink synchronous Counter Value equals local Counter Value, if not then abandon this message or retransmit; If then carry out subsequent treatment: local Counter Value adds 1, after then up authentication Extended Protocol message data body being carried out verification and deciphering, checking whether the instruction name in the up authentication Extended Protocol message is 0x70, is then whether to transfer " state is passed through in authentication " to the comparative result decision host computer of receiving; Otherwise abandon this message.
Under the non-ideality, then need to utilize uplink synchronous Counter Value and down-going synchronous Counter Value in the up-downgoing authentication Extended Protocol message, and the logical relation of each instruction name shields the influence of upper computer end file system Cache in the verification process, and is specific as follows:
Navigation application software:
For step 3, if the down-going synchronous Counter Value in the up authentication Extended Protocol message is changed to invalid (0xFFFFFFFF), and the uplink synchronous Counter Value equals the local Counter Value of navigation application software, two conditions satisfy simultaneously represents that then the file read operation is customized the SD card and receives and handle, otherwise abandon this up authentication Extended Protocol message, repeating step 1 is retransmitted.
For step 7, if the down-going synchronous Counter Value in the up authentication Extended Protocol message is changed to invalid (0xFFFFFFFF), and the uplink synchronous Counter Value equals the local Counter Value of navigation application software, two conditions satisfy simultaneously represent then that a complete file is write, the file read procedure all is customized the SD card and receives and handle; Otherwise or read operation is hit by file system Cache, or write operation is hit by file system Cache, or the two is all hit by file system Cache: if a) the down-going synchronous Counter Value is changed to invalid (0xFFFFFFFF), but the uplink synchronous Counter Value is less than the local Counter Value of navigation application software, represent that then the file write operation that sends in the step 3 is hit by the Cache of file system, the file read operation of step 5 is customized the SD card and receives and handle, after then using the random number of carrying in the up authentication Extended Protocol message and re-executing identifying algorithm, the file write operation in the retransmission steps 3; In order to reduce the probability that the file write operation is hit by Cache, need to adjust and write the length of content, as be adjusted to 2K, 4K size.B) if the down-going synchronous Counter Value is not equal to invalid value (0xFFFFFFFF), the read operation of expression file is hit by Cache.Need this moment to adopt retransmission policy to retransmit.
Customization SD card:
For step 4, if the down-going synchronous Counter Value in the descending authentication Extended Protocol message is smaller or equal to the local Counter Value of customization SD card, expression was once hit by the Cache of file system by the file write operation that navigation application software sends, retransmit the new file write operation in back and be customized the SD card and receive and handled, then directly abandon this message;
For step 6, if being in " producing the random number state ", customization SD card receives the file read operation, represent that then the file write operation that step 3 sends has been hit by the Cache of file system, the Cache that file system is then walked around in the file read operation that step 5 sent has sent to customization SD card earlier, customization SD card then produces random number, the response of the file read operation in the retransmission steps 2 again.
By such processing, navigation application software only utilizes file system api just can set up reliable data interaction passage with customization SD card, finish the authentication process, thereby guaranteed only to have those application software could the geography information in the customization SD card be conducted interviews, effectively prevented illegal software stealing geographic information data in the customization SD card by authentication.