APPARATUS AND METHOD FOR IMPLEMENTING INSTRUCTION SUPPORT FOR THE KASUMI CIPHER ALGORITHM | Patent Publication Number 20100246815
US 20100246815 A1Gregory F. Grohoski
Lawrence A. Spracklen
A processor including instruction support for implementing the Kasumi block cipher algorithm may issue, for execution, programmer-selectable instructions from a defined instruction set architecture (ISA). The processor may include a cryptographic unit that may receive instructions for execution. The instructions include one or more Kasumi instructions defined within the ISA. In addition, the Kasumi instructions may be executable by the cryptographic unit to implement portions of a Kasumi cipher that is compliant with 3rd Generation Partnership Project (3GPP) Technical Specification TS 35.202 version 8.0.0. In response to receiving a Kasumi FL( )-operation instruction defined within the ISA, the cryptographic unit may perform an FL( ) operation, as defined by the Kasumi cipher, upon a data input operand and a subkey operand in which the data input operand and subkey operand may be specified by the Kasumi FL( )-operation instruction.
- 1. A processor, comprising:nan instruction fetch unit configured to issue instructions for execution, wherein the instructions are programmer-selectable from a defined instruction set architecture (ISA); anda cryptographic unit configured to receive instructions for execution from the instruction fetch unit, wherein the instructions include one or more Kasumi instructions defined within said ISA, wherein the one or more Kasumi instructions are executable by the cryptographic unit to implement portions of a Kasumi cipher that is compliant with 3rd Generation Partnership Project (3GPP) Technical Specification TS 35.202 version 8.0.0;wherein in response to receiving a Kasumi FL( )-operation instruction defined within said ISA, the cryptographic unit is further configured to perform an FL( ) operation, as defined by the Kasumi cipher, upon a data input operand and a subkey operand, wherein the data input operand and subkey operand are specified by the Kasumi FL( )-operation instruction.
- 11. A method, comprising:na hardware processor issuing instructions for execution, wherein the instructions are programmer-selectable from a defined instruction set architecture (ISA);a hardware cryptographic unit of the processor receiving ones of said instructions for execution, wherein the instructions include one or more Kasumi instructions defined within said ISA, wherein the one or more Kasumi instructions are executable by the cryptographic unit to implement portions of a Kasumi cipher that is compliant with 3rd Generation Partnership Project (3GPP) Technical Specification TS 35.202 version 8.0.0; andin response to receiving a Kasumi FL( )-operation instruction defined within said ISA, the hardware cryptographic unit performing an FL( ) operation, as defined by the Kasumi cipher, upon a data input operand and a subkey operand, wherein the data input operand and subkey operand are specified by the Kasumi FL( )-operation instruction.
1. Field of the Invention
This invention relates to processors and, more particularly, to implementation of cryptographic algorithms.
2. Description of the Related Art
Securing transactions and communications against tampering, interception and unauthorized use has become a problem of increasing significance as new forms of electronic commerce and communication proliferate. For example, many businesses provide customers with Internet-based purchasing mechanisms, such as web pages via which customers may convey order and payment details. Such details often include sensitive information, such as credit card numbers, that might be subject to fraudulent use if intercepted by a third party.
To provide a measure of security for sensitive data, cryptographic algorithms have been developed that may allow encryption of sensitive information before it is conveyed over an insecure channel. The information may then be decrypted and used by the receiver. However, as the performance of generally available computer technology continues to increase (e.g., due to development of faster microprocessors), less sophisticated cryptographic algorithms become increasingly vulnerable to compromise or attack.
More sophisticated cryptographic algorithms are continually evolving to meet the threat posed by new types of attacks. However, as cryptographic algorithms become increasingly powerful, they often become computationally more complex to implement, potentially adding overhead to secure transactions and consequently reducing their performance.
Various embodiments of a processor and method for instruction support for implementing the Kasumi block cipher algorithm are disclosed. In one embodiment, a processor includes an instruction fetch unit that may be configured to issue, for execution, programmer-selectable instructions from a defined instruction set architecture (ISA). The processor may also include a cryptographic unit that may be configured to receive instructions for execution from the instruction fetch unit. The instructions include one or more Kasumi instructions defined within the ISA. In addition, the Kasumi instructions may be executable by the cryptographic unit to implement portions of a Kasumi cipher that is compliant with 3rd Generation Partnership Project (3GPP) Technical Specification TS 35.202 version 8.0.0. Further, in response to receiving a Kasumi FL( )-operation instruction defined within the ISA, the cryptographic unit may perform an FL( ) operation, as defined by the Kasumi cipher, upon a data input operand and a subkey operand in which the data input operand and subkey operand may be specified by the Kasumi FL( )-operation instruction.
While the disclosure is susceptible to various modifications and alternative forms, specific embodiments thereof are shown by way of example in the drawings and will herein be described in detail. It should be understood, however, that the drawings and detailed description thereto are not intended to limit the disclosure to the particular form disclosed, but on the contrary, the intention is to cover all modifications, equivalents and alternatives falling within the spirit and scope of the present disclosure as defined by the appended claims.
In the following discussion, hardware support for various types of instructions that are specific to particular cipher algorithms is explored. First, an overview is provided of one type of multithreaded processor in which cipher-specific instruction support may be provided. Next, particular embodiments of cipher-specific instruction support are described with respect to the DES cipher, the Kasumi cipher, the Camellia cipher, and the AES cipher. Finally, an exemplary system embodiment including a processor that may implement instruction-level support for various ciphers is discussed.
A block diagram illustrating one embodiment of a multithreaded processor 10 is shown in
Via crossbar 110 and L3 cache 120, cores 100 may be coupled to a variety of devices that may be located externally to processor 10. In the illustrated embodiment, one or more memory interface(s) 130 may be configured to couple to one or more banks of system memory (not shown). One or more coherent processor interface(s) 140 may be configured to couple processor 10 to other processors (e.g., in a multiprocessor environment employing multiple units of processor 10). Additionally, system interconnect 125 couples cores 100 to one or more peripheral interface(s) 150 and network interface(s) 160. As described in greater detail below, these interfaces may be configured to couple processor 10 to various peripheral devices and networks.
Cores 100 may be configured to execute instructions and to process data according to a particular instruction set architecture (ISA). In one embodiment, cores 100 may be configured to implement a version of the SPARC® ISA, such as SPARC® V9, UltraSPARC Architecture 2005, UltraSPARC Architecture 2007, or UltraSPARC Architecture 2009, for example. However, in other embodiments it is contemplated that any desired ISA may be employed, such as x86 (32-bit or 64-bit versions), PowerPC® or MIPS®, for example.
In the illustrated embodiment, each of cores 100 may be configured to operate independently of the others, such that all cores 100 may execute in parallel. Additionally, as described below in conjunction with the descriptions of
Additionally, as described in greater detail below, in some embodiments, each of cores 100 may be configured to execute certain instructions out of program order, which may also be referred to herein as out-of-order execution, or simply OOO. As an example of out-of-order execution, for a particular thread, there may be instructions that are subsequent in program order to a given instruction yet do not depend on the given instruction. If execution of the given instruction is delayed for some reason (e.g., owing to a cache miss), the later instructions may execute before the given instruction completes, which may improve overall performance of the executing thread.
As shown in
In various embodiments, L2 cache 105 may include a variety of structures configured to support cache functionality and performance. For example, L2 cache 105 may include a miss buffer configured to store requests that miss the L2, a fill buffer configured to temporarily store data returning from L3 cache 120, a writeback buffer configured to temporarily store dirty evicted data and snoop copyback data, and/or a snoop buffer configured to store snoop requests received from L3 cache 120. In one embodiment, L2 cache 105 may implement a history-based prefetcher that may attempt to analyze L2 miss behavior and correspondingly generate prefetch requests to L3 cache 120.
Crossbar 110 may be configured to manage data flow between L2 caches 105 and the shared L3 cache 120. In one embodiment, crossbar 110 may include logic (such as multiplexers or a switch fabric, for example) that allows any L2 cache 105 to access any bank of L3 cache 120, and that conversely allows data to be returned from any L3 bank to any L2 cache 105. That is, crossbar 110 may be configured as an M-to-N crossbar that allows for generalized point-to-point communication. However, in other embodiments, other interconnection schemes may be employed between L2 caches 105 and L3 cache 120. For example, a mesh, ring, or other suitable topology may be utilized.
Crossbar 110 may be configured to concurrently process data requests from L2 caches 105 to L3 cache 120 as well as data responses from L3 cache 120 to L2 caches 105. In some embodiments, crossbar 110 may include logic to queue data requests and/or responses, such that requests and responses may not block other activity while waiting for service. Additionally, in one embodiment crossbar 110 may be configured to arbitrate conflicts that may occur when multiple L2 caches 105 attempt to access a single bank of L3 cache 120, or vice versa.
L3 cache 120 may be configured to cache instructions and data for use by cores 100. In the illustrated embodiment, L3 cache 120 may be organized into eight separately addressable banks that may each be independently accessed, such that in the absence of conflicts, each bank may concurrently return data to a respective L2 cache 105. In some embodiments, each individual bank may be implemented using set-associative or direct-mapped techniques. For example, in one embodiment, L3 cache 120 may be an 8 megabyte (MB) cache, where each 1 MB bank is 16-way set associative with a 64-byte line size. L3 cache 120 may be implemented in some embodiments as a writeback cache in which written (dirty) data may not be written to system memory until a corresponding cache line is evicted. However, it is contemplated that in other embodiments, L3 cache 120 may be configured in any suitable fashion. For example, L3 cache 120 may be implemented with more or fewer banks, or in a scheme that does not employ independently-accessible banks; it may employ other bank sizes or cache geometries (e.g., different line sizes or degrees of set associativity); it may employ write-through instead of writeback behavior; and it may or may not allocate on a write miss. Other variations of L3 cache 120 configuration are possible and contemplated.
In some embodiments, L3 cache 120 may implement queues for requests arriving from and results to be sent to crossbar 110. Additionally, in some embodiments L3 cache 120 may implement a fill buffer configured to store fill data arriving from memory interface 130, a writeback buffer configured to store dirty evicted data to be written to memory, and/or a miss buffer configured to store L3 cache accesses that cannot be processed as simple cache hits (e.g., L3 cache misses, cache accesses matching older misses, accesses such as atomic operations that may require multiple cache accesses, etc.). L3 cache 120 may variously be implemented as single-ported or multiported (i.e., capable of processing multiple concurrent read and/or write accesses). In either case, L3 cache 120 may implement arbitration logic to prioritize cache access among various cache read and write requesters.
Not all external accesses from cores 100 necessarily proceed through L3 cache 120. In the illustrated embodiment, non-cacheable unit (NCU) 122 may be configured to process requests from cores 100 for non-cacheable data, such as data from I/O devices as described below with respect to peripheral interface(s) 150 and network interface(s) 160.
Memory interface 130 may be configured to manage the transfer of data between L3 cache 120 and system memory, for example in response to cache fill requests and data evictions. In some embodiments, multiple instances of memory interface 130 may be implemented, with each instance configured to control a respective bank of system memory. Memory interface 130 may be configured to interface to any suitable type of system memory, such as Fully Buffered Dual Inline Memory Module (FB-DIMM), Double Data Rate or Double Data Rate 2, 3, or 4 Synchronous Dynamic Random Access Memory (DDR/DDR2/DDR3/DDR4 SDRAM), or Rambus® DRAM (RDRAM®), for example. In some embodiments, memory interface 130 may be configured to support interfacing to multiple different types of system memory.
In the illustrated embodiment, processor 10 may also be configured to receive data from sources other than system memory. System interconnect 125 may be configured to provide a central interface for such sources to exchange data with cores 100, L2 caches 105, and/or L3 cache 120. In some embodiments, system interconnect 125 may be configured to coordinate Direct Memory Access (DMA) transfers of data to and from system memory. For example, via memory interface 130, system interconnect 125 may coordinate DMA transfers between system memory and a network device attached via network interface 160, or between system memory and a peripheral device attached via peripheral interface 150.
Processor 10 may be configured for use in a multiprocessor environment with other instances of processor 10 or other compatible processors. In the illustrated embodiment, coherent processor interface(s) 140 may be configured to implement high-bandwidth, direct chip-to-chip communication between different processors in a manner that preserves memory coherence among the various processors (e.g., according to a coherence protocol that governs memory transactions).
Peripheral interface 150 may be configured to coordinate data transfer between processor 10 and one or more peripheral devices. Such peripheral devices may include, for example and without limitation, storage devices (e.g., magnetic or optical media-based storage devices including hard drives, tape drives, CD drives, DVD drives, etc.), display devices (e.g., graphics subsystems), multimedia devices (e.g., audio processing subsystems), or any other suitable type of peripheral device. In one embodiment, peripheral interface 150 may implement one or more instances of a standard peripheral interface. For example, one embodiment of peripheral interface 150 may implement the Peripheral Component Interface Express (PCI Express™ or PCIe) standard according to generation 1.x, 2.0, 3.0, or another suitable variant of that standard, with any suitable number of I/O lanes. However, it is contemplated that any suitable interface standard or combination of standards may be employed. For example, in some embodiments peripheral interface 150 may be configured to implement a version of Universal Serial Bus (USB) protocol or IEEE 1394 (Firewire®) protocol in addition to or instead of PCI Express™.
Network interface 160 may be configured to coordinate data transfer between processor 10 and one or more network devices (e.g., networked computer systems or peripherals) coupled to processor 10 via a network. In one embodiment, network interface 160 may be configured to perform the data processing necessary to implement an Ethernet (IEEE 802.3) networking standard such as Gigabit Ethernet or 10-Gigabit Ethernet, for example. However, it is contemplated that any suitable networking standard may be implemented, including forthcoming standards such as 40-Gigabit Ethernet and 100-Gigabit Ethernet. In some embodiments, network interface 160 may be configured to implement other types of networking protocols, such as Fibre Channel, Fibre Channel over Ethernet (FCoE), Data Center Ethernet, Infiniband, and/or other suitable networking protocols. In some embodiments, network interface 160 may be configured to implement multiple discrete network interface ports.
As mentioned above, in one embodiment each of cores 100 may be configured for multithreaded, out-of-order execution. More specifically, in one embodiment, each of cores 100 may be configured to perform dynamic multithreading. Generally speaking, under dynamic multithreading, the execution resources of cores 100 may be configured to efficiently process varying types of computational workloads that exhibit different performance characteristics and resource requirements. Such workloads may vary across a continuum that emphasizes different combinations of individual-thread and multiple-thread performance.
At one end of the continuum, a computational workload may include a number of independent tasks, where completing the aggregate set of tasks within certain performance criteria (e.g., an overall number of tasks per second) is a more significant factor in system performance than the rate at which any particular task is completed. For example, in certain types of server or transaction processing environments, there may be a high volume of individual client or customer requests (such as web page requests or file system accesses). In this context, individual requests may not be particularly sensitive to processor performance. For example, requests may be I/O-bound rather than processor-bound—completion of an individual request may require I/O accesses (e.g., to relatively slow memory, network, or storage devices) that dominate the overall time required to complete the request, relative to the processor effort involved. Thus, a processor that is capable of concurrently processing many such tasks (e.g., as independently executing threads) may exhibit better performance on such a workload than a processor that emphasizes the performance of only one or a small number of concurrent tasks.
At the other end of the continuum, a computational workload may include individual tasks whose performance is highly processor-sensitive. For example, a task that involves significant mathematical analysis and/or transformation (e.g., cryptography, graphics processing, scientific computing) may be more processor-bound than I/O-bound. Such tasks may benefit from processors that emphasize single-task performance, for example through speculative execution and exploitation of instruction-level parallelism.
Dynamic multithreading represents an attempt to allocate processor resources in a manner that flexibly adapts to workloads that vary along the continuum described above. In one embodiment, cores 100 may be configured to implement fine-grained multithreading, in which each core may select instructions to execute from among a pool of instructions corresponding to multiple threads, such that instructions from different threads may be scheduled to execute adjacently. For example, in a pipelined embodiment of core 100 employing fine-grained multithreading, instructions from different threads may occupy adjacent pipeline stages, such that instructions from several threads may be in various stages of execution during a given core processing cycle. Through the use of fine-grained multithreading, cores 100 may be configured to efficiently process workloads that depend more on concurrent thread processing than individual thread performance.
In one embodiment, cores 100 may also be configured to implement out-of-order processing, speculative execution, register renaming and/or other features that improve the performance of processor-dependent workloads. Moreover, cores 100 may be configured to dynamically allocate a variety of hardware resources among the threads that are actively executing at a given time, such that if fewer threads are executing, each individual thread may be able to take advantage of a greater share of the available hardware resources. This may result in increased individual thread performance when fewer threads are executing, while retaining the flexibility to support workloads that exhibit a greater number of threads that are less processor-dependent in their performance. In various embodiments, the resources of a given core 100 that may be dynamically allocated among a varying number of threads may include branch resources (e.g., branch predictor structures), load/store resources (e.g., load/store buffers and queues), instruction completion resources (e.g., reorder buffer structures and commit logic), instruction issue resources (e.g., instruction selection and scheduling structures), register rename resources (e.g., register mapping tables), and/or memory management unit resources (e.g., translation lookaside buffers, page walk resources).
One embodiment of core 100 that is configured to perform dynamic multithreading is illustrated in
In the following discussion, exemplary embodiments of each of the structures of the illustrated embodiment of core 100 are described. However, it is noted that the illustrated partitioning of resources is merely one example of how core 100 may be implemented. Alternative configurations and variations are possible and contemplated.
Instruction fetch unit 200 may be configured to provide instructions to the rest of core 100 for execution. In one embodiment, IFU 200 may be configured to select a thread to be fetched, fetch instructions from instruction cache 205 for the selected thread and buffer them for downstream processing, request data from L2 cache 105 in response to instruction cache misses, and predict the direction and target of control transfer instructions (e.g., branches). In some embodiments, IFU 200 may include a number of data structures in addition to instruction cache 205, such as an instruction translation lookaside buffer (ITLB), instruction buffers, and/or structures configured to store state that is relevant to thread selection and processing.
In one embodiment, during each execution cycle of core 100, IFU 200 may be configured to select one thread that will enter the IFU processing pipeline. Thread selection may take into account a variety of factors and conditions, some thread-specific and others IFU-specific. For example, certain instruction cache activities (e.g., cache fill), ITLB activities, or diagnostic activities may inhibit thread selection if these activities are occurring during a given execution cycle. Additionally, individual threads may be in specific states of readiness that affect their eligibility for selection. For example, a thread for which there is an outstanding instruction cache miss may not be eligible for selection until the miss is resolved. In some embodiments, those threads that are eligible to participate in thread selection may be divided into groups by priority, for example depending on the state of the thread or of the ability of the IFU pipeline to process the thread. In such embodiments, multiple levels of arbitration may be employed to perform thread selection: selection occurs first by group priority, and then within the selected group according to a suitable arbitration algorithm (e.g., a least-recently-fetched algorithm). However, it is noted that any suitable scheme for thread selection may be employed, including arbitration schemes that are more complex or simpler than those mentioned here.
Once a thread has been selected for fetching by IFU 200, instructions may actually be fetched for the selected thread. To perform the fetch, in one embodiment, IFU 200 may be configured to generate a fetch address to be supplied to instruction cache 205. In various embodiments, the fetch address may be generated as a function of a program counter associated with the selected thread, a predicted branch target address, or an address supplied in some other manner (e.g., through a test or diagnostic mode). The generated fetch address may then be applied to instruction cache 205 to determine whether there is a cache hit.
In some embodiments, accessing instruction cache 205 may include performing fetch address translation (e.g., in the case of a physically indexed and/or tagged cache), accessing a cache tag array, and comparing a retrieved cache tag to a requested tag to determine cache hit status. If there is a cache hit, IFU 200 may store the retrieved instructions within buffers for use by later stages of the instruction pipeline. If there is a cache miss, IFU 200 may coordinate retrieval of the missing cache data from L2 cache 105. In some embodiments, IFU 200 may also be configured to prefetch instructions into instruction cache 205 before the instructions are actually required to be fetched. For example, in the case of a cache miss, IFU 200 may be configured to retrieve the missing data for the requested fetch address as well as addresses that sequentially follow the requested fetch address, on the assumption that the following addresses are likely to be fetched in the near future.
In many ISAs, instruction execution proceeds sequentially according to instruction addresses (e.g., as reflected by one or more program counters). However, control transfer instructions (CTIs) such as branches, call/return instructions, or other types of instructions may cause the transfer of execution from a current fetch address to a nonsequential address. As mentioned above, IFU 200 may be configured to predict the direction and target of CTIs (or, in some embodiments, a subset of the CTIs that are defined for an ISA) in order to reduce the delays incurred by waiting until the effect of a CTI is known with certainty. In one embodiment, IFU 200 may be configured to implement a perceptron-based dynamic branch predictor, although any suitable type of branch predictor may be employed.
To implement branch prediction, IFU 200 may implement a variety of control and data structures in various embodiments, such as history registers that track prior branch history, weight tables that reflect relative weights or strengths of predictions, and/or target data structures that store fetch addresses that are predicted to be targets of a CTI. Also, in some embodiments, IFU 200 may further be configured to partially decode (or predecode) fetched instructions in order to facilitate branch prediction. A predicted fetch address for a given thread may be used as the fetch address when the given thread is selected for fetching by IFU 200. The outcome of the prediction may be validated when the CTI is actually executed (e.g., if the CTI is a conditional instruction, or if the CTI itself is in the path of another predicted CTI). If the prediction was incorrect, instructions along the predicted path that were fetched and issued may be cancelled.
Through the operations discussed above, IFU 200 may be configured to fetch and maintain a buffered pool of instructions from one or multiple threads, to be fed into the remainder of the instruction pipeline for execution. Generally speaking, select unit 210 may be configured to select and schedule threads for execution. In one embodiment, during any given execution cycle of core 100, select unit 210 may be configured to select up to one ready thread out of the maximum number of threads concurrently supported by core 100 (e.g., 8 threads), and may select up to two instructions from the selected thread for decoding by decode unit 215, although in other embodiments, a differing number of threads and instructions may be selected. In various embodiments, different conditions may affect whether a thread is ready for selection by select unit 210, such as branch mispredictions, unavailable instructions, or other conditions. To ensure fairness in thread selection, some embodiments of select unit 210 may employ arbitration among ready threads (e.g. a least-recently-used algorithm).
The particular instructions that are selected for decode by select unit 210 may be subject to the decode restrictions of decode unit 215; thus, in any given cycle, fewer than the maximum possible number of instructions may be selected. Additionally, in some embodiments, select unit 210 may be configured to allocate certain execution resources of core 100 to the selected instructions, so that the allocated resources will not be used for the benefit of another instruction until they are released. For example, select unit 210 may allocate resource tags for entries of a reorder buffer, load/store buffers, or other downstream resources that may be utilized during instruction execution.
Generally, decode unit 215 may be configured to prepare the instructions selected by select unit 210 for further processing. Decode unit 215 may be configured to identify the particular nature of an instruction (e.g., as specified by its opcode) and to determine the source and sink (i.e., destination) registers encoded in an instruction, if any. In some embodiments, decode unit 215 may be configured to detect certain dependencies among instructions, to remap architectural registers to a flat register space, and/or to convert certain complex instructions to two or more simpler instructions for execution. Additionally, in some embodiments, decode unit 215 may be configured to assign instructions to slots for subsequent scheduling. In one embodiment, two slots 0-1 may be defined, where slot 0 includes instructions executable in load/store unit 245 or execution units 235-240, and where slot 1 includes instructions executable in execution units 235-240, floating point/graphics unit 255, and any branch instructions. However, in other embodiments, other numbers of slots and types of slot assignments may be employed, or slots may be omitted entirely.
Register renaming may facilitate the elimination of certain dependencies between instructions (e.g., write-after-read or “false†dependencies), which may in turn prevent unnecessary serialization of instruction execution. In one embodiment, rename unit 220 may be configured to rename the logical (i.e., architected) destination registers specified by instructions by mapping them to a physical register space, resolving false dependencies in the process. In some embodiments, rename unit 220 may maintain mapping tables that reflect the relationship between logical registers and the physical registers to which they are mapped.
Once decoded and renamed, instructions may be ready to be scheduled for execution. In the illustrated embodiment, pick unit 225 may be configured to pick instructions that are ready for execution and send the picked instructions to issue unit 230. In one embodiment, pick unit 225 may be configured to maintain a pick queue that stores a number of decoded and renamed instructions as well as information about the relative age and status of the stored instructions. During each execution cycle, this embodiment of pick unit 225 may pick up to one instruction per slot. For example, taking instruction dependency and age information into account, for a given slot, pick unit 225 may be configured to pick the oldest instruction for the given slot that is ready to execute.
In some embodiments, pick unit 225 may be configured to support load/store speculation by retaining speculative load/store instructions (and, in some instances, their dependent instructions) after they have been picked. This may facilitate replaying of instructions in the event of load/store misspeculation. Additionally, in some embodiments, pick unit 225 may be configured to deliberately insert “holes†into the pipeline through the use of stalls, e.g., in order to manage downstream pipeline hazards such as synchronization of certain load/store or long-latency FGU instructions.
Issue unit 230 may be configured to provide instruction sources and data to the various execution units for picked instructions. In one embodiment, issue unit 230 may be configured to read source operands from the appropriate source, which may vary depending upon the state of the pipeline. For example, if a source operand depends on a prior instruction that is still in the execution pipeline, the operand may be bypassed directly from the appropriate execution unit result bus. Results may also be sourced from register files representing architectural (i.e., user-visible) as well as non-architectural state. In the illustrated embodiment, core 100 includes a working register file 260 that may be configured to store instruction results (e.g., integer results, floating point results, and/or condition code results) that have not yet been committed to architectural state, and which may serve as the source for certain operands. The various execution units may also maintain architectural integer, floating-point, and condition code state from which operands may be sourced.
Instructions issued from issue unit 230 may proceed to one or more of the illustrated execution units for execution. In one embodiment, each of EXU0 235 and EXU1 240 may be similarly or identically configured to execute certain integer-type instructions defined in the implemented ISA, such as arithmetic, logical, and shift instructions. In the illustrated embodiment, EXU0 235 may be configured to execute integer instructions issued from slot 0, and may also perform address calculation and for load/store instructions executed by LSU 245. EXU1 240 may be configured to execute integer instructions issued from slot 1, as well as branch instructions. In one embodiment, FGU instructions and multicycle integer instructions may be processed as slot 1 instructions that pass through the EXU1 240 pipeline, although some of these instructions may actually execute in other functional units.
In some embodiments, architectural and non-architectural register files may be physically implemented within or near execution units 235-240. It is contemplated that in some embodiments, core 100 may include more or fewer than two integer execution units, and the execution units may or may not be symmetric in functionality. Also, in some embodiments execution units 235-240 may not be bound to specific issue slots, or may be differently bound than just described.
Load store unit 245 may be configured to process data memory references, such as integer and floating-point load and store instructions and other types of memory reference instructions. LSU 245 may include a data cache 250 as well as logic configured to detect data cache misses and to responsively request data from L2 cache 105. In one embodiment, data cache 250 may be configured as a set-associative, write-through cache in which all stores are written to L2 cache 105 regardless of whether they hit in data cache 250. As noted above, the actual computation of addresses for load/store instructions may take place within one of the integer execution units, though in other embodiments, LSU 245 may implement dedicated address generation logic. In some embodiments, LSU 245 may implement an adaptive, history-dependent hardware prefetcher configured to predict and prefetch data that is likely to be used in the future, in order to increase the likelihood that such data will be resident in data cache 250 when it is needed.
In various embodiments, LSU 245 may implement a variety of structures configured to facilitate memory operations. For example, LSU 245 may implement a data TLB to cache virtual data address translations, as well as load and store buffers configured to store issued but not-yet-committed load and store instructions for the purposes of coherency snooping and dependency checking. LSU 245 may include a miss buffer configured to store outstanding loads and stores that cannot yet complete, for example due to cache misses. In one embodiment, LSU 245 may implement a store queue configured to store address and data information for stores that have committed, in order to facilitate load dependency checking. LSU 245 may also include hardware configured to support atomic load-store instructions, memory-related exception detection, and read and write access to special-purpose registers (e.g., control registers).
Floating point/graphics unit 255 may be configured to execute and provide results for certain floating-point and graphics-oriented instructions defined in the implemented ISA. For example, in one embodiment FGU 255 may implement single- and double-precision floating-point arithmetic instructions compliant with the IEEE 754-1985 floating-point standard, such as add, subtract, multiply, divide, and certain transcendental functions. Also, in one embodiment FGU 255 may implement partitioned-arithmetic and graphics-oriented instructions defined by a version of the SPARC® Visual Instruction Set (VIS™) architecture, such as VIS™ 2.0 or VIS™ 3.0. In some embodiments, FGU 255 may implement fused and unfused floating-point multiply-add instructions. Additionally, in one embodiment FGU 255 may implement certain integer instructions such as integer multiply, divide, and population count instructions. Depending on the implementation of FGU 255, some instructions (e.g., some transcendental or extended-precision instructions) or instruction operand or result scenarios (e.g., certain denormal operands or expected results) may be trapped and handled or emulated by software.
In one embodiment, FGU 255 may implement separate execution pipelines for floating point add/multiply, divide/square root, and graphics operations, while in other embodiments the instructions implemented by FGU 255 may be differently partitioned. In various embodiments, instructions implemented by FGU 255 may be fully pipelined (i.e., FGU 255 may be capable of starting one new instruction per execution cycle), partially pipelined, or may block issue until complete, depending on the instruction type. For example, in one embodiment floating-point add and multiply operations may be fully pipelined, while floating-point divide operations may block other divide/square root operations until completed.
Embodiments of FGU 255 may also be configured to implement hardware cryptographic support. For example, FGU 255 may include logic configured to support encryption/decryption algorithms such as Advanced Encryption Standard (AES), Data Encryption Standard/Triple Data Encryption Standard (DES/3DES), the Kasumi block cipher algorithm, and/or the Camellia block cipher algorithm. FGU 255 may also include logic to implement hash or checksum algorithms such as Secure Hash Algorithm (SHA-1, SHA-256, SHA-384, SHA-512), or Message Digest 5 (MD5). FGU 255 may also be configured to implement modular arithmetic such as modular multiplication, reduction and exponentiation, as well as various types of Galois field operations. In one embodiment, FGU 255 may be configured to utilize the floating-point multiplier array for modular multiplication. In various embodiments, FGU 255 may implement several of the aforementioned algorithms as well as other algorithms not specifically described.
The various cryptographic and modular arithmetic operations provided by FGU 255 may be invoked in different ways for different embodiments. In one embodiment, these features may be implemented via a discrete coprocessor that may be indirectly programmed by software, for example by using a control word queue defined through the use of special registers or memory-mapped registers. In another embodiment, the ISA may be augmented with specific instructions that may allow software to directly perform these operations.
As previously described, instruction and data memory accesses may involve translating virtual addresses to physical addresses. In one embodiment, such translation may occur on a page level of granularity, where a certain number of address bits comprise an offset into a given page of addresses, and the remaining address bits comprise a page number. For example, in an embodiment employing 4 MB pages, a 64-bit virtual address and a 40-bit physical address, 22 address bits (corresponding to 4 MB of address space, and typically the least significant address bits) may constitute the page offset. The remaining 42 bits of the virtual address may correspond to the virtual page number of that address, and the remaining 18 bits of the physical address may correspond to the physical page number of that address. In such an embodiment, virtual to physical address translation may occur by mapping a virtual page number to a particular physical page number, leaving the page offset unmodified.
Such translation mappings may be stored in an ITLB or a DTLB for rapid translation of virtual addresses during lookup of instruction cache 205 or data cache 250. In the event no translation for a given virtual page number is found in the appropriate TLB, memory management unit 270 may be configured to provide a translation. In one embodiment, MMU 270 may be configured to manage one or more translation tables stored in system memory and to traverse such tables (which in some embodiments may be hierarchically organized) in response to a request for an address translation, such as from an ITLB or DTLB miss. (Such a traversal may also be referred to as a page table walk or a hardware table walk.) In some embodiments, if MMU 270 is unable to derive a valid address translation, for example if one of the memory pages including a necessary page table is not resident in physical memory (i.e., a page miss), MMU 270 may be configured to generate a trap to allow a memory management software routine to handle the translation. It is contemplated that in various embodiments, any desirable page size may be employed. Further, in some embodiments multiple page sizes may be concurrently supported.
As noted above, several functional units in the illustrated embodiment of core 100 may be configured to generate off-core memory requests. For example, IFU 200 and LSU 245 each may generate access requests to L2 cache 105 in response to their respective cache misses. Additionally, MMU 270 may be configured to generate memory requests, for example while executing a page table walk. In the illustrated embodiment, L2 interface 265 may be configured to provide a centralized interface to the L2 cache 105 associated with a particular core 100, on behalf of the various functional units that may generate L2 accesses. In one embodiment, L2 interface 265 may be configured to maintain queues of pending L2 requests and to arbitrate among pending requests to determine which request or requests may be conveyed to L2 cache 105 during a given execution cycle. For example, L2 interface 265 may implement a least-recently-used or other algorithm to arbitrate among L2 requesters. In one embodiment, L2 interface 265 may also be configured to receive data returned from L2 cache 105, and to direct such data to the appropriate functional unit (e.g., to data cache 250 for a data cache fill due to miss).
During the course of operation of some embodiments of core 100, exceptional events may occur. For example, an instruction from a given thread that is selected for execution by select unit 210 may be not be a valid instruction for the ISA implemented by core 100 (e.g., the instruction may have an illegal opcode), a floating-point instruction may produce a result that requires further processing in software, MMU 270 may not be able to complete a page table walk due to a page miss, a hardware error (such as uncorrectable data corruption in a cache or register file) may be detected, or any of numerous other possible architecturally-defined or implementation-specific exceptional events may occur. In one embodiment, trap logic unit 275 may be configured to manage the handling of such events. For example, TLU 275 may be configured to receive notification of an exceptional event occurring during execution of a particular thread, and to cause execution control of that thread to vector to a supervisor-mode software handler (i.e., a trap handler) corresponding to the detected event. Such handlers may include, for example, an illegal opcode trap handler configured to return an error status indication to an application associated with the trapping thread and possibly terminate the application, a floating-point trap handler configured to fix up an inexact result, etc.
In one embodiment, TLU 275 may be configured to flush all instructions from the trapping thread from any stage of processing within core 100, without disrupting the execution of other, non-trapping threads. In some embodiments, when a specific instruction from a given thread causes a trap (as opposed to a trap-causing condition independent of instruction execution, such as a hardware interrupt request), TLU 275 may implement such traps as precise traps. That is, TLU 275 may ensure that all instructions from the given thread that occur before the trapping instruction (in program order) complete and update architectural state, while no instructions from the given thread that occur after the trapping instruction (in program) order complete or update architectural state.
Additionally, in the absence of exceptions or trap requests, TLU 275 may be configured to initiate and monitor the commitment of working results to architectural state. For example, TLU 275 may include a reorder buffer (ROB) that coordinates transfer of speculative results into architectural state. TLU 275 may also be configured to coordinate thread flushing that results from branch misprediction. For instructions that are not flushed or otherwise cancelled due to mispredictions or exceptions, instruction processing may end when instruction results have been committed.
In various embodiments, any of the units illustrated in
Through the use of dynamic multithreading, in some instances, it is possible for each stage of the instruction pipeline of core 100 to hold an instruction from a different thread in a different stage of execution, in contrast to conventional processor implementations that typically require a pipeline flush when switching between threads or processes. In some embodiments, flushes and stalls due to resource conflicts or other scheduling hazards may cause some pipeline stages to have no instruction during a given cycle. However, in the fine-grained multithreaded processor implementation employed by the illustrated embodiment of core 100, such flushes and stalls may be directed to a single thread in the pipeline, leaving other threads undisturbed. Additionally, even if one thread being processed by core 100 stalls for a significant length of time (for example, due to an L2 cache miss), instructions from another thread may be readily selected for issue, thus increasing overall thread processing throughput.
As described previously, however, the various resources of core 100 that support fine-grained multithreaded execution may also be dynamically reallocated to improve the performance of workloads having fewer numbers of threads. Under these circumstances, some threads may be allocated a larger share of execution resources while other threads are allocated correspondingly fewer resources. Even when fewer threads are sharing comparatively larger shares of execution resources, however, core 100 may still exhibit the flexible, thread-specific flush and stall behavior described above.
As noted above, in some embodiments FGU 255 may be configured to support cryptographic operations including encryption/decryption and hashing algorithms using coprocessing hardware. More particularly, as shown in
As noted above and described in greater detail below, the ISA may include specific programmer visible instructions that may allow software to directly control the engines within SPU 300. As such, the other FGU hardware 345 may include logic to decode and/or route the encryption/decryption and hashing instructions or their corresponding operations to the corresponding engines.
The above-mentioned encryption/decryption algorithms may be referred to as block cipher algorithms. Generally speaking, a block cipher algorithm is a class of cryptographic algorithm in which multiple bits of a message may be encrypted and/or decrypted as a group, in contrast to stream cipher algorithms in which a character of a message may be individually encrypted/decrypted before progressing to another character.
As shown in
In the following discussion, the general operation of the DES cipher is first described. Examples of particular DES instructions that DES engine 315 may execute to implement the DES cipher are then discussed, including code examples that implement such instructions.
Generally speaking, the DES cipher is a block cipher that provides for the encryption and decryption of a 64-bit block of input data under the control of a 64-bit input key to produce a 64-bit block of output data. During operation, the DES cipher expands the 64-bit key into a set of 16 56-bit cipher keys (also referred to as a “key schedule†). To encrypt the input data block, the DES cipher first applies an initial permutation (IP) operation to the input data block, followed by 16 “rounds†or iterations of the cipher using the 16 keys of the key schedule. Finally, the DES cipher applies an inverse initial permutation operation (IIP) to the result of the final round to generate the encrypted data block. To perform decryption, the DES cipher applies same sequence of an IP operation and 16 cipher rounds followed by an IIP operation, but using the 16 keys of the key schedule in an inverse order relative to encryption.
To generate the key schedule from the 64-bit input key, the DES cipher applies a sequence of permutation and bitwise rotate operations to the input key. In the following discussion, consistent with the notation employed in FIPS 46-3, the most significant bit of a 64-bit data word is denoted bit 1, while the least significant bit is denoted bit 64. Although the input key is defined to be 64 bits wide, the DES cipher only employs 56 bits of the input key, omitting every eighth bit. In some implementations, the omitted bits may instead be used as parity bits to detect parity errors in the corresponding bytes of the input key.
The key expansion function “Permuted Choice One†(PC1) is defined to produce a 56-bit output as a permutation of a 64-bit input, according to the following mapping:
where the uppermost row denotes the bits of the input that correspond to bits 1:7 of the output, the second row denotes the bits of the input that correspond to bits 8:14 of the output, and so forth. Thus, according to the function PC1, the most significant bit of the output (i.e., bit 1) corresponds to bit 57 of the input, while the least significant bit of the output (bit 56) corresponds to bit 4 of the input.
The key expansion function “Permuted Choice Two†(PC2) is defined to produce a 48-bit output as a permutation of a 56-bit input, according to the following mapping:
where, in a manner similar to PC1, the leftmost entry of the uppermost row denotes the most significant bit of the output (bit 1), while the rightmost entry of the lowermost row denotes the least significant bit of the output (bit 48). (It will be assumed that the ordering convention described above with respect to the PC1 and PC2 mappings will be applicable to all other DES cipher permutations described below, unless otherwise noted.)
Given the foregoing definitions of PC1 and PC2, the DES cipher key schedule may be generated according to the following pseudocode, where the notation {A, B} indicates the bitwise concatenation of bit fields A and B, and the input key is defined as key[1:64]:
As seen above, the input key is first transformed by the PC1 function, and then split into two 28-bit halves c0 and d0, which are referred to as a c/d pair. Successive c/d pairs are generated by rotating the previous c/d pairs by either one or two bit positions. Applying the PC2 function to each c/d pair yields a corresponding key of the key schedule, denoted key1 through key16. It is noted that application of the PC2 function to a c/d pair to generate a particular key is dependent only on the c/d pair for the particular key; that is, once the c/d pair is known, the PC2 function may be applied at any time prior to actual use of the particular key within the DES cipher round.
In some instances, each of the DES cipher c/d pairs shown above may be referred to as an intermediate value or precursor to its respectively corresponding cipher key. Each given intermediate value (i.e., each c/d pair) has the property that when the PC2 function of the DES cipher is applied to the given intermediate value, a corresponding cipher key of the DES cipher key schedule is generated. As noted below, the point at which the PC2 function is applied to generate a cipher key may vary in various implementations of processor 10.
The DES cipher makes use of several distinct permutation operations, each of which is now summarized. The initial permutation operation IP maps a 64-bit input to a 64-bit output as follows:
The inverse initial permutation operation IIP maps a 64-bit input to a 64-bit output as follows:
The DES Expansion Permutation operation maps a 32-bit input to a 48-bit output as follows:
The DES Permutation Function operation maps a 32-bit input to a 32-bit output as follows:
Additionally, the DES cipher employs eight substitution functions denoted here as “sbox1†through “sbox8.†Each of these substitution functions takes a six-bit input value B[1:6] and produces a four-bit output value S[1:4], in the following fashion. Each substitution function is depicted as an arrangement of four rows of sixteen columns. To produce the output S for a given input B, bits B[1] and B[6] are decoded to select one of the four rows, and bits B[2:5] are decoded to select one of the sixteen columns. The value indicated at the intersection of the selected row and column is then produced as the output S[1:4]. The individual substitution functions are arranged as follows (represented in decimal format):
Having defined the various operations employed by the DES cipher, the operation of the cipher itself may be given by the following pseudocode:
As seen above, the input 64-bit block is first transformed by the IP operation, and then divided into 32-bit left and right halves L—1 and R—1. During each of the 16 DES cipher rounds, the Expansion Permutation operation is applied to right half R_i to generate a 48-bit value, which is then combined with the key (selected from the generated key schedule) that corresponds to the current round. The 8 sbox operations are then applied in parallel to produce a 32-bit result to which the Permutation Function operation is then applied. The right half R_i+1 for the next round is then generated by combining the left half L_i of the current round with the result of the Permutation Function operation. The left half L_i+1 for the next round is simply the right half R_i of the current round (essentially, right half R_i shifted left by 32 bits). After the sixteenth round is complete, the IIP operation is applied to the concatenation of R—16 and L—16 to produce the 64-bit encrypted output block.
As noted above with respect to key expansion, the PC2 function may be applied to a c/d pair either after the c/d pair is generated during key expansion, or before the key is first utilized during the cipher round. The above pseudocode reflects the latter choice. However, in an embodiment where the PC2 function was applied during key expansion, it would be omitted from the cipher round.
In some embodiments, the DES key expansion and cipher functionality described above may be implemented by standard arithmetic and logical instructions that may be provided by a processor's ISA. For example, the various permutation operations may be implemented by successively masking input bits (e.g., using a logical AND instruction), shifting the masked bits to their corresponding output positions (e.g., using logical shift or rotate instructions), and combining the shifted bits into the permuted result (e.g., using a logical OR instruction). Similarly, the sbox substitution operations may be implemented as a sequence of conditional compare instructions, or as a lookup table in memory accessed via load instructions.
However, implementing the DES cipher using general-purpose ISA instructions may require numerous instructions as well as a substantial number of cycles to execute those instructions, diminishing cipher performance. By contrast, in one embodiment, DES engine 315 may be configured to provide support for certain ISA instructions that are particular to the DES cipher, such that execution of individual ones of the DES-specific instructions results in DES engine 315 performing entire corresponding portions of the DES cipher. Thus, for at least some embodiments of DES engine 315, executing the individual DES-specific instructions to implement the DES cipher may accomplish more of the work of the DES cipher per instruction than in the case of using general-purpose ISA instructions configured to perform the DES cipher.
One such embodiment of DES engine 315 is illustrated in
In one embodiment, DES key expansion unit 316 may be configured to execute a DES key expansion instruction defined within the ISA of processor 10 and denoted with the instruction mnemonic DES_KEXPAND (though any suitable mnemonic may be employed). In various embodiments, DES key expansion unit 316 may directly decode the DES_KEXPAND instruction from opcode bits sent from upstream pipeline stages, or may receive an already-decoded or partially-decoded signal indicative of the occurrence of a DES_KEXPAND instruction.
There are various possibilities for the specific behavior of the DES_KEXPAND instruction, which may exhibit a range of tradeoffs between the hardware complexity of DES key expansion unit 316 and the relative performance of key expansion (in terms of the numbers of instances of the DES_KEXPAND instruction required to generate the complete key schedule, as well as the extent to which the instances minimize dependencies among each other and thus reduce execution latency). To review the DES key expansion discussed above, in order to generate a schedule of 16 keys, the PC1 function is first applied to the input key, which is split into halves c0 and d0. Successive c/d pairs are generated by rotating the previous c/d pairs by either one or two bit positions, and application of the PC2 function to each c/d pair yields a corresponding key of the key schedule. It is noted that once pair c0/d0 is generated, each successive c/d pair may be generated as a shift function relative to the immediately preceding c/d pair, as an absolute shift function of the c0/d0 pair, or as a shift function relative to any preceding c/d pair (not necessarily the immediately preceding pair). This is partially illustrated in the following shift schedule:
As this shift schedule shows, the shift required to produce the c/d pair for a given round may be specified as a shift of one or two bit positions of the c/d pair for the immediately preceding round (shown as the “relative shift†row), or as a shift of a cumulative total of bit positions of the c0/d0 pair (shown as the “total shift†row). A large number of intermediate combinations are also possible. For example, the c6/d6 pair may be generated as a shift of the c4/d4 pair by four bits, of the c3/d3 pair by six bits, of the c2/d2 pair by seven bits, or of the c1/d1 pair by eight bits.
The properties illustrated by this shift schedule provide several possible implementations for the DES_KEXPAND instruction. Preliminarily, it is noted that in various embodiments, the DES_KEXPAND instruction may be implemented with different programmer-selectable modes of operation. For example, one of the instruction's operands may be defined as a programmer-selectable constant or immediate value that designates the desired mode of the DES_KEXPAND instruction, or as the identifier of an architectural register that contains an indication of the desired mode. When decoded by DES key expansion unit 316, each of the modes may result in a different defined behavior. The number of different modes to be supported by DES key expansion unit 316 may affect the overall hardware complexity of that unit, as discussed below.
Also, as noted previously, application of the PC2 function to the intermediate c/d value to generate the final cipher key may either be performed during DES key expansion, or during the execution of a DES round, prior to the cipher key's use. In embodiments where the DES_KEXPAND instruction applies the PC2 function, the output generated by executing the DES_KEXPAND instruction may include one or more of the cipher keys themselves in a form ready for immediate use by the DES cipher round. In other embodiments, the DES_KEXPAND instruction may not apply the PC2 function to the intermediate c/d pair. Instead, the PC2 function may be deferred to the DES_ROUND instruction discussed below, or implemented as part of a different instruction or a dedicated instruction. In such embodiments, the output generated by executing the DES_KEXPAND instruction may include one or more intermediate values (i.e., c/d pairs) that, upon application of the PC2 function, yield corresponding ones of the cipher keys.
In one embodiment, the DES key expansion unit 316 may be configured to support two selectable modes of operation of the DES_KEXPAND instruction: one that applies the PC1 operation to the initial input key, and one that implements a one-bit shift operation. For example, DES key expansion unit 316 may implement the appropriate combinatorial logic (e.g., logic gates and/or state elements) needed to implement the PC1 operation as well as the one-bit shift operation, as well as logic (e.g., a multiplexor or “mux†) configured to select the result specified by the indicated mode of the instruction. As indicated in the shift schedule above, the maximum total shift that is required is 28 bits, which may be achieved through repeated application of the one-bit shift mode of this embodiment of DES_KEXPAND. This embodiment may require little hardware complexity, though it may create serial dependencies among each of the DES_KEXPAND instructions, which may increase execution latency.
In another embodiment, DES key expansion unit 316 may be configured to support a two-bit shift mode of operation of the DES_KEXPAND instruction in addition to the one-bit shift and PC1 odes of operation described above. For example, DES key expansion unit 316 may include an additional port on a shift mux to support two-bit as well as one-bit shifts. As reflected in the shift schedule above, because some keys require a two-bit shift, explicitly providing support for this shift mode may reduce the total number of DES_KEXPAND instructions required to completely generate the key schedule. In one variant, DES key expansion unit 316 may be configured to combine the PC1 operation with a one-bit shift, such that a one-bit shift occurs when the PC1 mode of operation is selected.
As the shift schedule indicates, the c/d pair for each key may be generated as an independent function of the c0/d0 pair, according to the 16 distinct shift operations reflected in the “total shift†row of the shift schedule. Correspondingly, in one embodiment, DES key expansion unit 316 may be configured to implement support for each of these 16 shift operations, in addition to the PC1 operation, as distinct modes of operation of the DES_KEXPAND instruction. For example, DES key expansion unit 316 may include a shift mux having 16 ports corresponding respectively to the 16 different shift modes, as well as logic configured to perform the PC1 operation. Because each shift mode of this embodiment is dependent upon the same c0/d0 source, implementing each shift mode separately may eliminate dependencies among the DES_KEXPAND instructions, which may reduce the latency of performing DES key expansion, at the cost of increased hardware complexity.
One embodiment of DES key expansion unit 316 may represent an intermediate choice between hardware complexity and reduced dependencies among DES_KEXPAND instructions. In this embodiment, DES key expansion unit 316 may be configured to implement support for the PC1-plus-one-bit-shift mode of operation as well as one-bit, two-bit, and four-bit shift modes of operation of the DES_KEXPAND instruction. One example of SPARC assembly language code that reflects usage of this embodiment is as follows:
In this example, the initial two instructions load the 64-bit DES cipher key into floating-point register % f0. The second operand of the DES_KEXPAND instruction is shown as a constant that specifies one of the four modes of operation. In one embodiment, DES key expansion unit 316 may be configured to execute the first DES_KEXPAND instruction to apply the PC1 operation as well as a one-bit shift to % f0 generate the first intermediate c/d value corresponding to the first key. DES key expansion unit 316 may be further configured to execute the remaining instructions to apply the various shift operations to the results of previous operations to generate the remaining intermediate c/d values corresponding to the remaining keys. It is noted that this code represents merely one example of how a DES_KEXPAND instruction may be employed, and that numerous other applications using other variants of the instruction are possible and contemplated. For example, in other embodiments, DES_KEXPAND may be implemented to generate DES cipher keys instead of intermediate values c/d, to use the integer register file instead of the floating-point register file, and/or to generate more than one intermediate value or key per invocation of the DES_KEXPAND instruction. Further, the DES_KEXPAND instruction may be implemented in any suitable ISA.
In one embodiment, DES round unit 317 may be configured to execute a DES initial permutation instruction, a DES round instruction, and a DES inverse initial permutation instruction, each defined within the ISA of processor 10 and respectively denoted with the instruction mnemonics DES_IP, DES_ROUND, and DES_IIP (though any suitable mnemonics may be employed). In various embodiments, DES round unit 317 may directly decode these instruction from opcode bits sent from upstream pipeline stages, or may receive already-decoded or partially-decoded signals indicative of the occurrence of any of these instructions. (In other embodiments, some or all of these instructions may be implemented by distinct units within DES engine 315 according to suitable combinations, or integrated into a single, monolithic unit.)
To implement the DES_IP and DES_IIP instructions, DES round unit 317 may include logic configured to respectively apply the IP and IIP operations discussed above to a 64-bit input operand. For example, the 64-bit permutations given by each of these operations may be implemented by a 64-bit, 2-port mux that selectively reorders the bits according to either operation.
To implement the DES_ROUND instruction, DES round unit 317 may include logic configured to perform the initial DES Expansion Permutation operation, the various sbox substitution operations, the DES Permutation Function operation, and the other ancillary operations described above with respect to the DES cipher pseudocode. For example, as with any of the other features implemented by DES engine 315, the various permutation and substitution operations of the DES cipher may be implemented through the use of appropriately configured muxes or combinatorial logic according to any suitable logic and/or circuit design methodology. In one embodiment, to implement the DES_ROUND instruction, DES round unit 317 may further include logic configured to apply the PC2 function to the entry of the key schedule generated by the DES_KEXPAND instruction.
From the DES cipher pseudocode given above, it is noted that each round i of the DES cipher takes as an input a 48-bit round key (key_i), which may or may not reflect application of the PC2 function. Each round also takes a 64-bit intermediate value (expressed as 32-bit left and right halves L_i and R_i), and produces as an output a 64-bit intermediate value for use by the next round or by the IIP operation (L_i+1 and R_i+1). In some embodiments, however, the ISA implemented by processor 10 may support up to three 64-bit input operands for an instruction such as DES_ROUND. In one such embodiment, the additional input operand may be employed to provide an additional round key (denoted key_i+1), and DES round unit 317 may be configured to perform two rounds of the DES cipher for each invocation of the DES_ROUND instruction. For example, in response to receiving a DES_ROUND instruction that specifies two consecutive 48-bit round keys key_i and key_i+1 as well as a 64-bit intermediate value {L_i, R_i}, DES round unit 317 may be configured to first compute {Li+1,R_i+1} using key_i and {L_i, R_i}, and then compute {Li+2,R_i+2} using the previously-determined {Li+1,R_i+1} and key_i+1. DES round unit 317 may then produce {Li+2,R_i+2} as the result of the DES_ROUND instruction to be written back. In some embodiments, producing two rounds of the DES cipher per invocation of the DES_ROUND instruction may improve overall cipher performance, although in other embodiments, it is contemplated that fewer or more rounds may be performed per DES_ROUND instruction.
One example of SPARC assembly language code that reflects usage of the DES_IP and DES_IIP instructions and the two-rounds-per-invocation embodiment of the DES_ROUND instruction discussed above is as follows:
In this example, it is assumed that the DES key schedule has already been generated and stored within 64-bit floating-point registers % f0 through % f30. The first two instructions load the 64-bit input block to be encrypted into floating-point register % f32. DES round unit 317 may be configured to execute the DES_IP instruction to apply the IP operation to register % f32, and may be further configured to execute the DES_ROUND instructions using the specified keys from the key schedule (or intermediate values that are precursors to such keys) to compute one pair of DES rounds per instruction. Finally, DES round unit 317 may be configured to execute the DES_IIP instruction to apply the IIP operation to register % 32, which then contains the 64-bit encrypted output block. It is noted that this code represents merely one example of how the DES_IP, DES_IIP, and DES_ROUND instructions may be employed, and that numerous other applications using other variants of these instructions are possible and contemplated. For example, in other embodiments, these instructions may be implemented to use the integer register file instead of the floating-point register file. Further, these instructions may be implemented in any suitable ISA.
As noted previously, the inverse DES cipher may be implemented by executing the same operations as for the DES cipher, but with an inverted key ordering. One example of SPARC assembly language code that reflects an implementation of the inverse DES cipher is shown below. The above remarks with respect to the DES cipher may apply equally to the inverse DES cipher.
It is noted that the FIPS 46-3 standard additionally defines the “triple DES†or 3DES cipher, which is implemented as three successive applications of the DES cipher on a data block (i.e., where the 64-bit encrypted result of one cipher application forms the 64-bit input to the next cipher application) using one, two, or three distinct 64-bit keys. Because the 3DES cipher is constructed through multiple applications of the DES cipher, the above-described DES instructions may also be employed to implement the 3DES cipher.
In some embodiments of DES engine 315, the various DES-specific instructions may each require multiple execution cycles to execute. Given that each DES_ROUND instruction depends on the result of the prior instruction, during processing of a single data block from a single thread, a new DES_ROUND instruction may not be able to be issued every cycle. However, in some such embodiments, DES engine 315 may be configured to support pipelined execution, such that multiple threads or multiple different data blocks may be concurrently executing within DES engine 315, which may increase the overall utilization of DES engine 315. For example, several different threads may concurrently share DES engine 315, where a new DES_ROUND instruction from a different thread may be issued as often as every execution cycle.
In response to receiving the issued DES_KEXPAND instruction, the cryptographic unit executes the DES_KEXPAND instruction to produce one or more of the expanded keys defined by the DES cipher (block 502). For example, DES engine 315 within FGU 255 may be configured to execute the DES_KEXPAND instruction as previously described, which may include performing different types of operations according to the mode of the DES_KEXPAND instruction as specified by the instruction operands. In various embodiments, executing the DES_KEXPAND instruction may include reading instruction operands from a register file, an operand bypass unit, or another operand source, as well as writing a result to working storage or to another destination.
As noted previously, in some embodiments, execution of the DES_KEXPAND instruction may produce a value that, upon application of the PC2 operation, yields one of the expanded keys defined by the DES cipher. That is, the actual result of executing the DES_KEXPAND instruction may be an intermediate value or precursor to the final expanded key. In such embodiments, application of the PC2 operation may be incorporated into execution of another instruction, such as the DES_ROUND instruction.
In response to receiving the issued DES_IP instruction, the cryptographic unit executes the DES_IP instruction to apply the Initial Permutation operation to the specified input value (block 506). For example, DES engine 315 within FGU 255 may be configured to execute the DES_IP instruction as previously described. In various embodiments, executing the DES_IP instruction may include reading instruction operands from a register file, an operand bypass unit, or another operand source, as well as writing a result to working storage or to another destination.
In response to receiving the issued DES_IIP instruction, the cryptographic unit executes the DES_IIP instruction to apply the Inverse Initial Permutation operation to the specified input value (block 510). For example, DES engine 315 within FGU 255 may be configured to execute the DES_IIP instruction as previously described. In various embodiments, executing the DES_IIP instruction may include reading instruction operands from a register file, an operand bypass unit, or another operand source, as well as writing a result to working storage or to another destination.
In response to receiving the issued DES_ROUND instruction, the cryptographic unit executes the DES_ROUND instruction to compute one or more rounds of the DES cipher (block 514). For example, DES engine 315 within FGU 255 may be configured to execute the DES_ROUND instruction as previously described. In various embodiments, executing the DES_ROUND instruction may include reading instruction operands from a register file, an operand bypass unit, or another operand source, as well as writing a result to working storage or to another destination.
As shown in
In the following discussion, the general operation of the Kasumi cipher is first described. Examples of particular Kasumi instructions that Kasumi engine 320 may execute to implement the Kasumi cipher are then discussed, including code examples that implement such instructions.
Generally speaking, the Kasumi cipher is a block cipher that provides for the encryption and decryption of a 64-bit block of input data under the control of a 128-bit input key to produce a 64-bit block of output data. During operation, the Kasumi cipher produces a key schedule of cipher keys from the 128-bit input key, and performs multiple cipher rounds on the input data block using the key schedule. Each cipher round performs a sequence of transformation operations described in greater detail below. In some embodiments, to perform decryption, the Kasumi cipher applies the same sequence of operations as for encryption, but using the keys of the key schedule in an inverse order relative to encryption.
The Kasumi cipher provides for a 128-bit input key K and 8 cipher rounds, where each round i uses a set of keys {KLi, KOi, KIi} that is derived for that round according to a key schedule. To generate the round keys from the input key K, the 128-bit key K is first subdivided into 8 16-bit subkeys denoted K1 . . . K8, where K1 and K8 correspond to the most and least significant 16 bits of K, respectively. A second set of subkeys denoted K1′ . . . K8′ is derived by respectively applying to subkeys K1 . . . K8 a corresponding one of the hexadecimal constants listed below, using an exclusive-OR (XOR) function.
- C1=0x0123
- C2=0x4567
- C3=0x89AB
- C4=0xCDEF
- C5=0xFEDC
- C6=9xBA98
- C7=0x7654
- C8=0x3210
Using these two sets of subkeys, the individual keys for each round are generated according to the following table, where the notation Kn<<<m denotes the logical left rotate function of subkey Kn by m bits:
Each of subkeys KLi is a 32-bit value specified as a most significant 16-bit value KLi,1 and a least significant 16-bit value KLi,2. Each of subkeys KOi is a 48-bit value specified as a most significant 16-bit value KOi,1, a middle 16-bit value KOi,2, and a least significant 16-bit value KOi,3. Each of subkeys KLi is also a 48-bit value using nomenclature similar to that for subkeys KOi.
The Kasumi cipher proceeds by first dividing the input data block into two 32-bit sub-blocks denoted L0 (the most significant 32 bits) and R0 (the least significant 32 bits). The cipher then computes eight rounds I, where i proceeds from 1 to 8, and where each round outputs a pair {Li, Ri} as follows:
where XOR denotes the logical exclusive-OR function. The final cipher output is given as {L8, R8}.
The function fi(I, RKi) applies a round key RKi to a 32-bit input I to produce a 32-bit output O. The round key RKi may be further defined as the triplet of subkeys {KLi, KOi, KIi}. The behavior of function fi( ) may be defined in terms of subfunctions in a round-dependent manner. For odd-numbered rounds 1, 3, 5, and 7, fi( ) may be determined by first applying function FL( ) to input I, followed by applying function FO( ) to the result:
- fi (I,RKi)=FO ( FL (I, KLi), KOi, KIi)
For even-numbered rounds 2, 4, 6, and 8, the order of application of functions FL( ) and FO( ) is reversed: - fi (I,RKi)=FL ( FO ( I, KOi, KIi), KLi )
The FL( ) function takes a 32-bit subkey KLi, which is split into a most significant half KLi,1 and a least significant half KLi,2, as noted above. The FL( ) function also takes a 32-bit data input that is split into a most significant half L and a least significant half R. The FL( ) function produces a 32-bit output {L′, R′} as follows:
where XOR, AND, and OR denote corresponding Boolean operators.
The FO( ) function takes two 48-bit subkeys KOi and KIi, each split into three 16-bit portions KOi,1, KOi,2, KOi,3 and KIi,1, KIi,2, KIi,3, as noted above. The FO( ) function also takes a 32-bit data input that is split into a most significant half L0 and a least significant half R0. For an integer j ranging from 1 to 3, the FO( ) function computes the following:
The FO( ) function ultimately returns a 32-bit output {L3, R3}.
As seen above, the FO( ) function is expressed in terms of another function FI( ). The FI( ) function operates on a 16-bit data input that is split into a 9-bit most significant portion L0 and a 7-bit least significant portion R0. The FI( ) function also takes a 16-bit subkey KIi,j, which is split into a 9-bit most significant portion KIi,j,1 and a 7-bit least significant portion KIi,j,2. The FI( ) function makes use of two substitution functions, S9 and S7, which respectively map a 9-bit input to a 9-bit output and a 7-bit input to a 7-bit output according to the following mappings, expressed as Boolean functions. In the following, “nk†denotes bit k of a nine-bit input value, and “sk†denotes bit k of a seven-bit input value. The symbol “̂†denotes the logical XOR operator, and where two bit values appear adjacent to one another (e.g., n0n2), a logical AND operator is implied between the two values.
Using these definitions, the FI( ) function may be expressed as the following sequence of operations. Here, the notation ZE(X) denotes the conversion of a 7-bit value X to a 9-bit value by adding two zero bits to the most significant end of X (i.e., zero-extending X), and the notation TR( ) denotes the conversion of a 9-bit value Y to a 7-bit value by truncating the two most significant bits of Y.
Once these operations are complete, the FI( ) function returns the 16-bit result {L4, R4}.
To summarize, the Kasumi cipher employs a set of keys {KLi, KOi, KIi} generated for each of 8 rounds from a 128-bit input key. During each round, the cipher applies the functions FL( ) and FO( ), where FO( ) is further defined in terms of a function FI( ). During odd rounds, the general order of operations is to compute FL( ), followed by FO( ), followed by an XOR of the result with data from a prior round. During even rounds, the general order of operations is compute FO( ), followed by FL( ), followed by an XOR of the result with data from a prior round. For each application of FO( ), there are three sequences of an XOR operation, an FI( ) operation, and an XOR operation.
In some embodiments, the Kasumi key expansion and cipher functionality described above may be implemented by standard arithmetic and logical instructions that may be provided by a processor's ISA. For example, the various functions FL( ), FO( ), and/or FI( ) may be implemented through successive applications of appropriate Boolean and shift instructions. Similarly, the substitution functions S9 and S7 may be implemented as a sequence of conditional compare instructions, or as a lookup table in memory accessed via load instructions.
However, implementing the Kasumi cipher using general-purpose ISA instructions may require numerous instructions as well as a substantial number of cycles to execute those instructions, diminishing cipher performance. By contrast, in one embodiment, Kasumi engine 320 may be configured to provide support for certain ISA instructions that are particular to the Kasumi cipher, such that execution of individual ones of the Kasumi-specific instructions results in Kasumi engine 320 performing entire corresponding portions of the Kasumi cipher. Thus, for at least some embodiments of Kasumi engine 320, executing the individual Kasumi-specific instructions to implement the Kasumi cipher may accomplish more of the work of the Kasumi cipher per instruction than in the case of using general-purpose ISA instructions configured to perform the Kasumi cipher.
One such embodiment of Kasumi engine 320 is illustrated in
As noted above, in one embodiment, the general sequence of operations of the Kasumi cipher may be represented FL( ), FO( ), XOR in the case of odd rounds, and FO( ), FL( ), XOR in the case of even rounds. Additionally, FO( ) may be represented as three repetitions of the sequence XOR, FI( ), XOR. Thus, for even rounds, the general sequence of operations of the overall cipher may be represented as FL( ), 3{XOR, FI( ), XOR}, XOR, while for odd rounds, the sequence may be represented as 3{XOR, FI( ), XOR}, FL( ), XOR. It is noted that for odd rounds, the FL( ) operation is followed by a final XOR operation, while for even rounds, it is the last XOR, FI( ), XOR sequence that is followed by a final XOR operation.
In one embodiment, Kasumi FL_XOR unit 321 may be configured to execute a Kasumi FL( )-operation instruction defined within the ISA of processor 10 and denoted with the instruction mnemonic KASUMI_FL_XOR (though any suitable mnemonic may be employed). In various embodiments, Kasumi FL_XOR unit 321 may directly decode the KASUMI_FL_XOR instruction from opcode bits sent from upstream pipeline stages, or may receive an already-decoded or partially-decoded signal indicative of the occurrence of a KASUMI_FL_XOR instruction.
To execute the KASUMI_FL_XOR instruction, in one embodiment, Kasumi FL_XOR unit 321 may be configured to receive a 32-bit data input operand as well as a 32-bit subkey operand corresponding to subkey KLi. Kasumi FL_XOR unit 321 may further include logic that is configured to implement the FL( ) operation on the data input and subkey. For example, Kasumi FL_XOR unit 321 may include appropriate combinatorial logic configured to implement the Boolean and shift operations (or their logical equivalents) specified for the FL( ) operation.
In one embodiment, to execute the KASUMI_FL_XOR instruction, Kasumi FL_XOR unit 321 may further be configured to receive a third data input operand and to combine this third operand with the result of the FL( ) operation using an XOR operation. As noted above, for odd rounds of the cipher, the FL( ) operation result is XORed with data from an earlier round to form a portion of the result for the current round. Thus, to implement an odd round of the Kasumi cipher, the KASUMI_FL_XOR instruction may be issued for execution with the prior round data specified as the third operand.
By contrast, to implement an even round of the Kasumi cipher where the FL( ) operation is not followed by a discrete XOR operation, the KASUMI_FL_XOR instruction may be issued for execution with a zeroed-out third operand. Because the result of XORing any value with zero is the original value, this may essentially nullify the effect of the XOR when the KASUMI_FL_XOR instruction is issued during even cipher rounds.
In the embodiment of
In one embodiment, to execute the KASUMI_FI_FI instruction, Kasumi FI_FI unit 322 may be configured to implement the first two of the three sequences of XOR, FI( ), XOR operations specified by the Kasumi cipher. In this embodiment, Kasumi FI_FI unit 322 may be configured to receive a 32-bit data input operand as well as the subkeys KOi,1, KOi,2 and KIi,1, KIi,2. In various embodiments, the four 16-bit subkeys may be concatenated together as a single 64-bit operand or supplied to Kasumi FI_FI unit 322 as two distinct 32-bit operands. Kasumi FI_FI unit 322 may further include logic that is configured to implement the two sequences of XOR, FI( ), XOR operations on the data input and subkeys. For example, Kasumi FI_FI unit 322 may include appropriate combinatorial logic configured to implement the various XOR operations as well as the S9 and S7 substitution functions specified for the FI( ) operation.
In one embodiment, to execute the KASUMI_FI_XOR instruction, Kasumi FI_XOR unit 323 may be configured to implement the final one of the three sequences of XOR, FI( ), XOR operations specified by the Kasumi cipher. In this embodiment, Kasumi FI_XOR unit 323 may be configured to receive a 32-bit data input operand as well as the subkeys KOi,3 and KIi,3. Kasumi FI_XOR unit 323 may further include logic that is configured to implement the final sequence of XOR, FI( ), XOR operations on the data input and subkeys. For example, Kasumi FI_XOR unit 323 may include appropriate combinatorial logic configured to implement the various XOR operations as well as the S9 and S7 substitution functions specified for the FI( ) operation. In some embodiments, Kasumi FI_XOR unit 323 and Kasumi FI_FI unit 322 may share some or all of their logic.
As noted above, for even cipher rounds, the final sequence of XOR, FI( ), XOR operations is followed by an XOR operation to combine the result with data from an earlier round to form a portion of the result for the current round. Correspondingly, to execute the KASUMI_FI_XOR instruction, one embodiment of Kasumi FI_XOR unit 323 may further be configured to receive a third data input operand and to combine this third operand with the result of the final sequence of XOR, FI( ), XOR operations using an XOR operation. Thus, to implement an even round of the Kasumi cipher, the KASUMI_FI_XOR instruction may be issued for execution with the prior round data specified as the third operand.
By contrast, to implement an odd round of the Kasumi cipher where the final sequence of XOR, FI( ), XOR operations is not followed by a discrete XOR operation, the KASUMI_FI_XOR instruction may be issued for execution with a zeroed-out third operand. As noted above with respect to the KASUMI_FL_XOR instruction, this may essentially nullify the effect of the XOR when the KASUMI_FI_XOR instruction is issued during odd cipher rounds.
It is noted that the above discussion represents merely one possible definition of Kasumi-specific instructions and a corresponding configuration of Kasumi engine 320. Other embodiments representing different instruction definitions and underlying execution hardware are possible and contemplated. For example, while the KASUMI_FL_XOR and KASUMI_FI_XOR instructions explicitly provide for an XOR operation following the FL( ) or XOR, FI( ), XOR operations, in alternative embodiments, Kasumi engine 320 may be configured to implement certain operations alone or in combination with different operations. For example, in response to a KASUMI_FL or similar instruction, one embodiment of Kasumi engine 320 might be configured only to perform the FL( ) operation, leaving a subsequent XOR operation—if one is needed—to be implemented as part of another Kasumi-specific instruction or by a general purpose XOR instruction selected from the ISA of processor 10. Generically, instructions that implement at least one instance of the Kasumi FL( ) operation may be referred to as Kasumi FL( )-operation instructions, regardless of whatever other operations such instructions might perform. Similarly, instructions that implement at least one instance of the Kasumi FI( ) operation may be referred to as Kasumi FI( )-operation instructions, regardless of whatever other operations such instructions might perform.
Similarly, in response to a KASUMI_FI or similar instruction, one embodiment of Kasumi engine 320 might be configured only to perform the FI( ) function alone, leaving the remaining XOR operations to be implemented by other instructions. Alternatively, instead of mapping the three sequences of XOR, FI( ), XOR operations onto two instructions as described above, one embodiment of Kasumi engine 320 might be configured to perform all three of these sequences in response to receiving a single KASUMI_FI or similar instruction.
One example of SPARC assembly language code that reflects usage of the KASUMI_FL_XOR, KASUMI_FI_FI, and KASUMI_FI_XOR instructions discussed above is as follows:
In this example, it is assumed that the Kasumi key schedule has already been generated and stored within 64-bit floating-point registers % f0 through % f46 (e.g., by a separately-executed set of instructions). The first group of instructions loads the left and right 32 bits of the 64-bit input block into registers % f52 and % f54, respectively, and initializes register % f56 to zero.
In the illustrated example, each of the eight rounds of the Kasumi cipher is implemented by one group of three instructions, where the group varies according to whether the round is odd or even. During the first round, Kasumi FL_XOR unit 321 may be configured to execute the KASUMI_FL_XOR instruction, with the left half of the data input (in register % f52) specified as the first operand and the relevant first-round keys (in register % f0) specified as the second operand. Because the XOR function of the KASUMI_FL_XOR instruction is not relevant during odd rounds, the third operand is set to zero (via register % f56). The output of the KASUMI_FL_XOR instruction is temporarily stored in register % f58. Kasumi FI_FI unit 322, via execution of the KASUMI_FI_FI instruction, may receive this result as its first operand, as well as the relevant first-round keys (in register % f2) specified as the second operand, and may store the result of the first two XOR, FI( ), XOR sequences in register % f58. Finally, Kasumi FI_XOR unit 323, via execution of the KASUMI_FI_XOR instruction, may receive the result of the KASUMI_FI_FI instruction via register % f58 as its first operand, as well as the relevant first-round keys (in register % f4) specified as the second operand. Additionally, the initial right-half data is provided (via register % f54) as the third operand, to be XORed with the result of the final XOR, FI( ), XOR sequence to produce the final result of the first round, which is stored in register % f54.
The second round proceeds in a similar fashion, though with the instructions executed in a different order to reflect the order of operations that applies to even rounds. It can be seen from the code that in this instance, the KASUMI_FI_XOR instruction is not the final instruction of the round, and thus its third operand is set to zero (via register % f56). Consistent with the Kasumi cipher, the left and right halves of the working data block are swapped after each round. Because these halves are stored in different registers in the illustrated example, the swap may be effected by simply exchanging which register is referenced. After the final round executes, the encrypted block is stored within registers % f52 and % f54. As noted above, decryption may be performed by executing the Kasumi cipher with a reversed key order relative to encryption.
It is noted that this code represents merely one example of how the KASUMI_FL_XOR, KASUMI_FI_FI, and KASUMI_FI_XOR instructions may be employed, and that numerous other applications using other variants of these instructions are possible and contemplated. For example, in other embodiments, these instructions may be implemented to use the integer register file instead of the floating-point register file. Further, these instructions may be implemented in any suitable ISA.
In some embodiments of Kasumi engine 320, the various Kasumi-specific instructions may each require multiple execution cycles to execute. Given that each instruction depends on the result of the prior instruction, during processing of a single data block from a single thread, a new Kasumi instruction may not be able to be issued every cycle. However, in some such embodiments, Kasumi engine 320 may be configured to support pipelined execution, such that multiple threads or multiple different data blocks may be concurrently executing within Kasumi engine 320, which may increase the overall utilization of Kasumi engine 320. For example, several different threads may concurrently share Kasumi engine 320, where a new KASUMI_FL_XOR, KASUMI_FI_FI, or KASUMI_FI_XOR instruction from a different thread may be issued as often as every execution cycle.
In response to receiving the issued KASUMI_FL_XOR instruction, the cryptographic unit executes the KASUMI_FL_XOR instruction to apply the Kasumi FL( ) operation to the specified input value using specified keys (block 702). For example, Kasumi engine 320 within FGU 255 may be configured to execute the KASUMI_FL_XOR instruction as previously described, which may include performing an additional XOR operation on the result of the FL( ) operation using a third specified operand. In various embodiments, executing the KASUMI_FL_XOR instruction may include reading instruction operands from a register file, an operand bypass unit, or another operand source, as well as writing a result to working storage or to another destination.
In response to receiving the issued KASUMI_FI_FI instruction, the cryptographic unit executes the KASUMI_FI_FI instruction to apply the Kasumi FI( ) operation to the specified input value (block 706). For example, Kasumi engine 320 within FGU 255 may be configured to execute the KASUMI_FI_FI instruction as previously described, by performing the initial two applications of the XOR, FI( ), XOR sequence specified by the Kasumi cipher. In various embodiments, executing the KASUMI_FI_FI instruction may include reading instruction operands from a register file, an operand bypass unit, or another operand source, as well as writing a result to working storage or to another destination.
In response to receiving the issued KASUMI_FI_XOR instruction, the cryptographic unit executes the KASUMI_FI_XOR instruction to apply the Kasumi FI( ) operation to the specified input value (block 710). For example, Kasumi engine 320 within FGU 255 may be configured to execute the KASUMI_FI_XOR instruction as previously described, which may include performing the third sequence of XOR, FI( ), XOR operations specified by the Kasumi cipher, as well as an additional XOR operation on the result of this third sequence using a third specified operand. In various embodiments, executing the KASUMI_FI_XOR instruction may include reading instruction operands from a register file, an operand bypass unit, or another operand source, as well as writing a result to working storage or to another destination.
As shown in
In the following discussion, the general operation of the Camellia cipher is first described. Examples of particular Camellia instructions that Camellia engine 325 may execute to implement the Camellia cipher are then discussed, including code examples that implement such instructions.
Generally speaking, the Camellia cipher is a block cipher that provides for the encryption and decryption of a 128-bit block of input data under the control of an input key that may be 128, 192, or 256 bits. During operation, the Camellia cipher produces a key schedule of cipher keys from the input key, and performs multiple cipher rounds on the input data block using the key schedule. Each cipher round performs a sequence of transformation operations described in greater detail below. In some embodiments, to perform decryption, the Camellia cipher applies same sequence of operations as for encryption, but using the keys of the key schedule in an inverse order relative to encryption.
Key schedule generation for the Camellia begins with generating two 128-bit values KL and KR from the input key K according to one of the following groups of operations, depending on whether K is 128, 192, or 256 bits wide. In contrast to the discussion of the DES cipher above, in the following discussion, the least significant bit of a multi-bit value is denoted bit 0. Also, in the following discussion, “<<n†denotes a logical left shift by n bits, “>>n†denotes a logical right shift by n bits, and “˜†denotes the bitwise complement operator.
Two additional 128-bit quantities, KA and KB, are generated from KL and KR as follows.
Here, tmp1 and tmp2 denote temporary variables. MASK64 denotes a 64-bit quantity consisting of all 1s. The F( ) operation is described in greater detail below. Sigmal through Sigma6 denote 64-bit constants having the following values:
A set of 64-bit subkeys may then be generated as a function of the 128-bit values KL, KR, KA, and KB. For 128-bit keys, there are 26 subkeys denoted kw1 . . . kw4, k1 . . . k18, and ke1 . . . ke4 and generated as follows. As before, “<<<n†denotes a logical left rotate by n bits.
For 192- and 256-bit keys, there are 34 subkeys denoted kw1 . . . kw4, k1 . . . k24, and ke1 . . . ke6 and generated as follows:
In the case of a 128-bit input key, the Camellia cipher may be represented by the following pseudocode, where M[127:0] denotes the input message and C[127:0] denotes the output ciphertext (i.e., the encrypted message):
Here, the input message is first combined with keys kw1 and kw2. Then, 18 rounds are performed using the 18 64-bit keys k1 . . . k18 from the key schedule. During the sixth and twelfth rounds, keys ke1 . . . ke4 are applied. Finally, the output ciphertext is derived by combining the result of the last round with keys kw3 and kw4. The F( ), FL( ) and FLI( ) operations will be described in greater detail below.
For 192-bit and 256-bit input keys, the Camellia cipher may be represented by the following pseudocode:
Operation is similar to the case involving 128-bit keys. Here, the input message is first combined with keys kw1 and kw2. Then, 24 rounds are performed using the 24 64-bit keys k1 . . . k24 from the key schedule. During the sixth, twelfth, and eighteenth rounds, keys ke1 . . . ke6 are applied. Finally, the output ciphertext is derived by combining the result of the last round with keys kw3 and kw 4.
As noted previously, decryption may be performed using the same operations as encryption, but with an inverted key order. That is, where keys kw1 . . . kw4, k1 . . . k18/k24, and ke1 . . . ke4/ke6 are used for encryption in the above pseudocode, keys kw4 . . . kw1, k18/k24 . . . k1, ke4/ke6 . . . ke1 may be substituted to effect decryption.
As seen above, the Camellia F( ) operation is applied during each cipher round. It receives 64-bit input data F_IN as well as a 64-bit subkey KI, and produces a 64-bit result F_OUT according to the following pseudocode:
Here, MASK8 denotes an 8-bit quantity consisting of all 1s. Each of SBOX1 through SBOX4 are substitution functions that produce an 8-bit output from an 8-bit input. The SBOX1 function is defined by the following table:
Here, the most significant four bits of the input to SBOX1 selects a row of the table, and the least significant four bits selects a column. The value at the intersection of the selected row and column is the output value (shown here in decimal format). Each of SBOX2 through SBOX4 are defined in terms of the SBOX1 function as follows:
The Camellia FL( ) and FLI( ) operations are applied during certain cipher rounds as noted above. The FL( ) operation receives 64-bit input data FL_IN as well as a 64-bit subkey KI, and produces a 64-bit result FL_OUT. (It is noted that the Camellia FL( ) operation is entirely distinct from the Kasumi FL( ) operation described above.) The FLI( ) operation receives 64-bit input data FLI_IN as well as a 64-bit subkey KI, and produces a 64-bit result FLI_OUT. FL( ) and FLI( ) respectively operate according to the following pseudocode:
In some embodiments, the Camellia key expansion and cipher functionality described above may be implemented by standard arithmetic and logical instructions that may be provided by a processor's ISA. For example, the various functions F( ), FL( ), and/or FLI( ) may be implemented through successive applications of appropriate Boolean and shift instructions. Similarly, the substitution function SBOX1 may be implemented as a sequence of conditional compare instructions, or as a lookup table in memory accessed via load instructions.
However, implementing the Camellia cipher using general-purpose ISA instructions may require numerous instructions as well as a substantial number of cycles to execute those instructions, diminishing cipher performance. By contrast, in one embodiment, Camellia engine 325 may be configured to provide support for certain ISA instructions that are particular to the Camellia cipher, such that execution of individual ones of the Camellia-specific instructions results in Camellia engine 325 performing entire corresponding portions of the Camellia cipher. Thus, for at least some embodiments of Camellia engine 325, executing the individual Camellia-specific instructions to implement the Camellia cipher may accomplish more of the work of the Camellia cipher per instruction than in the case of using general-purpose ISA instructions configured to perform the Camellia cipher.
One such embodiment of Camellia engine 325 is illustrated in
In one embodiment, Camellia F unit 326 may be configured to execute a Camellia F( ) operation instruction defined within the ISA of processor 10 and denoted with the instruction mnemonic CAMELLIA_F (though any suitable mnemonic may be employed). In various embodiments, Camellia F unit 326 may directly decode the CAMELLIA_F instruction from opcode bits sent from upstream pipeline stages, or may receive an already-decoded or partially-decoded signal indicative of the occurrence of a CAMELLIA_F instruction.
To execute the CAMELLIA_F instruction, in one embodiment, Camellia F unit 326 may be configured to receive a 64-bit data input operand as well as a 64-bit subkey operand KI corresponding to the current round of the cipher. Camellia F unit 326 may further include logic that is configured to implement the F( ) operation on the data input and subkey. For example, Camellia F unit 326 may include appropriate combinatorial logic configured to implement the Boolean and shift operations (or their logical equivalents) specified for the F( ) operation, as well as combinatorial or other logic configured to implement the Camellia SBOX1, SBOX2, SBOX3, and SBOX4 substitution operations.
As reflected in the Camellia cipher pseudocode given above, the output of the F( ) function is combined with a portion of the data block from a previous round using an XOR operation. In one embodiment, to execute the CAMELLIA_F instruction, Camellia F unit 326 may further be configured to receive a third data input operand that corresponds to the data from the previous round, and to combine this third operand with the result of the F( ) operation using an XOR operation.
In one embodiment, Camellia FL unit 327 may be configured to execute a Camellia FL( ) operation instruction defined within the ISA of processor 10 and denoted with the instruction mnemonic CAMELLIA_FL (though any suitable mnemonic may be employed). In various embodiments, Camellia FL unit 327 may directly decode the CAMELLIA_FL instruction from opcode bits sent from upstream pipeline stages, or may receive an already-decoded or partially-decoded signal indicative of the occurrence of a CAMELLIA_FL instruction.
To execute the CAMELLIA_FL instruction, in one embodiment, Camellia FL unit 327 may be configured to receive a 64-bit data input operand as well as a 64-bit subkey operand KI corresponding to the current round of the cipher. Camellia FL unit 327 may further include logic that is configured to implement the FL( ) operation on the data input and subkey. For example, Camellia FL unit 327 may include appropriate combinatorial logic configured to implement the Boolean and shift operations (or their logical equivalents) specified for the FL( ) operation.
In one embodiment, Camellia FL( ) unit 328 may be configured to execute a Camellia FLI( ) operation instruction defined within the ISA of processor 10 and denoted with the instruction mnemonic CAMELLIA_FLI (though any suitable mnemonic may be employed). In various embodiments, Camellia FLI unit 328 may directly decode the CAMELLIA_FLI instruction from opcode bits sent from upstream pipeline stages, or may receive an already-decoded or partially-decoded signal indicative of the occurrence of a CAMELLIA_FLI instruction.
To execute the CAMELLIA_FLI instruction, in one embodiment, Camellia FLI unit 328 may be configured to receive a 64-bit data input operand as well as a 64-bit subkey operand KI corresponding to the current round of the cipher. Camellia FLI unit 328 may further include logic that is configured to implement the FLI( ) operation on the data input and subkey. For example, Camellia FLI unit 328 may include appropriate combinatorial logic configured to implement the Boolean and shift operations (or their logical equivalents) specified for the FLI( ) operation.
One example of SPARC assembly language code that reflects usage of the CAMELLIA_F, CAMELLIA_FL, and CAMELLIA_FLI instructions discussed above to perform encryption using a 128-bit input key is as follows:
In this example, it is assumed that the Camellia key schedule has already been generated and stored within 64-bit floating-point registers % f0 through % f50 (e.g., by a separately-executed set of instructions). The first group of instructions loads the 128-bit input block into registers % f52 and % f54, and the FXOR instructions apply keys kw1 and kw2 to the input block.
In the illustrated example, each of the 18 rounds of the Camellia cipher is implemented by a corresponding instance of the CAMELLIA_F instruction, which may be executed by Camellia F unit 326. The first operand of the CAMELLIA_F instruction specifies the subkey input KI, and the second operand specifies the input data to the F( ) operation. The third operand specifies the prior round data that is to be XORed with the result of the F( ) operation. The fourth operand specifies the destination register for the result of the round. Consistent with the Camellia cipher, the left and right 64-bit halves of the 128-bit working data block are swapped after each round. Because these halves are stored in different registers in the illustrated example, the swap may be effected by simply exchanging which register is referenced, as shown in the above code.
After the sixth and twelfth rounds, the CAMELLIA_FL and CAMELLIA_FLI instructions are given, which may be respectively executed by Camellia FL unit 327 and Camellia FLI unit 328. For each of these instructions, the first operand specifies the subkey input KI, and the second operand specifies the input data to the FL( ) or FLI( ) operation. After the final round, the final group of FXOR instructions apply keys kw3 and kw4 to generate the resultant encrypted block.
One example of SPARC assembly language code that reflects usage of the CAMELLIA_F, CAMELLIA_FL, and CAMELLIA_FLI instructions discussed above to perform encryption using a 192-bit or 256-bit input key is as follows:
The operation of this code is largely similar to that discussed above for the 128-bit example. However, in this case, certain keys (e.g., kw1 through kw4) may be stored in the integer register file, and applied using integer XOR instructions rather than floating-point FXOR instructions. (Here, the result of the first two XOR instructions is moved to the floating-point register file for use during cipher rounds, while the result of the last cipher round is moved back to the integer register file for use during the final two XOR instructions.) In other embodiments, all keys may be stored entirely within one register file. In contrast to the 128-bit example, this code example reflects 24 rounds as well as application of the FL( ) and FLI( ) operations after the eighteenth round.
It is noted that this code represents merely one example of how the CAMELLIA_F, CAMELLIA_FL, and CAMELLIA_FLI instructions may be employed, and that numerous other applications using other variants of these instructions are possible and contemplated. For example, in other embodiments, these instructions may be implemented to use the integer register file instead of the floating-point register file. Further, these instructions may be implemented in any suitable ISA. Generically, instructions that implement at least one instance of the Camellia F( ) operation may be referred to as Camellia F( )-operation instructions, regardless of whatever other operations such instructions might perform. Similarly, instructions that implement at least one instance of the Camellia FL( ) operation or the Camellia FLI( ) may respectively be referred to as Camellia FL( )-operation instructions or Camellia FLI( )-operation instructions, regardless of whatever other operations such instructions might perform.
In some embodiments of Camellia engine 325, the various Camellia-specific instructions may each require multiple execution cycles to execute. Given that many of the instructions depend on the result of the prior instruction, during processing of a single data block from a single thread, a new Camellia instruction may not be able to be issued every cycle. However, in some such embodiments, Camellia engine 325 may be configured to support pipelined execution, such that multiple threads or multiple different data blocks may be concurrently executing within Camellia engine 325, which may increase the overall utilization of Camellia engine 325. For example, several different threads may concurrently share Camellia engine 325, where a new CAMELLIA_F, CAMELLIA_FL, or CAMELLIA_FLI instruction from a different thread may be issued as often as every execution cycle.
In response to receiving the issued CAMELLIA_F instruction, the cryptographic unit executes the CAMELLIA_F instruction to apply the Camellia F( ) operation to the specified input value using specified keys (block 902). For example, Camellia engine 325 within FGU 255 may be configured to execute the CAMELLIA_F instruction as previously described, which may include performing an additional XOR operation on the result of the F( ) operation using a third specified operand. In various embodiments, executing the CAMELLIA_F instruction may include reading instruction operands from a register file, an operand bypass unit, or another operand source, as well as writing a result to working storage or to another destination.
In response to receiving the issued CAMELLIA_FL instruction, the cryptographic unit executes the CAMELLIA_FL instruction to apply the Camellia FL( ) operation to the specified input value (block 906). For example, Camellia engine 325 within FGU 255 may be configured to execute the CAMELLIA_FL instruction as previously described. In various embodiments, executing the CAMELLIA_FL instruction may include reading instruction operands from a register file, an operand bypass unit, or another operand source, as well as writing a result to working storage or to another destination.
In response to receiving the issued CAMELLIA_FLI instruction, the cryptographic unit executes the CAMELLIA_FLI instruction to apply the Camellia FLI( ) operation to the specified input value (block 910). For example, Camellia engine 325 within FGU 255 may be configured to execute the CAMELLIA_FLI instruction as previously described. In various embodiments, executing the CAMELLIA_FLI instruction may include reading instruction operands from a register file, an operand bypass unit, or another operand source, as well as writing a result to working storage or to another destination.
As shown in the embodiment of
The following discussion will describe the general operation of the AES cipher including pseudocode of the various AES cipher algorithms. Examples of the AES instructions that AES engine 310 may execute to implement the AES cipher are then discussed, including code examples that implement those instructions.
Generally speaking, the AES cipher is a block cipher that performs encryption/decryption of a 128-bit data block using initial cipher keys having sizes of 128, 192 or 256 bits. The selected initial key may be supplied to the cipher as an argument along with the data block to be encrypted/decrypted. As described in greater detail below, the AES cipher uses a number of iterative loops or cipher rounds to encrypt or decrypt a data block. The AES cipher may use a unique 128-bit key for each cipher round following the application of the initial key. Thus, for initial AES cipher key lengths of 128, 192 and 256 bits requiring 10, 12 and 14 rounds, respectively, a total of 11, 13, or 15 128-bit keys (or 44, 52, or 60 32-bit keys) are required to provide a unique key per round following application of the initial key.
The AES cipher can be broken down into three sections: key expansion, encryption, and decryption. As mentioned above, the unique cipher keys for each round may be generated from the initial cipher key according to a key expansion algorithm. The set of keys resulting from the operation of the key expansion algorithm may be referred to as the expanded set of keys, and each member of the expanded set may correspond to a particular round of the cipher algorithm. (In some embodiments, the expanded set of keys may also include the initial cipher key.) One pseudocode representation of an AES key expansion algorithm is given below:
As shown in the above representation, Nr represents the number of rounds performed by the AES algorithm, and varies according to the size of the initial cipher key as described above. Nk represents the number of 32-bit words comprising the initial cipher key. For example, for 128-bit, 196-bit and 256-bit initial cipher keys, Nk equals 4, 6 and 8, respectively. Further Ne represents the total number of expanded keys. As shown, the number of expanded keys is dependent on the size of the initial cipher key. Thus, for 128-bit, 196-bit and 256-bit initial cipher keys, Ne equals 44, 52 and 60 expanded keys, respectively. The expanded set of cipher keys may sometimes be referred to as the key schedule. The pseudocode illustrating the AES cipher algorithm as given below, shows how the algorithm may progress through the expanded key set as rounds of the algorithm complete.
In the above pseudocode representation, SubWord( ) is a function that takes a four-byte input word and applies the SBOX substitution transformation function to each of the four bytes to produce an output word. RotWord( ) is a function that takes a word {a0,a1,a2,a3} as input, performs a cyclic byte permutation, and returns the word {a1,a2,a3,a0}. Rcon[i] “round constant word array†contains the values given by [x(i−1), {00},{00},{00}], with x(i−1) being powers of x (x is denoted as {02}) in the field GF(28). Note that i starts at 1, and not 0.
In this AES key expansion algorithm, the initial cipher key is copied into the first Nk 32-bit words of the expanded set, as illustrated by the first for loop. Subsequently, in most cases each 32-bit word of the expanded set is a logical exclusive-OR (XOR) function of the immediately previous word and the Nk-previous word. That is, word i of the expanded set is generally a function of word i−1 and word i−Nk.
As illustrated in the AES key expansion algorithm, for every Nk words (that is, for each word i of the expanded set for which i mod Nk=0), several transformations are applied to word i−1 prior to the XOR with word i−Nk. Specifically, the RotWord transformation may, in one embodiment, cyclically rotate the bytes of word i−1 left by one byte position. It is noted that in some embodiments, the RotWord transformation may be analogous to the ShiftRows transformation of the AES cipher algorithm for row 1 of the cipher state, as described below. Additionally, the SubWord transformation may, in one embodiment, comprise applying the SubBytes function of the AES cipher algorithm, as described above, to each byte of word i−1. Following the SubWord transformation, the resulting word is XORed with a round constant Rcon, which may vary according to the specific word i being generated. It is noted that in the illustrated embodiment, when Nk=8 (i.e., a 256-bit initial AES cipher key is being used), an additional SubWord transformation is specified for each word i of the expanded set for which i mod Nk=4.
As an example, executing the above pseudocode for an initial AES cipher key of 128 bits (Nk=4) may result in words w[0] through w[3] being assigned the corresponding words of the initial cipher key. Subsequent words of the expanded set may be determined as follows:
In this embodiment, generation of the expanded set of cipher keys is generally dependent upon the initial cipher key in a sequential fashion, where later-generated cipher keys have increasing dependency on earlier-generated cipher keys.
In the AES cipher, operations are performed on a two-dimensional array of bytes having a plurality of rows and columns. This two-dimensional array is referred to as the cipher state. One such arrangement is illustrated in
Following an initial step of adding a key to cipher state 1012, each round in the iterative loop of the above representation of the AES cipher includes applying the four functions or steps to cipher state 1012 described above. (Each of which may be generically referred to as a byte-substitution step, a row-shifting step, a column-mixing step, and an add-round-key step, respectively.) In one embodiment, the SubBytes (SB) function may include applying a particular transformation to each byte of cipher state 1012, which in one implementation of the AES cipher may include taking a multiplicative inverse of the byte as defined in the finite Galois field GF(28) and applying an affine transformation to the result. The ShiftRows (SR) function may, in one embodiment, include cyclically shifting or rotating zero or more bytes of a given row of cipher state 1012 from a lower-numbered column to a higher-numbered column. For example, in one embodiment the SR function may leave row 0 of cipher state 1012 unmodified, shift byte s(1,0) to column 3 while shifting the remaining bytes of row 1 left one column, shift bytes s(2,0) and s(2,1) to columns 2 and 3, respectively, while shifting the remaining bytes of row 2 left two columns, and shift bytes s(3,0), s(3,1) and s(3,2) to columns 1, 2 and 3, respectively, while shifting the remaining byte of row 3 left three columns.
In one embodiment, the MixColumns (MC) function may include multiplying each column of cipher state 1012 by a fixed matrix, which may represent a polynomial multiplication in GF(28). Finally, the AddRoundKey (ARK) function may, in one embodiment, include adding a cipher key appropriate to the particular round to each column of cipher state 1012. It is noted that in some embodiments, mathematical operations defined over field elements may differ in implementation from ordinary integer arithmetic. For example, addition of field elements may be implemented as an exclusive-OR (XOR) operation rather than an integer addition operation. More details about each of the AES functions described above may be found in the FIPS 197 publication referenced above.
It is noted that while the pseudocode example of the AES cipher given above illustrated the behavior of a cipher encryption operation, a cipher decryption operation may use inverse functions in a similar fashion. For example, a decryption round of the AES cipher may apply the inverses of the ShiftRows, SubBytes, AddRoundKey, and MixColumns functions (e.g., InvShiftRows, InvSubBytes, AddRoundKey and InvMixColumns) in that order. One pseudocode representation of a version of the AES cipher for decrypting a data block is given below:
In some embodiments, the AES key expansion and cipher functionality described above may be implemented by standard arithmetic and logical instructions that may be provided by a processor's ISA. For example, the sbox substitution operations may be implemented as a sequence of conditional compare instructions, or as a lookup table in memory accessed via load instructions.
However, implementing the AES cipher using general-purpose ISA instructions may require numerous instructions as well as a substantial number of cycles to execute those instructions, diminishing cipher performance. In one embodiment, AES engine 310 may be configured to provide support for certain ISA instructions that are particular to the AES cipher, such that execution of individual ones of the AES-specific instructions results in AES engine 310 performing entire corresponding portions of the AES cipher. For example, as described further below, the AES engine 310 may support AES key expansion instructions and AES Round instructions for both encryption and decryption.
One such embodiment of AES engine 310 is illustrated in
In various embodiments, SPU 300 may also include additional logic not shown, such as additional cipher algorithm control logic, combinatorial logic, and/or logic configured to perform different types of operations. Collectively, the illustrated features of AES Engine 310 may be configured to implement the AES cipher as described above. It is noted that in some embodiments, SR logic 1032 may be included within state storage 311 or coupled between state storage 311 and cipher pipeline 312. Additionally, AES engine 310 may utilize the floating point register file (FRF) and/or the integer register file (IRF) (e.g., working register files 260 of
State storage 311 may be any type of structure suitable for storing the cipher state 1012, which is operated on by the AES cipher. For example, in various embodiments state storage 311 may be configured as a register file, a random access memory (RAM), a queue, or any other suitable data structure. In some embodiments, state storage 311 may provide storage for state in addition to cipher state 1012. For example, cipher state 1012 may include state (such as a data block) currently undergoing iterative processing by cipher pipeline 312. Additionally, in one embodiment, state storage 311 may provide additional storage for a next data block to be processed after processing of cipher state 1012 completes. After processing of current cipher state 1012 completes, a next data block may become the new value of cipher state 1012.
In one embodiment, key expansion pipeline 314, in combination with control logic 313, may be configured to execute AES key expansion instructions defined within the ISA of processor 10 and denoted with the following instruction mnemonics: AES_KEXPAND0, AES_KEXPAND1, and AES_KEXPAND2 (though any suitable mnemonics may be employed). These instructions may be referred to collectively in the following discussions as the AES_KEXPAND instructions, where appropriate. In various embodiments, the control logic 313 may directly decode the AES_KEXPAND instructions from opcode bits sent from upstream pipeline stages, or may receive already-decoded or partially-decoded signals indicative of the occurrence of AES_KEXPAND instructions. Control logic 313 may responsively provide corresponding control signals to the key expansion pipeline 314 to execute the AES_KEXPAND instructions.
In one embodiment, the AES_KEXPAND0 instruction generates two 32-bit keys using SubBytes, XOR, and an additional XOR to create the second key. The AES_KEXPAND1 instruction generates two 32-bit keys using RotWord, SubBytes, Rcon, XOR, XOR, and an additional XOR to create the second key. The AES_KEXPAND2 instruction generates two 32-bit keys using XOR and an additional XOR to create the second key.
In one embodiment, SB logic 1034 and RXR logic 1040 may be implemented as pipeline stages configured to implement corresponding steps of generating a member of the expanded key set according to the key expansion algorithm above. For example, SB logic 1034 may be configured to perform the SubBytes transformation that comprises the SubWord transformation illustrated in the AES key expansion algorithm pseudocode shown above. Further, RXR logic 1040 may be configured to conditionally perform the RotWord and XOR functions shown in the AES key expansion algorithm, along with selecting the appropriate Rcon constant, if necessary. It is noted that in other embodiments, key expansion pipeline 314 may be partitioned differently into different stages and/or elements, and may implement functions in addition to or distinct from the AES key expansion functions illustrated.
In the illustrated embodiment, SB logic 1034 is shared between key expansion pipeline 314 and cipher pipeline 312. Further, SPU 300 may be configured to operate in a key expansion mode of operation, during which a key expansion algorithm executes, as well as a cipher mode of operation, during which a cipher algorithm executes. For example, SPU 300 may be configured to generate the complete set of expanded keys to be used during encryption/decryption in the key expansion mode of operation prior to commencing cipher execution during the cipher mode of operation.
It is noted that although the AES key expansion pseudocode given above illustrates that the innermost RotWord transformation is performed prior to the SubWord transformation, an equivalent result may be obtained by performing these transformations in the opposite order, as described above with respect to the ShiftRows and SubBytes functions of the AES cipher algorithm. In various embodiments of key expansion pipeline 314, these steps may be implemented in either order. Additionally, it is noted that in general, one or more portions of key expansion pipeline 314 may be configured to perform cipher algorithm steps regardless of whether any stage of cipher pipeline 312 is configured to concurrently process all or fewer than all columns of cipher state 1012. That is, functional overlap and sharing may occur between key expansion pipeline 314 and cipher pipeline 312 in instances where cipher pipeline 312 concurrently processes all of cipher state 1012, in addition to instances where stages of cipher pipeline 312 concurrently process fewer than all columns of cipher state 1012.
One example of SPARC assembly language code that illustrates the use of the AES_KEXPAND instructions to expand a 128-bit key is as follows:
In this exemplary code sequence, the first two instructions load the initial 128-bit AES cipher key into floating-point registers % f0 and % f2. The third operand of the AES_KEXPAND1 instruction is shown as a constant that is used to select the Rcon constant. In one embodiment, SB 434 and RXR 440 of key expansion pipeline 314 may be configured to execute the first AES_KEXPAND1 instruction to generate the fifth and sixth 32-bit expanded keys (e.g., w[4] and w[5]) and to store them in the floating-point register % f4. (Note: The first four 32-bit keys (e.g., w[0:3]) are stored in the floating-point register % f0 and % f2). Similarly, in one embodiment, SB 434 and RXR 440 of key expansion pipeline 314 may be configured to execute the first AES_KEXPAND2 instruction to generate the seventh and eighth 32-bit expanded keys (e.g., w[6] and w[7]) and to store them in the floating-point register % f6. To generate the remaining expended keys, key expansion pipeline 314 repetitively executes the AES_KEXPAND1 and AES_KEXPAND2 instructions as shown. It is noted that this code represents merely one example of how the AES_KEXPAND instructions may be employed, and that numerous other applications using other variants of the instructions are possible and contemplated. For example, in other embodiments, AES_KEXPAND instructions may be implemented to use the integer register file instead of the floating-point register file, or may be implemented to generate more than two keys per invocation of the AES_KEXPAND instructions. Further, the AES_KEXPAND instructions may be implemented in any suitable ISA.
It is noted that the above floating-point register notation % fn refers to the notation used in SPARC processors. More particularly, the floating-point registers may be referenced as 64-bit double-precision registers. For example, % f0 and % f1 are the even and odd single-precision halves of double-precision FP register % f0. Thus, the first four 32-bit keys are stored in the first two double-precision registers % f0 and % f2.
To support the expansion of the 192 and 256-bit AES cipher keys the key expansion pipeline 314 may be configured to execute different combinations of the AES_KEXPAND instructions similar to the execution shown in the 128-bit key expansion. The following exemplary SPARC assembly language code sequence illustrates the use of the AES_KEXPAND instructions to expand the 192-bit AES cipher key.
The following exemplary SPARC assembly language code sequences illustrate the use of the AES_KEXPAND instructions to expand the 256-bit AES cipher key for encryption and decryption, respectively.
In one embodiment, the nature of the AES encrypt/decrypt routine requires four registers to hold the current and next round data. Accordingly, in one embodiment, four expanded keys may be held in the IRF. To optimize performance, the four keys applied as “AddRoundKey†may be held in the IRF with “AddRoundKey†XOR executed in the EXU.
In the illustrated embodiment, cipher pipeline 312 may be configured to execute AES Round instructions to retrieve and utilize cipher keys of the expanded key set from the appropriate register file during encryption/decryption rounds of the cipher algorithm. In one embodiment, cipher pipeline 312, in combination with control logic 313, may be configured to execute AES Round instructions defined within the ISA of processor 10 and denoted with the following instruction mnemonics: AES_EROUND01, AES_EROUND23, AES_EROUND01_LAST, AES_EROUND23_LAST, AES_DROUND01, AES_DROUND23, AES_DROUND01_LAST, and AES_DROUND23_LAST (though any suitable mnemonics may be employed). These instructions may be referred to collectively in the following discussions as the AES_ROUND instructions, where appropriate. In various embodiments, the control logic 313 may directly decode the AES_ROUND instructions from opcode bits sent from upstream pipeline stages, or may receive already-decoded or partially-decoded signals indicative of the occurrence of AES_ROUND instructions. Control logic 313 may responsively provide corresponding control signals to the cipher pipeline 312 to execute the AES_ROUND instructions.
More particularly, in one embodiment, the AES_EROUND01 instruction may encrypt columns 0 and 1 of the cipher state 1012 using SubBytes, ShiftRows, MixColumn, and AddRoundKey, while the AES_EROUND01_LAST instruction may encrypt columns 0 and 1 for the last round of the encryption. Similarly, the AES_EROUND23 instruction may encrypt columns 2 and 3 of the cipher state 1012, while the AES_EROUND23_LAST instruction may encrypt columns 2 and 3 for the last round of the encryption. In a likewise manner the AES_DROUND01 instruction may decrypt columns 0 and 1 of the cipher state 1012 using InvShiftRows, InvSubBytes, AddRoundKey, and InvMixColumn, while the AES_DROUND01_LAST instruction may decrypt columns 0 and 1 for the last round of the encryption. Similar to the encryption rounds, the AES_DROUND23 and AES_DROUND23_LAST instructions may decrypt columns 2 and 3 or the cipher state, including the last round.
As described in greater detail below, in one embodiment, SR logic 1032, SB logic 1034, and MC/ARK logic 1036 may be implemented as pipeline stages configured to implement corresponding steps of encrypting and decrypting according to the AES cipher algorithm above. For example, SR logic 1032 may be configured as fixed or selectable circular shift logic, for example using multiplexers. SB logic 1034 may be configured to perform a byte substitution (e.g., SubBytes transformation) for bytes of cipher state 1012 as defined by the transformation specified by the AES cipher algorithm. Further, MC/ARK logic 1036 may be configured to perform the Mix Columns and Add Round Key transformation shown in the AES cipher algorithm. In the illustrated embodiment, the MC and ARK functions are combined within MC/ARK logic 1036. For example, the MC function may be implemented as a collection of XOR logic gates followed by an additional level of XOR logic to compute the ARK function. Additionally, control logic 313 may be configured to control the various pipeline stages and their interconnectivity such that execution of the AES algorithms may be pipelined over several stages, as described in greater detail below. It is noted that in other embodiments, cipher pipeline 312 may be partitioned differently into different stages and/or elements, and may implement functions in addition to or distinct from the AES cipher functions illustrated.
As described above, in some embodiments, cipher pipeline 312 may be configured to implement the appropriate inverse functions for decryption, either by reconfiguring encryption logic or providing separate logic.
In various embodiments, the rate at which cipher keys may be utilized by cipher pipeline 312 during a given round may depend on how cipher pipeline 312 is implemented. For example, depending on the specific implementation, one 32-bit word from the expanded key set may be applied to each column of cipher state 1012, or to fewer than all four columns concurrently during the AddRoundKey step described above. In embodiments where all 4 columns of cipher state 1012 concurrently undergo the AddRoundKey step, 4 32-bit words may be concurrently retrieved from the register file and utilized. In embodiments where fewer than all columns are concurrently processed, a correspondingly narrower datapath from the register files may be provided.
As noted above, the various pipeline stages implemented within cipher pipeline 312 may be configured to concurrently process fewer than all of the columns of cipher state 1012, thereby potentially reducing the area required to implement the AES cipher. More particularly, in the illustrated embodiment, SR logic 1032 may be configured to select and shift two of the columns of cipher state 1012, and to convey the two shifted columns to SB logic 1034. During a given execution cycle or time slot, SB logic 1034 and MC/ARK logic 1036 each may be configured to perform the appropriate byte substitution and to perform the MC/ARK functions, respectively, on two columns of cipher state 1012. During decryption, cipher pipeline 312 may concurrently process fewer than all columns of cipher state 1012 in a manner similar to that described above.
Accordingly, by configuring each pipeline stage to process two columns concurrently rather than all four columns of cipher state 1012, the corresponding area to implement the logic on an integrated circuit may be reduced by approximately half. More generally, for some embodiments of cipher pipeline 312, the implementation area required by a given pipeline stage may be proportional to the number of columns of cipher state 1012 the given pipeline stage is configured to concurrently process.
It is noted that the order of functions suggested by the AES pseudocode given above may not be ideal for area reduction using a datapath configured to concurrently process fewer than all columns of cipher state 1012. In the pseudocode, SubBytes is performed before ShiftRows. However, for the AES algorithm, a given output byte of the SubBytes function is dependent only on a single input byte, whereas a given output byte of the ShiftRows function is dependent upon potentially all of the bytes in a row of cipher state 1012. Consequently, if SubBytes is implemented prior to ShiftRows within cipher pipeline 312, it may be necessary to perform SubBytes on all columns of cipher state 1012 before ShiftRows begins. This may in turn require additional temporary storage in addition to cipher state 1012 in which columns of state on which SubBytes has already been performed may be held while remaining columns are processed. Such additional storage may partially negate the area benefit realized by implementing fewer columns. Additionally, delaying execution of ShiftRows until SubBytes has been performed on all of cipher state 1012 may lengthen the execution pipeline, increasing the latency of algorithm execution.
Because the SubBytes function, in AES, is an independent mapping of an input byte to an output byte, the result of performing SubBytes followed by ShiftRows on all columns of cipher state 1012 is equivalent to the result of performing ShiftRows followed by SubBytes, even though the intermediate results may differ. Since cipher state 1012 includes all columns of the cipher state, implementing ShiftRows (which may depend on multiple columns) prior to SubBytes (which does not) may avoid the need for temporary storage and possible pipeline delays described above. In the illustrated embodiment, SR logic 1032 may be configured to perform the ShiftRows function with respect to two output columns at a time, referring to all columns of cipher state 1012 as necessary for a given row. Subsequently, SB logic 1034 and MC/ARK logic 1036 may perform their steps of the AES algorithm on two columns at any given time. Accordingly, as described above, the AES_ROUND instructions may operate on either columns 0 and 1, or columns 2 and 3 concurrently.
The following exemplary SPARC assembly language code sequences illustrate the use of the AES_ROUND instructions for encryption. The following code sequence illustrates encrypting a 128-bit block of clear text using the expanded set of keys generated from a 128-bit AES cipher key.
The following exemplary SPARC assembly language code sequence illustrates the use of the AES_ROUND instructions to encrypt a 128-bit block of clear text using the expanded set of keys generated from a 192-bit AES cipher key.
The following exemplary SPARC assembly language code sequence illustrates the use of the AES_ROUND instructions to encrypt a 128-bit block of clear text using the expanded set of keys generated from a 256-bit AES cipher key.
The following exemplary SPARC assembly language code sequences illustrate the use of the AES_ROUND instructions for decryption. The following code sequence illustrates decrypting a 128-bit block of cipher text using the expanded set of keys generated from a 128-bit AES cipher key.
The following exemplary SPARC assembly language code sequence illustrates the use of the AES_ROUND instructions to decrypt a 128-bit block of cipher text using the expanded set of keys generated from a 192-bit AES cipher key.
The following exemplary SPARC assembly language code sequence illustrates the use of the AES_ROUND instructions to decrypt a 128-bit block of cipher text using the expanded set of keys generated from a 256-bit AES cipher key.
Referring to
In some embodiments, the area required by cipher pipeline 312 may be reduced still further. It is noted that in other embodiments, each stage of cipher pipeline 312 may be configured to concurrently process one column of cipher state 1012, instead of two. The details of configuration and operation of the illustrated embodiment are analogous to those of the embodiment of
It is contemplated that in other embodiments, different numbers of columns may be implemented for concurrent execution within cipher pipeline 312. For example, if cipher state 1012 included six columns, different area vs. latency tradeoffs may be achieved by implementing one, two or three columns for concurrent execution within cipher pipeline 312. It is also possible to implement more than half, but fewer than all columns of cipher state 1012 for concurrent execution, although these solutions may be less than optimal tradeoffs of area vs. latency.
Turning to
In response to receiving the issued AES_KEXPANDn instruction, the cryptographic unit executes the AES_KEXPANDn instruction to produce one or more of the expanded keys defined by the AES cipher (block 1302). More particularly, in one embodiment, AES engine 310 within FGU 255 may be configured to execute the AES_KEXPANDn instruction as previously described, which may include performing different types of functions depending on which AES_KEXPANDn instruction as specified by the instruction operands is executed. In various embodiments, executing the AES_KEXPANDn instruction may include reading instruction operands from a register file, an operand bypass unit, or another operand source, as well as writing a result to working storage or to another destination.
Referring to
In response to receiving the issued AES_EROUNDmm instruction, the cryptographic unit executes the AES_EROUNDmm instruction to apply the transformation operations to the specified input value (block 1306). For example, AES engine 310 within FGU 255 may be configured to execute the AES_EROUNDmm instructions as previously described to encrypt blocks of clear text. In various embodiments, executing the AES_EROUNDmm instructions may include reading instruction operands from a register file, an operand bypass unit, or another operand source, as well as writing a result to working storage or to another destination.
Referring to
In response to receiving the issued AES_DROUNDpp instruction, the cryptographic unit executes the AES_DROUNDpp instruction to apply the transformation operations to the specified input value (block 1310). For example, AES engine 310 within FGU 255 may be configured to execute the AES_DROUNDpp instructions as previously described to decrypt blocks of cipher text using, for example, inverse cipher functions. In various embodiments, executing the AES_DROUNDpp instructions may include reading instruction operands from a register file, an operand bypass unit, or another operand source, as well as writing a result to working storage or to another destination.
It is noted that the cipher algorithms described above may be implemented using a number of chaining modes. For example, various applications may call for various levels of message confidentiality and/or message integrity. Since block ciphers encrypt each block the same way with the same key, when multiple blocks will be encrypted using a single key, it may be possible to distinguish patterns in the encrypted data. One way to mitigate that is to use information from a previous block encryption to somehow change the new data block for the next encryption in a reproducible way. Accordingly, chaining modes may be used, which may use some combination of the plain text of a new block of data and the cipher text of a previous block. There are a number of well-known chaining modes such as cipher-block chaining (CBC), counter (CTR), cipher feedback (CFB), to name a few. Due to the large number of possible chaining modes that may be required by different applications, to maintain flexibility, in the embodiments of processor 10 described above, chaining modes may be handled external to the cryptographic unit in software.
As described above, in some embodiments, processor 10 of
In some embodiments, system 1400 may be configured as a multiprocessor system, in which processor 10a may optionally be coupled to one or more other instances of processor 10, shown in
In various embodiments, system memory 1410 may comprise any suitable type of system memory as described above, such as FB-DIMM, DDR/DDR2/DDR3/DDR4 SDRAM, or RDRAM®, for example. System memory 1410 may include multiple discrete banks of memory controlled by discrete memory interfaces in embodiments of processor 10 that provide multiple memory interfaces 130. Also, in some embodiments, system memory 1410 may include multiple different types of memory.
Peripheral storage device 1420, in various embodiments, may include support for magnetic, optical, or solid-state storage media such as hard drives, optical disks, nonvolatile RAM devices, etc. In some embodiments, peripheral storage device 1420 may include more complex storage devices such as disk arrays or storage area networks (SANs), which may be coupled to processor 10 via a standard Small Computer System Interface (SCSI), a Fibre Channel interface, a Firewire® (IEEE 1394) interface, or another suitable interface. Additionally, it is contemplated that in other embodiments, any other suitable peripheral devices may be coupled to processor 10, such as multimedia devices, graphics/display devices, standard input/output devices, etc. In one embodiment, peripheral storage device 1420 may be coupled to processor 10 via peripheral interface(s) 150 of
As described previously, in one embodiment boot device 1430 may include a device such as an FPGA or ASIC configured to coordinate initialization and boot of processor 10, such as from a power-on reset state. Additionally, in some embodiments boot device 1430 may include a secondary computer system configured to allow access to administrative functions such as debug or test modes of processor 10.
Network 1440 may include any suitable devices, media and/or protocol for interconnecting computer systems, such as wired or wireless Ethernet, for example. In various embodiments, network 1440 may include local area networks (LANs), wide area networks (WANs), telecommunication networks, or other suitable types of networks. In some embodiments, computer system 1450 may be similar to or identical in configuration to illustrated system 1400, whereas in other embodiments, computer system 1450 may be substantially differently configured. For example, computer system 1450 may be a server system, a processor-based client system, a stateless “thin†client system, a mobile device, etc. In some embodiments, processor 10 may be configured to communicate with network 1440 via network interface(s) 160 of
It is noted that the above exemplary assembly language code sequences use the setx instruction. However, the setx instruction is defined within the SPARC ISA as a synthetic instruction. As described in section G.3 of the SPARC Architecture Manual Version 9, synthetic instructions may be provided in a SPARC assembler for the convenience of assembly language programmers, and they do generate instructions. The synthetic instructions map to actual instructions.
Although the embodiments above have been described in considerable detail, numerous variations and modifications will become apparent to those skilled in the art once the above disclosure is fully appreciated. It is intended that the following claims be interpreted to embrace all such variations and modifications.