Real-time clock device, working method thereof and USB (universal serial bus) equipment

文档序号:1378151 发布日期:2020-08-14 浏览:42次 中文

阅读说明:本技术 一种实时时钟装置及其工作方法、usb设备 (Real-time clock device, working method thereof and USB (universal serial bus) equipment ) 是由 陆舟 于华章 于 2020-07-07 设计创作,主要内容包括:本发明公开了一种实时时钟装置及其工作方法、USB设备,属于计算机技术领域。本发明通过实时时钟装置检测接收上位装置发送的操作指令,根据操作指令确定操作类型,若操作类型为写入时间则按照认证方式对操作指令中认证数据进行认证,以确保实时时钟装置中的时间不被恶意篡改,从而可以保障提供的时钟是安全可信的。(The invention discloses a real-time clock device, a working method thereof and USB equipment, and belongs to the technical field of computers. The real-time clock device detects and receives the operation instruction sent by the upper device, determines the operation type according to the operation instruction, and authenticates the authentication data in the operation instruction according to the authentication mode if the operation type is write-in time so as to ensure that the time in the real-time clock device is not maliciously tampered, thereby ensuring that the provided clock is safe and credible.)

1. A method of operating a real time clock apparatus, the method comprising:

step S1, the real-time clock device is electrified and initialized;

step S2, the real-time clock device detects whether an operation instruction sent by an upper device is received, if so, the step S3 is executed, otherwise, the operation is ended;

step S3, the real-time clock device judges the operation type according to the operation instruction, if the operation type is the write-in time, the step S4 is executed; if the operation type is the read time, go to step S6;

step S4, the real-time clock device obtains the first authentication code and time data in the operation instruction, obtains key data stored by the real-time clock device, verifies the first authentication code according to the key data, if the verification is successful, the step S5 is executed, if the verification is failed, authentication failure information is sent to the upper device, and the step S2 is returned;

step S5, the real-time clock device sets the acquired time data as the starting time, starts timing according to the starting time, and returns to step S2;

and S6, the real-time clock device acquires the current timing time, organizes and obtains a read time response according to the current timing time, sends the read time response to the upper device, and returns to the step S2.

2. The method according to claim 1, wherein in step S4, the verifying the first authentication code according to the key data specifically includes: and the real-time clock device acquires an authentication factor, acquires a second authentication code according to the key data and the authentication factor, judges whether the second authentication code is consistent with the first authentication code, if so, executes the step S5, otherwise, sends authentication failure information to the upper device, and returns to the step S2.

3. The method according to claim 1, wherein in step S3, the method further comprises: if the operation type is a write time authentication request, the method further comprises:

the real-time clock device acquires key data stored by the real-time clock device, acquires an authentication factor, acquires a third authentication code according to the key data and the authentication factor, sends an authentication instruction including the third authentication code to the upper device, and returns to the step S2;

the verifying the first authentication code according to the key data specifically includes: and the real-time clock device obtains a fourth authentication code according to the key data and the third authentication code, judges whether the fourth authentication code is consistent with the first authentication code, if so, executes the step S5, otherwise, sends authentication failure information to the upper device, and returns to the step S2.

4. The method according to claim 1, wherein before executing the step S4, further comprising: and the real-time clock device determines the key type according to the operation instruction, judges whether the key data corresponding to the key type is empty, returns error information to the upper device if the key data corresponding to the key type is empty, returns to the step S2, and otherwise executes the step S4.

5. The method according to claim 1, wherein in step S5, before returning to step S2, the method further comprises: and the real-time clock device sets a corresponding value corresponding to the operation status byte according to the writing time result, and generates writing time response data according to the operation status byte and returns the writing time response data to the upper device.

6. The method according to claim 1, wherein the step S3 further comprises: if the operation type is updating the key, the method comprises the following steps:

step S7, the real-time clock device acquires a fifth authentication code in the operation instruction, acquires key data stored by the real-time clock device, verifies the fifth authentication code according to the key data stored by the real-time clock device, if the verification is successful, the step S8 is executed, if the verification is failed, authentication failure information is sent to the upper device, and the step S2 is returned;

step S8, the real-time clock device obtains the updated key data in the operation instruction, updates the key data stored therein to the updated key data, and returns to step S2.

7. The method according to claim 6, wherein in step S7, the verifying the fifth authentication code according to the key data stored in the step S7 specifically includes: and the real-time clock device acquires an authentication factor, acquires a sixth authentication code according to the key data stored in the real-time clock device and the authentication factor, judges whether the sixth authentication code is consistent with the fifth authentication code, if so, executes the step S8, otherwise, sends authentication failure information to the upper device, and returns to the step S2.

8. The method according to claim 6, wherein the step S3 further comprises: if the operation type is an update key authentication request, the method further comprises the following steps:

the real-time clock device acquires key data stored by the real-time clock device, acquires an authentication factor, acquires a seventh authentication code according to the key data and the authentication factor, sends an authentication instruction including the seventh authentication code to the upper device, and returns to the step S2;

the verifying the fifth authentication code according to the key data stored by the fifth authentication code specifically comprises: and the real-time clock device obtains an eighth authentication code according to the key data stored in the real-time clock device and the seventh authentication code, judges whether the eighth authentication code is consistent with the fifth authentication code, if so, executes the step S8, otherwise, sends authentication failure information to the upper device, and returns to the step S2.

9. The method according to claim 6, wherein before executing the step S7, further comprising: and the real-time clock device determines the key type according to the operation instruction, judges whether the key data corresponding to the key type is empty, returns error information to the upper device if the key data corresponding to the key type is empty, returns to the step S2, and otherwise executes the step S7.

10. The method according to claim 9, wherein the determining that the key data corresponding to the key category is empty comprises: and the real-time clock device acquires the updated key data in the operation instruction, stores the updated key data corresponding to the key type, returns an updated key response to the upper device, and returns to the step S2.

11. The method according to claim 6, wherein in step S8, before returning to step S2, the method further comprises: and the real-time clock device sets a value corresponding to the corresponding operation state byte according to the key updating result, generates key updating response data according to the operation state byte, and returns the key updating response data to the upper device.

12. The method according to claim 1, wherein before executing the step S6, further comprising:

step A1, the real-time clock device obtains the ninth authentication code in the operation instruction, obtains key data stored by the real-time clock device, verifies the ninth authentication code according to the key data, if the verification is successful, step S6 is executed, if the verification is failed, authentication failure information is sent to the upper device, and the step S2 is returned.

13. The method according to claim 12, wherein the verifying the ninth authentication code according to the key data specifically comprises: and the real-time clock device acquires an authentication factor, obtains a tenth authentication code according to the key data and the authentication factor, judges whether the tenth authentication code is consistent with the ninth authentication code, if so, executes the step S6, otherwise, sends authentication failure information to the upper device, and returns to the step S2.

14. The method according to claim 12, wherein the step S3 further comprises: if the operation type is a read time authentication request, the method further comprises the following steps:

the real-time clock device acquires key data stored by the real-time clock device, acquires an authentication factor, acquires an eleventh authentication code according to the key data and the authentication factor, sends an authentication instruction including the eleventh authentication code to the upper device, and returns to the step S2;

the verifying the ninth authentication code according to the key data specifically includes: and the real-time clock device obtains a twelfth authentication code according to the key data and the eleventh authentication code, judges whether the twelfth authentication code is consistent with the ninth authentication code, if so, executes the step S6, otherwise, sends authentication failure information to the upper device, and returns to the step S2.

15. The method of claim 12, wherein the step a1 is further performed before: and the real-time clock device determines the key type according to the operation instruction, judges whether the key data corresponding to the key type is empty, returns error information to the upper device if the key data corresponding to the key type is empty, returns to the step S2, and otherwise executes the step A1.

16. A real time clock apparatus, the apparatus comprising:

the initialization module is used for power-on initialization;

the detection module is used for detecting whether an operation instruction sent by the upper device is received or not;

the judging module is used for judging the operation type according to the operation instruction;

the first verification module is used for acquiring a first authentication code and time data in the operation instruction when the judgment module judges that the operation type is the writing time, acquiring key data stored by the first verification module, and verifying the first authentication code according to the key data;

the first verification module is further used for setting the acquired time data as an initial time when the first authentication code is verified successfully, and starting timing according to the initial time;

the acquisition module is used for acquiring the current timing time when the judgment module judges that the operation type is the reading time, and organizing the reading time according to the current timing time to obtain the reading time response;

the sending module is used for sending the reading time response organized by the obtaining module to the upper device;

the sending module is further configured to send authentication failure information to the upper device when the first authentication code fails to be verified.

17. The apparatus of claim 16, wherein the first authentication module comprises: the device comprises a first acquisition unit, a first judgment unit and a first sending unit;

the first obtaining unit is used for obtaining an authentication factor and obtaining a second authentication code according to the key data and the authentication factor;

the first judging unit is used for judging whether the second authentication code is consistent with the first authentication code;

the first sending unit is configured to send authentication failure information to the upper apparatus when the first determining unit determines that the second authentication code is inconsistent with the first authentication code.

18. The apparatus according to claim 16, wherein the obtaining module is further configured to, when the determining module determines that the operation type is a write time authentication request, obtain key data stored in the determining module, obtain an authentication factor, and obtain a third authentication code according to the key data and the authentication factor;

the sending module is further configured to send an authentication instruction including the third authentication code to the upper apparatus;

the first verification module is specifically configured to obtain a fourth authentication code according to the key data and the third authentication code, and determine whether the fourth authentication code is consistent with the first authentication code;

the sending module is further configured to send authentication failure information to the upper device when the first verification module determines that the fourth authentication code is inconsistent with the first authentication code.

19. The apparatus of claim 16, further comprising a first determining module;

the first determining module is configured to determine a key category according to the operation instruction, and determine whether key data corresponding to the key category is empty;

the sending module is further configured to return error information to the upper apparatus when the first determining module determines that the key data corresponding to the key category is empty.

20. The apparatus of claim 16, further comprising a first write module;

the first write-in module is used for setting a corresponding value of the corresponding operation state byte according to the write-in time result and generating write-in time response data according to the operation state byte;

the sending module is further configured to send the write-in time response data generated by the first writing module to the upper apparatus.

21. The apparatus of claim 16, further comprising a second authentication module;

the second verification module is used for acquiring a fifth authentication code in the operation instruction when the judgment module judges that the operation type is the updated key, acquiring key data stored in the second verification module, and verifying the fifth authentication code according to the key data;

the second verification module is further configured to obtain updated key data in the operation instruction when the verification of the fifth authentication code is successful, and replace the key data stored in the second verification module with the obtained updated key data;

the sending module is further configured to send authentication failure information to the upper device when the second verification module fails to verify the fifth authentication code.

22. The apparatus of claim 21, wherein the second authentication module comprises: the first obtaining unit, the first judging unit and the first sending unit are connected;

the second obtaining unit is used for obtaining an authentication factor and obtaining a sixth authentication code according to the key data and the authentication factor;

the second judging unit judges whether the sixth authentication code is consistent with the fifth authentication code;

the second sending unit is configured to send authentication failure information to the upper apparatus when the second determining unit determines that the sixth authentication code is not consistent with the fifth authentication code.

23. The apparatus according to claim 21, wherein the obtaining module is further configured to, when the determining module determines that the operation type is an update key authentication request, obtain key data stored in the determining module, obtain an authentication factor, and obtain a seventh authentication code according to the key data and the authentication factor;

the sending module is further configured to send an authentication instruction including the seventh authentication code to the upper apparatus;

the second verification module is specifically configured to obtain an eighth authentication code according to the key data and the seventh authentication code, and determine whether the eighth authentication code is consistent with the fifth authentication code;

the sending module is further configured to send authentication failure information to the upper device when the second verification module determines that the eighth authentication code is inconsistent with the fifth authentication code.

24. The apparatus of claim 21, further comprising a second determining module;

the second determining module is configured to determine a key type according to the operation instruction, and determine whether key data corresponding to the key type is empty;

the sending module is further configured to return error information to the upper apparatus when the second determining module determines that the key data corresponding to the key category is empty.

25. The apparatus of claim 24, further comprising an update module;

the updating module is configured to, when the judging module judges that the key data corresponding to the key category is empty, obtain updated key data in the operation instruction, and store the updated key data corresponding to the key category;

the sending module is further configured to return a key update response to the upper device.

26. The apparatus of claim 21, further comprising a second write module;

the second write-in module is used for setting a corresponding value of the corresponding operation state byte according to the key updating result and generating key updating response data according to the operation state byte;

the sending module is further configured to send the updated key response data generated by the second writing module to the upper device.

27. The apparatus of claim 16, further comprising a third authentication module;

the third verification module is used for acquiring a ninth authentication code in the operation instruction, acquiring key data stored in the third verification module and verifying the ninth authentication code according to the key data when the judgment module judges that the operation type is the reading time;

the sending module is further configured to send authentication failure information to the upper device when the third verification module fails to verify the ninth authentication code.

28. The apparatus of claim 27, wherein the third authentication module comprises: a third acquiring unit, a third judging unit and a third sending unit;

the third obtaining unit is configured to obtain an authentication factor, and obtain a tenth authentication code according to the key data and the authentication factor;

the third judging unit judges whether the tenth authentication code is consistent with the ninth authentication code;

the third sending unit is configured to send authentication failure information to the upper apparatus when the third determining unit determines that the tenth authentication code is not consistent with the ninth authentication code.

29. The apparatus according to claim 27, wherein the obtaining module is further configured to, when the determining module determines that the operation type is a read time authentication request, obtain key data stored in the determining module, obtain an authentication factor, and obtain an eleventh authentication code according to the key data and the authentication factor;

the sending module is further configured to send an authentication instruction including the eleventh authentication code to the upper apparatus;

the third verification module is specifically configured to obtain a twelfth authentication code according to the key data and the eleventh authentication code, and determine whether the twelfth authentication code is consistent with the ninth authentication code;

the sending module is further configured to send authentication failure information to the upper apparatus when the third verification module determines that the twelfth authentication code is inconsistent with the ninth authentication code.

30. The apparatus of claim 27, further comprising a third determining module;

the third determining module is configured to determine a key category according to the operation instruction, and determine whether key data corresponding to the key category is empty;

the sending module is further configured to return error information to the upper apparatus when the third determining module determines that the key data corresponding to the key category is empty.

31. A USB device, characterized in that it comprises an apparatus according to any one of claims 16 to 30.

Technical Field

The invention relates to the technical field of computers, in particular to a real-time clock device, a working method thereof and USB equipment.

Background

A Real Time Clock (RTC) is a standard configuration of electronic devices that is used to provide a Time reference for the electronic devices. In the prior art, a communication mode for interaction between a real-time clock and a master control in an electronic device includes: however, in some real-time clock application fields, for example, in order to reduce loss, a person maliciously modifies the current time of a real-time clock to achieve a malicious behavior of evading tax in order to reduce loss in tax invoicing work, so how to safely provide the running time of the real-time clock is an urgent problem to be solved.

Disclosure of Invention

In order to solve the problems in the prior art, embodiments of the present invention provide a real-time clock apparatus, a working method thereof, and a USB device, which can prevent tampering with real-time clock time.

The working method of the real-time clock device provided by the embodiment of the invention comprises the following steps:

step S1, the real-time clock device is electrified and initialized;

step S2, the real-time clock device detects whether an operation instruction sent by an upper device is received, if so, the step S3 is executed, otherwise, the operation is ended;

step S3, the real-time clock device judges the operation type according to the operation instruction, if the operation type is the write-in time, the step S4 is executed; if the operation type is the read time, go to step S6;

step S4, the real-time clock device obtains the first authentication code and time data in the operation instruction, obtains key data stored by the real-time clock device, verifies the first authentication code according to the key data, if the verification is successful, the step S5 is executed, if the verification is failed, authentication failure information is sent to the upper device, and the step S2 is returned;

step S5, the real-time clock device sets the acquired time data as the starting time, starts timing according to the starting time, and returns to step S2;

and S6, the real-time clock device acquires the current timing time, organizes and obtains a read time response according to the current timing time, sends the read time response to the upper device, and returns to the step S2.

The embodiment of the invention provides a real-time clock device, which comprises:

the initialization module is used for power-on initialization;

the detection module is used for detecting whether an operation instruction sent by the upper device is received or not;

the judging module is used for judging the operation type according to the operation instruction;

the first verification module is used for acquiring a first authentication code and time data in the operation instruction when the judgment module judges that the operation type is the writing time, acquiring key data stored by the first verification module, and verifying the first authentication code according to the key data;

the first verification module is further used for setting the acquired time data as an initial time when the first authentication code is verified successfully, and starting timing according to the initial time;

the acquisition module is used for acquiring the current timing time when the judgment module judges that the operation type is the reading time, and organizing the reading time according to the current timing time to obtain the reading time response;

the sending module is used for sending the reading time response organized by the obtaining module to the upper device;

the sending module is further configured to send authentication failure information to the upper device when the first authentication code fails to be verified. .

The USB equipment provided by the embodiment of the invention comprises the device provided by the invention.

The technical scheme provided by the embodiment of the invention has the beneficial effects that: the invention authenticates the write time operation request sent by the upper device through the real-time clock device according to the authentication mode to ensure that the time in the real-time clock device is not maliciously tampered, thereby ensuring that the provided clock is safe and credible.

Drawings

Fig. 1 is a flowchart of a method for operating a real-time clock device according to an embodiment of the present invention;

2-1, 2-2, and 2-3 are flowcharts of a method for operating a real-time clock apparatus according to a second embodiment of the present invention;

fig. 3 is a block diagram of a real-time clock apparatus according to a third embodiment of the present invention.

Detailed Description

In order to make the objects, technical solutions and advantages of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.

21页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:电子设备

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!