This invention relates in general to memory systems, and in particular to a memory system with in stream data encryption/decryption.
The mobile device market is developing in the direction of including content storage so as to increase the average revenue by generating more data exchanges. This means that the content has to be protected when stored on a mobile device.
Portable storage devices are in commercial use for many years. They carry data from one computing device to another or to store back-up data. More sophisticated portable storage devices, such as portable hard disc drives, portable flash memory disks and flash memory cards, include a microprocessor for controlling the storage management.
In order to protect the contents stored in the portable storage devices, the data stored is typically encrypted and only authorized users are allowed to decrypt the data.
In portable storage devices with cryptographic capability that had been proposed, the microprocessor for storage management is also involved intimately in the encryption and decryption processes. Such a system is described, for example, in U.S. Pat. No. 6,457,126. When this is the case, the throughput and performance of the storage device can be seriously affected. It is therefore desirable to provide an improved local storage device where such difficulties are alleviated.
One aspect of the invention is based on the recognition that the throughput of the memory system can be improved where data in the data stream is cryptographically processed by a circuit without involving intimately any controller or microprocessor when data in the data stream is sent to or fetched from non-volatile memory cells. In one embodiment, the controller is only involved in setting the parameters used in the cryptographic process(es) but not in the processes. In one implementation of this embodiment, the parameters are set by means of a configuration register.
The memory cells preferably comprise flash memory cells. Also preferably, the memory cells, the circuit used for encrypting and/or decrypting data and a controller controlling the cells and the circuit are placed within and encapsulated in a physical body such as a memory card or stick.
Data may be written to or read from the memory cells in pages. In many conventional cryptographic algorithms used for encryption and decryption operates on units of data typically smaller than the page. Thus other aspects of the invention are based on recognition that the cryptographic circuit cryptographically processes one or more pages of data in the data stream being read or written, and that the data stream may be controlled so that it has a selected data source among a plurality of sources and a selected destination among a plurality of destinations, all without involving the controller.
According to other aspects of the invention, the cryptographic circuit may be configured to enable the selection of one or more cryptographic algorithms among a plurality of algorithms to encryption and/or decryption without involving a controller or microprocessor. The circuit may also be configured so that the circuit processes data in the data stream cryptographically in multiple successive stages without involvement of the controller after the configuring. The cryptographic processes in multiple successive stages may employ more than one key and may use more than one type of cryptographic processes without involvement of the controller after the configuring.
For certain applications, it may be desirable for the memory system to handle more than one data stream. In such event, the controller controls the memory cells and the circuit so that data in different data streams are processed cryptographically in an interleaved manner. Preferably the various parameters for cryptographic processing each data stream are stored when processing of the data stream is interrupted during the interleaving, so that when processing of such data stream is resumed, the parameters can be restored to continue the cryptographic processing. In one implementation of this feature, a security configuration record is created at the start of write operations to set the various parameters for cryptographic processing and these parameters are stored at the end of the session. This record is then retrieved from memory when a read operation starts, and discarded at the end of the operation. Such record is also stored when the data stream is temporarily interrupted to allow processing of another data stream, and retrieved when the processing of the original data stream is resumed.
The above described aspects of the invention may be used individually or in any combination thereof.
For convenience in description, identical components are labeled by the same numbers in this application.
An example memory system in which the various aspects of the present invention may be implemented is illustrated by the block diagram of
The buffer management unit 14 includes a host direct memory access (HDMA) 32, a flash direct memory access (FDMA) controller 34, an arbiter 36, a buffer random access memory (BRAM) 38 and a crypto-engine 40. The arbiter 36 is a shared bus arbiter so that only one master or initiator (which can be HDMA 32, FDMA 34 or CPU 12) can be active at any time and the slave or target is BRAM 38. The arbiter is responsible for channeling the appropriate initiator request to the BRAM 38. The HDMA 32 and FDMA 34 are responsible for data transported between the HIM 16, FIM 18 and BRAM 38 or the CPU random access memory (CPU RAM) 12a. The operation of the HDMA 32 and of the FDMA 34 is conventional and need not be described in detail herein. The BRAM 38 is used to buffer data passed between the host device 24, flash memory 20 and CPU RAM 12a. The HDMA 32 and FDMA 34 are responsible for transferring the data between HIM 16/FIM 18 and BRAM 38 or the CPU RAM 12a and for indicating sector transfer completion.
First when data from flash memory 20 is read by the host device 24, encrypted data in memory 20 is fetched through bus 28, FIM 18, FDMA 34, crypto engine 40 where the encrypted data is decrypted and stored in BRAM 38. The decrypted data is then sent from BRAM 38, through HDMA 32, HIM 16, bus 26 to the host device 24. The data fetched from BRAM 38 may again be encrypted by means of crypto engine 40 before it is passed to HDMA 32 so that the data sent to the host device 24 is again encrypted but by means of a different key and/or algorithm compared to the those whereby the data stored in memory 20 is decrypted. Preferably, and in an alternative embodiment, rather than storing decrypted data in BRAM 38 in the above-described process, which data may become vulnerable to unauthorized access, the data from memory 20 may be decrypted and encrypted again by crypto engine 40 before it is sent to BRAM 38. The encrypted data in BRAM 38 is then sent to host device 24 as before. This illustrates the data stream during a reading process.
When data is written by host device 24 to memory 20, the direction of the data stream is reversed. For example if unencrypted data is sent by host device, through bus 26, HIM 16, HDMA 32 to the crypto engine 40, such data may be encrypted by engine 40 before it is stored in BRAM 38. Alternatively, unencrypted data may be stored in BRAM 38. The data is then encrypted before it is sent to FDMA 34 on its way to memory 20. Where the data written undergoes multistage cryptographic processing, preferably engine 40 completes such processing before the processed data is stored in BRAM 38.
One aspect of the invention is based on the recognition that the throughput and hence the performance of device 10 can be much improved if the above-described cryptographic processing of data in the data stream passing between the host device 24 and memory 20 can be performed with minimal involvement of CPU 12. This is illustrated in
In the process described above, data streams having two different data sources and destinations have been described. In the reading process, the data source is memory 20 and the destination is host device 24. In the writing process, the data source is host device 24 and the destination is memory 20. In addition, the data source (or destination) can also be CPU 12 where the corresponding destination (or data source) is the memory 20. In yet another operation, the data stream can be from the BMU 14 to the CPU 12 for bulk encryption and hash operations. The various combinations of data in sources and data out destinations and the corresponding cryptographic processes that may be applied are set forth in the table below.
As shown in the table above, one additional operational mode is the bypass mode which enables the FDMA 34 to access the CPU 12 or the BRAM 38 along a bypass path (not shown in
Logic (not shown) can be employed in block 40 so that CPU 12 need not get involved in the cryptographic processes by engine 40 so that entire pages of data are cryptographically processed in units smaller than a page at a time by engine 40. In one embodiment, Crypto-Engine 40 is a hardware circuit.
As shown in
Configuration register 52 may also store the key that is to be used in the cryptographic process(es). In one embodiment, this key is retrieved by CPU 12 (such as from memory 20) and stored in register 52 prior to the encryption or decryption by Crypto-Block 50. The above described processes take place in block 40 without the involvement of CPU 12, after CPU 12 has written the pertinent information into register 52. To simplify
If a multistage process is desired, CPU 12 may be used to input security configuration information or record to register 52 to specify the number of times the data is cryptographically processed, and the key and/or algorithm to be used in each stage of the multistage process. After this information is written into register 52, CPU 12 need not be involved in the multistage process at all.
While the memory system 10 in
The read process for operating system 10 is illustrated by the flow chart of
Interleaving Data Streams
It may be desirable for multiple host applications to be able to access memory 20 in parallel for processing multiple data streams. This means that the cryptographic processing of one data stream may not have been completed when it is interrupted in order for the memory system 10 to process another different data stream. The cryptographic processing of different data streams will typically employ different parameters (e.g. different keys and algorithms, and different data sources and destinations). These parameters are provided in corresponding security configuration records of the data streams. To ensure that when the interrupted processing of a particular data stream is later resumed, its corresponding security configuration record has not been lost; such record is stored, preferably in the CPU RAM 12a. Upon resumption of the processing of the previously interrupted data stream, the CPU 12 then retrieves the stored security configuration record for such data stream, so that the resumed cryptographic processing of such data stream can proceed with the correct parameters, according to the stored corresponding security configuration record.
When the CPU receives another host command, it again checks to see if it is a start session command (diamond 206). If it is, then a second session can be started, by proceeding to block 210 or block 240, such as a new second session for a different second application running on host device 24 requesting cryptographically processing of a second data stream. The security configuration information or record for such second data stream is again stored in CPU RAM 12a, which is the case for both write and read sessions (blocks 210, 240). Additional sessions can be created for additional data streams in the same manner. The CPU returns to block 202, and checks the next host command to see if the host command is a start session command (diamond 206). Thus, additional sessions are created as described until the CPU 12 detects a host command that is not a start session command in diamond 206.
In such event, CPU 12 checks the next host command to see if the host command is an end of session command (diamond 222). If it is not then the CPU checks to see if it is a data command (diamond 224). Assuming that it is a data command, the CPU determines which data stream is the one to be processed, and configures the Crypto-engine 40 (by writing to register 52) according to the security configuration record for such data stream, and the Crypto-engine 40 performs the read or write operation in the manner described above (or Crypto-engine 40 is bypassed in the bypass mode), such as according to the process in
If there is no interruption in the reading or writing process, the process will continue until the CPU receives an end session command (block 222), which means all of the pages to be processed during the session has been processed. However, if there is interruption, the CPU will receive a host data command to process data from a data stream which is different from the one system 10 is currently processing. In such event, Crypto-engine 40 will need to be re-configured to process such different data stream. The CPU then retrieves from the CPU RAM 12a the security configuration record for such different data stream, re-configures the Crypto-engine 40 (by writing the retrieved record to register 52), so that the engine 40 will correctly process the different data stream.
When an end session command (block 222) is received, in a write session, the CPU stores in memory 20 the security configuration record along with the data written, so that the record can be retrieved in subsequent red operations (diamond 228, block 230). For read operations, the security configuration record stored in RAM 12a is discarded, but the record stored in memory 20 is maintained for possible future read operations (block 242).
For certain applications, it may be important to maintain integrity of data in memory 20 against tempering. To ensure that data stored in memory 20 has not been altered or otherwise corrupted, it is desirable to derive from the data hashed value(s) or digest of the data which value(s) or digest is stored together with the data. When the data is read, the digest or hashed value(s) is read as well, so that the read hashed value(s) or digest can be compared to the digest or hashed value(s) computed from the data that has been read. If there is a difference between them, then the data in memory 20 may have been altered or otherwise corrupted.
One common hash function is the chained block cipher (CBC), where message authentication codes (MAC) are derived in a time sequence from the blocks of data that is being written or read. One common CBC function is set forth below:
Encryption.
Input: m-bit key k; l-bit IV; l-bit plaintext blocks p1, - - - pr.
Output: c0, - - - , cr such that c0←IV and ci←ek(ci-1⊕pi) for 1≦i≦r.
Decryption.
Input: m-bit key k; l-bit IV; l-bit ciphertext blocks c1, - - - Cr.
Output: p0, - - - , pr such that p0←IV and pi←ci-1⊕ek−1(ci) for 1≦i≦r.
The values c0, . . . , cr above are the message authentication codes (MAC) of the data stream p1, . . . , pr. IV is the initiation vector, and k is a key. Thus, when it is desirable to write blocks of data p1, . . . , pr to memory 20, the MAC values (e.g. c0, . . . , cr) are calculated from the blocks of data by the Crypto-engine 40 in system 10 using a hash function such as the CBC function above, and an associated security configuration record comprising the MAC values, IV and the key k and other parameters described above is written to memory 20 along with the data itself is written to memory 20. In the above formulae, ek(x) means a process where x is encrypted by means of key k and ek−1(x) means x is decrypted using the key k.
When the data blocks p1, . . . , pr are later read from memory 20, the associated security configuration record is read as well, and the Crypto-engine 40 computes the set of MAC values from IV, the key k in the security configuration record and the data read and compares such set of values to the set of MAC values read from the memory 20. If there is a difference between the two sets of MAC values, the data read may have been altered or otherwise corrupted. For some hash functions such as the CBC function above, except for the first value in the sequence, each of the MAC value is derived from a prior MAC value. This means that the set of MAC values, in such circumstances, are derived sequentially in time.
It may be desirable for multiple applications in the host device 24 to be able to access memory 20 in parallel, so that the user does not have to wait for one application using the memory 20 to be completed before using another application to access memory 20. This may mean, for example, that not all the blocks of data p1, . . . , pr will have been read from memory 20 when the reading process is interrupted, so that the memory system (e.g. system 10 of
At the end of the read session at block 242 after an end of session command is detected from the host 24, the CPU compares the MAC values calculated from the data read from memory 20 to the MAC values stored in memory 20 to validate the data read. If the host command received is none of the ones indicated above, the CPU 12 simply executes the command and returns to block 202 (block 250).
While the invention has been described above by reference to various embodiments, it will be understood that changes and modifications may be made without departing from the scope of the invention, which is to be defined only by the appended claims and their equivalent. All references referred to herein are incorporated by reference.
This application claims the benefit of U.S. Provisional Application No. 60/639,442, filed Dec. 21, 2004, entitled, “Memory System with In Stream Data Encryption/Decryption.” This application is further related to U.S. patent application Ser. No. ______, [Docket: 483US1] entitled, “In Stream Data Encryption/Decryption Method,” filed on the same day as the present application. These applications are incorporated in their entirety by reference as if fully set forth herein.
Number | Date | Country | |
---|---|---|---|
60639442 | Dec 2004 | US |