US 11,809,578 B1
Method, system and apparatus for data encryption
Xiaojun Ding, Shanghai (CN); and Zhikai Chen, Shanghai (CN)
Assigned to Beijing Tenafe Electronic Technology Co., Ltd.
Filed by Beijing Tenafe Electronic Technology Co., Ltd., Beijing (CN)
Filed on Dec. 22, 2022, as Appl. No. 18/087,378.
Claims priority of application No. 202210961588.1 (CN), filed on Aug. 11, 2022.
Int. Cl. G06F 21/60 (2013.01); G06F 21/78 (2013.01)
CPC G06F 21/602 (2013.01) [G06F 21/78 (2013.01)] 14 Claims
OG exemplary drawing
 
1. A method, comprising:
detecting whether a next-to-last raw data block in a raw data segment has been written into an input buffer;
reading the next-to-last raw data block from the input buffer for encryption immediately after a current raw data block is read from the input buffer for encryption, in response to detecting that the next-to-last raw data block has been written into the input buffer, wherein reading the next-to-last raw data block comprises:
calculating a sequence number difference between a sequence number of the next-to-last raw data block and a sequence number of the current raw data block; and
reading the next-to-last raw data block from the input buffer, in response to the sequence number difference being equal to or less than a number of operation rounds required for encryption;
continuing to read a subsequent raw data block after the current raw data block from the input buffer for encryption, after the next-to-last raw data block is read from the input buffer for encryption; and
encrypting, using Advanced Encryption Standard (AES) processing and a CipherText Stealing (XTS) working mode, a last raw data block in the raw data segment by providing an intermediate encrypted data block, wherein the intermediate encrypted data block is obtained by encrypting the next-to-last raw data block, and the last raw data block is read from the input buffer.