API Reference | developer.brewmp.com API Reference | developer.brewmp.com

Developer

API Reference

ICIPHER1

Brew Release
Brew MP 1.0.2
Description

The functions in ICipher1 enable Brew MP developers to perform symmetric cipher encryption or decryption in a flexible manner without having to know the internals of the encryption algorithm or implementation.
This interface supports both stream and block ciphers.

The following header file is required:
ICipher1.h
Usage
ICipher1 is different from most Brew MP classes in that it is created via an instance of ICipherFactory instead of ISHELL_CreateInstance. Use ISHELL_CreateInstance to create the ICipherFactory and then call ICIPHERFACTORY_CreateCipher() or ICIPHERFACTORY_CreateCipher2() to create the specific cipher with all required features. The factory simplifies the process of creating the ICipher1 which best fits the developer's requirements. If the appropriate cipher can be created successfully, ICIPHERFACTORY_CreateCipher returns an ICipher1 interface pointer. See ICipherFactory for more details.
Each ICipher1 algorithm (i.e. DES, AES) may have multiple implementations, depending on the platform. Ciphers may be implemented in software, by a DSP or dedicated hardware. For each algorithm there is an abstract 'best fit' class Id which the factory uses to select the best available implementation for the current platform (generally this implies the fastest implementation). This allows application developers to develop platform independent code, without being concerned with the platform features.
Should the developer require a specific implementation, they may use the class id which identifies a specific implementation, with the understanding that a specific implementation may not be available on all devices.
The encrypt/decrypt key is set by calling ICipher1_SetParam() with CIPHER_PARAM_KEY. If using a block cipher, the initialization vector (IV) is set with CIPHER_PARAM_IV.
After initializing the key and optional IV, call ICipher1_Process() as required to encrypt or decrypt the data. Note that due to buffering and padding, the cipher may not return the same number of bytes passed in as returned on a given ICipher1_Process() call.

For block ciphers, always call ICipher1_ProcessLast to flush out the final block(s). This call is optional for stream ciphers.

When done with an ICipher1, call ICipher1_Release().