Apps     Components     Interfaces     All Files     Source Tree     source: tos.interfaces.BlockCipher.nc

Interface: BlockCipher

Author: Naveen Sastry

Components providing this interface:
tos.lib.TinySec.SkipJackM

Components requiring this interface:
tos.lib.TinySec.CBCMAC
tos.lib.TinySec.CBCModeM

Commands

Commands - Details

init

result_t init(CipherContext *context, uint8_t blockSize, uint8_t keySize, uint8_t *key)

Initialize the BlockCipher context.

Parameters:

context - structure to hold the opaque data from this initialization call. It should be passed to future invocations of this module which use this particular key.

blockSize - size of the block in bytes. Some cipher implementation may support multiple block sizes, in which case any valid size is valid.

keySize - key size in bytes

key - pointer to the key

Returns: Whether initialization was successful. The command may be unsuccessful if the key size or blockSize are not valid for the given cipher implementation.

encrypt

result_t encrypt(CipherContext *context, uint8_t *plainBlock, uint8_t *cipherBlock)

Encrypts a single block (of blockSize) using the key in the keySize.

Parameters:

context - holds the module specific opaque data related to the key (perhaps key expansions).

plainBlock - a plaintext block of blockSize

cipherBlock - the resulting ciphertext block of blockSize

Returns: Whether the encryption was successful. Possible failure reasons include not calling init().

decrypt

result_t decrypt(CipherContext *context, uint8_t *cipherBlock, uint8_t *plainBlock)

Decrypts a single block (of blockSize) using the key in the keySize. Not all ciphers will implement this function (since providing encryption is a useful primitive).

Parameters:

context - holds the module specific opaque data related to the key (perhaps key expansions).

cipherBlock - a ciphertext block of blockSize

plainBlock - the resulting plaintext block of blockSize

Returns: Whether the decryption was successful. Possible failure reasons include not calling init() or an unimplimented decrypt function.