43.3.4.5 Fast Copy/Clear

Purpose

This service performs a copy from a memory area to another or a memory area clear.

How to Use the Service

Description

This service copies a number X into another number R, padding with zero on the MSB side up to the length specified for R.

R = X

If the lengths of R and X are equal, a complete fast copy is processed.

If the length of R is strictly greater than the length of X, X is first copied in the Low Significant Bytes side of R, and R is padded with zeros on the Most Significant Bytes side.

If the pointer on the X area equals zero, R is filled with zeros. This operation can also be made by using the Fill service (see Fill).

The service name for this operation is FastCopy.

Important: The length of R must be greater or equal to the length of X.

Parameters Definition

This service can easily be accessed through the use of the PUKCL_FastCopy() macro.

Table 43-13. FastCopy Service Parameters
ParameterTypeDirectionLocationData LengthBefore Executing the ServiceAfter Executing the Service
nu1XBasenu1ICrypto RAMu2XLengthBase of XBase of X number untouched
nu1RBasenu1ICrypto RAMu2RLengthBase of RBase of R filled with X
u2RLengthu2ILength of RLength of R
u2XLengthu2ILength of XLength of X

Code Example

PUKCL_PARAM PUKCLParam;
PPUKCL_PARAM pvPUKCLParam = &PUKCLParam;

// Initialize parameters
PUKCL_FastCopy(nu1XBase) = <Base of the X number>; 
PUKCL_FastCopy(nu1RBase) = <Base of the R number>; 
PUKCL_FastCopy(u2XLength) = <Length of the X number>; 
PUKCL_FastCopy(u2RLength) = <Length of the R number>;

// vPUKCL_Process() is a macro command, which populates the service name
// and then calls the library... 
vPUKCL_Process(FastCopy,pvPUKCLParam); 
if (PUKCL(u2Status) == PUKCL_OK)
            {
            ...
            }
else // Manage the error

Constraints

The parameter placements that are not allowed are are as follows.

If nu1XBase equals zero, no checks are made on nu1XBase (fixed) and u2XLength (unused).

The following conditions must be avoided to ensure that the service works correctly:

  • nu1XBase or nu1RBase are not aligned on 32-bit boundaries
  • u2XLength or u2RLength is either: <4, >0xffc or not a 32-bit length or u2XLength >u2RLength
  • {nu1XBase, u2XLength} or {nu1RBase, u2RLength} do not entirely lie in Crypto RAM
  • {nu1XBase, u2XLength} overlaps {nu1RBase,u2RLength}

Status Returned Values

Table 43-14. FastCopy Service Return Codes
Returned statusImportanceMeaning
PUKCL_OKService functioned correctly