CryptoSys API Library Manual

Common problems when encrypting

The requirements for input to the block encipher functions (AES, DES, Triple DES and Blowfish) are quite strict.

Input Data: Input data to the block encipher functions in ECB or CBC mode must be an exact multiple of the block length (16 bytes for AES, 8 bytes for the others) or the functions will return an error. It is the user's responsibility to provide padding where necessary and to remove the padding after decryption. Failure to do this will result in one of these errors:-

Input not multiple of 8 bytes long
Input not multiple of block size

See Padding for more guidance on preparing your plaintext for encryption.

This rule on input lengths does not apply to the file encryption functions which automatically provide their own padding.

Keys and IV: All the keys and initialization vectors provided in hex format must be of the exact required length or the function will return an error:-

Invalid key length
Invalid initialization vector

Note also that the CNV_BytesFromHexStr function will - by design - filter invalid hex characters and return the resulting bytes from whatever is left without error. The hex versions of the encryption functions are stricter and will fail if any invalid hex characters are found in the input. See Hexadecimal versus Bytes for more details of the hex conversion functions.

[Contents] [Index]

[HOME]   [NEXT: Security Issues...]

Copyright © 2001-9 D.I. Management Services Pty Ltd. All rights reserved.