System Considerations In Crypto-C

Input and Output

Some of the AI entries in the Reference Manual include the categories “Input Constraints” and “Output Considerations”:

Input constraints generally describe the input requirements of the algorithm specified by the AI.

Output considerations warn you that there may be more (or fewer) output bytes than input bytes.

Two algorithm types that typically have input constraints or output considerations are symmetric block algorithms and the RSA algorithm.

Symmetric Block Algorithms

Symmetric block algorithms may have both input constraints and output considerations.

Input constraints

In symmetric block-encryption algorithms, the total number of input bytes must be a multiple of the block size. That does not mean the input to each call to an Update function must be a multiple of the block size, just the total.

For instance, with the RC2 algorithm, the block size is eight bytes. You can pass 23 bytes in the first call to Update, then 18, then 7, for a total of 48.

Output considerations

For a symmetric block-encryption algorithm, the output from each Update call may be different from the input size.

In the previous example, the RC2 algorithm was able to process 16 of the first 23 bytes but saved 7 in a buffer. The input was 23, but the output was 16. During the second call to Update, Crypto-C had the 18 new input bytes plus the old 7, or 25 bytes to work with. It could process 24 (and save 1). Hence, the input was 18, but the output was 24 bytes long. The last 7 input bytes combined with the saved 1 byte make up the final 8-byte block. It is important to allow for this difference in length between output and input in your application.

In addition to the difference in size during Updates, the overall data size can differ between input and output.

1 2 6

R S A B S A F E C r y p t o - C D e v e l o p e r ’s G u i d e

Page 148
Image 148
RSA Security 5.2.2 manual Input and Output, Symmetric Block Algorithms, Input constraints, Output considerations