background image

This document contains information on a new product. Specifications and information herein 
are subject to change without notice.

© Freescale Semiconductor, Inc., 2005. All rights reserved.

PRELIMINARY—SUBJECT TO CHANGE WITHOUT NOTICE

Freescale Semiconductor

1

Overview

The SEC2 device driver manages the operation of the SEC 2.0 
commonly instantiated into PowerQUICC processors. It is a fully 
functional component, meant to serve as an example of application 
interaction with the SEC2 core.

The driver is coded in ANSI C. In it’s design, an attempt has been 
made to write a device driver that is as operating system agnostic 
as practical. Where necessary, operating system dependencies are 
identified and 

Section 8, “Porting”

 addresses them.

Testing has been accomplished on VxWorks 5.5 and LinuxPPC 
using kernel version 2.4.27. 

Application interfaces to this driver are implemented through the 

ioctl()

 function call. Requests made through this interface can 

be broken down into specific components, including 
miscellaneous requests and process requests. The miscellaneous 
requests are any requests not related to the direct processing of 
data by the SEC2 core.

Process requests comprise the majority of the requests and all are 
executed using the same 

ioctl()

 access point. Structures needed 

to compose these requests are described in detail in 

Section 3.3.6, 

“Process Request Structures.”

Throughout the document, the acronyms CHA (crypto hardware 
accelerator) and EU (execution unit) are used interchangeably. 

SEC2SWUG

Rev. 0, 02/2005

Contents

1. Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  1

2. Device Driver Components   . . . . . . . . . . . . . . . . . . . .  3

3. User Interface  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  5

4. Individual Request Type Descriptions   . . . . . . . . . . .  14

5. Sample Code  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  36

6. Linux Environment  . . . . . . . . . . . . . . . . . . . . . . . . . .  39

7. VxWorks Environment  . . . . . . . . . . . . . . . . . . . . . . .  40

8. Porting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  41

SEC 2.0 Reference Device Driver 
User’s Guide

Содержание SEC 2.0

Страница 1: ...5 and LinuxPPC using kernel version 2 4 27 Application interfaces to this driver are implemented through the ioctl function call Requests made through this interface can be broken down into specific c...

Страница 2: ...tor This term is synonymous with AFEU in the MPC18x User s Manual and other documentation APAD Autopad The MDHA will automatically pad incomplete message blocks out to 512 bits when APAD is enabled AR...

Страница 3: ...ext RDK Restore decrypt key An AESA option to re use an existing expanded AES decryption key RNGA Random number generator accelerator SDES Single DES TEA Transfer error acknowledge TDES Triple DES VxW...

Страница 4: ...k 2 1 2 Request Dispatch Routine The request dispatch routine provides the ioctl interface to the device driver It uses the callers request code to identify which function is to execute and dispatches...

Страница 5: ...code This code will specify the driver specific operation to be performed by the device in question The third argument is the pointer to the SEC2 user request structure which contains information need...

Страница 6: ...ctl function and the second one after the completion of the request The second level is possible only if the request was done with at least the notify_on_error member of the user request structure If...

Страница 7: ...ber of channels implemented in the SEC2 device If not specified it will be set to a value of 4 as a default Table 2 Second and Third Arguments in the ioctl Function I O Control Code Second Argument in...

Страница 8: ...UM_DESAS Number of DES CHAs NUM_MDHAS Number of MD CHAs NUM_RNGAS Number of RNG CHAs NUM_PKHAS Number of PK CHAs NUM_AESAS Number of AESA CHAs Table 4 Request Operation ID Mask Define Description Valu...

Страница 9: ...nel memory free failed 0xE004FFEE SEC2_PARITY_SYSTEM_ERROR Parity Error detected on the bus 0xE004FFED SEC2_INCOMPLETE_POINTER Error due to partial pointer 0xE004FFEC SEC2_TEA_ERROR A transfer error h...

Страница 10: ...nsigned long ChannelStatusRegister NUM_CHANNELS 2 unsigned long ChannelConfigurationRegister NUM_CHANNELS 2 unsigned long CHAInterruptStatusRegister NUM_CHAS 2 unsigned long QueueEntryDepth unsigned l...

Страница 11: ...f cryptographic operation see Section 4 Individual Request Type Descriptions for all supported request types scatterBufs A bitmask that specifies which of the argued buffers are mapped through a scatt...

Страница 12: ...nstructs the driver cannot be designed with specific knowledge of one particular mapping method Therefore a generic memory fragment definition structure EXT_SCATTER_ELEMENT is defined for this purpose...

Страница 13: ...en mark the necessary bit in scatterBufs that defines this buffer for this specific request type 3 3 7 3 Direct Scatter Gather Usage Example In order to make this usage clear an example is presented A...

Страница 14: ...DES Requests 4 2 1 DES_CBC_CRYPT_REQ COMMON_REQ_PREAMBLE unsigned long inIvBytes 0 or 8 bytes unsigned char inIvData unsigned long keyBytes 8 16 or 24 bytes unsigned char keyData unsigned long inByte...

Страница 15: ...escriptors opId Descriptors Value Function Description DPD_SDES_CBC_CTX_ENCRYPT 0x2500 Load encrypted context from a dynamic channel to encrypt in single DES using CBC mode DPD_SDES_CBC_CTX_DECRYPT 0x...

Страница 16: ...LE unsigned long keyBytes unsigned char keyData unsigned long inBytes unsigned char inData unsigned char outData output length input length unsigned long outCtxBytes 257 bytes unsigned char outCtxData...

Страница 17: ...TX_HASH_PAD_ULCTX_GROUP 0x4500 defines the group for all descriptors within this request Table 11 HASH_REQ Valid Descriptors 0x4400 opId Descriptors Value Function Description DPD_SHA256_LDCTX_HASH_UL...

Страница 18: ...iption DPD_SHA256_LDCTX_HASH_PAD_ULCTX 0x4500 Compute digest with pre padded data using an SHA 256 hash algorithm then store the resulting context DPD_MD5_LDCTX_HASH_PAD_ULCTX 0x4501 Compute digest wi...

Страница 19: ...or all descriptors within this request Table 13 HMAC_PAD_REQ Valid Descriptors opId Descriptors Value Function Description DPD_SHA256_LDCTX_HMAC_ULCTX 0x4A00 Load context then use an SHA 256 hash algo...

Страница 20: ...ptors opId Descriptors Value Function Description DPD_AESA_CBC_ENCRYPT_CRYPT 0x6000 Perform encryption in AESA using CBC mode DPD_AESA_CBC_DECRYPT_CRYPT 0x6001 Perform decryption in AESA using CBC mod...

Страница 21: ...s the group for all descriptors within this request 4 7 3 MOD_R2MODN_REQ COMMON_REQ_PREAMBLE unsigned long modBytes unsigned char modData unsigned long outBytes unsigned char outData NUM_MM_R2MODN_DES...

Страница 22: ...DP_ULCTX_GROUP 0x5300 defines the group for all descriptors within this request 4 7 5 MOD_2OP_REQ unsigned long bDataBytes unsigned char bData unsigned long aDataBytes unsigned char aData unsigned lon...

Страница 23: ...lar A3 to B0 MUL1 operation DPD_POLY_LDCTX_A3_B0_MUL2_ULCTX 0x540E Perform a modular A3 to B0 MUL2 operation DPD_POLY_LDCTX_A3_B0_ADD_ULCTX 0x540F Perform a modular A3 to B0 ADD operation DPD_POLY_LDC...

Страница 24: ...operation DPD_POLY_LDCTX_A3_B2_ADD_ULCTX 0x5427 Perform a modular A3 to B2 ADD operation DPD_POLY_LDCTX_A0_B3_MUL1_ULCTX 0x5428 Perform a modular A0 to B3 MUL1 operation DPD_POLY_LDCTX_A0_B3_MUL2_ULC...

Страница 25: ...nsigned char modData unsigned long outBytes unsigned char outData NUM_EC_2OP_DESC defines the number of descriptors within the DPD_EC_2OP_GROUP that use this request Table 20 ECC_POINT_REQ Valid Descr...

Страница 26: ...gned long b1DataBytes unsigned char b1Data unsigned long buildDataBytes unsigned char buildData NUM_EC_SPKBUILD_DESC defines the number of descriptors within the DPD_EC_SPKBUILD_GROUP that use this re...

Страница 27: ...1DataBytes unsigned char b2Data unsigned long b2DataBytes unsigned char b2Data unsigned long b3DataBytes unsigned char b3Data 4 9 IPSec Requests 4 9 1 IPSEC_CBC_REQ COMMON_REQ_PREAMBLE unsigned long h...

Страница 28: ...S using CBC mode with SHA 256 padding DPD_IPSEC_CBC_SDES_DECRYPT_MD5_PAD 0x7003 Perform the IPSec process of decrypting in single DES using CBC mode with MD5 padding DPD_IPSEC_CBC_SDES_DECRYPT_SHA_PAD...

Страница 29: ...7100 Perform the IPSec process of encrypting in single DES using ECB mode with MD5 padding DPD_IPSEC_ECB_SDES_ENCRYPT_SHA_PAD 0x7101 Perform the IPSec process of encrypting in single DES using ECB mod...

Страница 30: ...ec process of encrypting in triple DES using ECB mode with SHA 256 padding DPD_IPSEC_ECB_TDES_DECRYPT_MD5_PAD 0x7109 Perform the IPSec process of decrypting in triple DES using ECB mode with MD5 paddi...

Страница 31: ..._ENCRYPT_SHA 0x8004 Perform the IPSec process of encrypting in AES using CBC mode with SHA 1 DPD_IPSEC_AES_CBC_ENCRYPT_SHA256 0x8005 Perform the IPSec process of encrypting in AES using CBC mode with...

Страница 32: ...AES using ECB mode with SHA 256 auto padding DPD_IPSEC_AES_ECB_ENCRYPT_MD5 0x8103 Perform the IPSec process of encrypting in AES using ECB mode with MD5 DPD_IPSEC_AES_ECB_ENCRYPT_SHA 0x8104 Perform t...

Страница 33: ...cket using single DES in ECB mode and SHA256 with auto padding DPD_IPSEC_ESP_IN_SDES_ECB_DCRPT_MD5_PAD 0x7503 Process an inbound IPSec encapsulated system payload packet using single DES in ECB mode a...

Страница 34: ...HA_PAD 0x7510 Process an inbound IPSec encapsulated system payload packet using triple DES in CBC mode and SHA1 with auto padding DPD_IPSEC_ESP_IN_TDES_CBC_DCRPT_SHA256_ PAD 0x7511 Process an inbound...

Страница 35: ...ryptDataBytes unsigned char cryptDataOut unsigned long MICBytes unsigned char MICData NUM_CCMP_DESC defines the number of descriptors within the DPD_CCMP_GROUP that use this request DPD_CCMP_GROUP 0x6...

Страница 36: ...use this request DPD_SRTP_GROUP 0x8500 defines the group for all descriptors within this request 5 Sample Code The following sections provide sample codes for DES and IPSec 5 1 DES Sample define the U...

Страница 37: ...a pointer to data desencReq outData desEncResult pointer to results desencReq nextReq 0 no descriptor chained call the driver status Ioctl device IOCTL_PROC_REQ desencReq First Level Error Checking if...

Страница 38: ...InDataBytes 8 length of data to be hashed only ipsecReq hashInData PlainText pointer to data to be hashed only ipsecReq inDataBytes packet_length 8 length of data to be hashed and encrypted ipsecReq i...

Страница 39: ...s a char device in the target system As shipped the driver assumes that the device major number will be assigned dynamically and that the minor number will always be zero since only one instance of th...

Страница 40: ...ference between the two operations Building the example testing application with __KERNEL__ on building a kernel mode test shows the installation and usage of standard completion callbacks and a mutex...

Страница 41: ...itialization the driver calls a specialized function name sysGetPeripheralBase which returns a pointer to the base location of the peripheral device block in the processor often defined by the CCSBAR...

Страница 42: ...ock semaphores IOInitSemaphores The ISR message queue IOInitQs Driver service function registration with the operating system IORegisterDriver ISR connection disconnection IOConnectInterrupt 8 3 Inter...

Страница 43: ...locations consistent with the file location conventions appropriate for their system configuration DBGTXT_SETRQ Messages from request setup operations new requests inbound from the application DBGTXT...

Страница 44: ...to the body or other applications intended to support or sustain life or for any other application in which the failure of the Freescale Semiconductor product could create a situation where personal i...

Отзывы: