C API for BALTECH SDK

§ brp_Crypto_BalKeyEncryptBuffer()

brp_errcode brp_Crypto_BalKeyEncryptBuffer ( brp_protocol  protocol,
unsigned  KeyVersion,
unsigned  EmbeddedKeyIndex,
unsigned  EmbeddedKeyPos,
brp_buf  Buffer,
size_t  Buffer_len,
brp_buf  InitialVector,
size_t  InitialVector_len,
brp_buf EncryptedBuffer,
size_t *  EncryptedBuffer_len,
brp_buf NextInitialVector,
size_t *  NextInitialVector_len,
brp_mempool mempool 
)

This command is a special version of the Crypto.EncryptBuffer command which always uses a customer key to encrypt a buffer of data and inserts a Crypto-Key at a desired position before encryption.

The key to insert has to be specified in the EmbeddedKeyIndex parameter. In this case, the 10 Byte Key will, on the one hand, replace the data at the EmbeddedKeyPos position, and on the other hand, replace the last two Bytes by a CRC (16-bit, 8404B, MSB encoded) that is generated on the data contained in Buffer.

Parameters
[in]protocolused to execute the command
[in]KeyVersion2: use SkipJack Key, 3: Use AES Key.
[in]EmbeddedKeyIndexIndex of the embedded key to insert in the data (value != 0x00). No key is inserted when this parameter is set to 0x00.
[in]EmbeddedKeyPosIf an embedded key is specified, this value specifies the position where to include the key.
[in]BufferData buffer to encrypt.
[in]Buffer_len
[in]InitialVectorInitial vector (IV) used for encryption.
[in]InitialVector_len
[out]EncryptedBufferBuffer after encryption.
[out]EncryptedBuffer_len
[out]NextInitialVectorInitial vector to be used as InitialVector parameter in the next call of this command.
[out]NextInitialVector_len
[in]mempoolis used to store response data. Maybe NULL to use an internal mempool, in this case the data is only available until another command uses the internal mempool