C API for BALTECH SDK

§ brp_Sec_SetKey()

brp_errcode brp_Sec_SetKey ( brp_protocol  protocol,
unsigned  ContinuousIV,
unsigned  Encrypted,
unsigned  MACed,
unsigned  SessionKey,
unsigned  DeriveKey,
unsigned  SecLevel,
brp_buf  Key 
)

Sets a key and the appropriate Authorization Mode bits for a specified Security Level.

Please note that if DeriveKey is not 0, Sec.SetKey will not use the Key parameter as a new key value for the authentication of security level SecLevel directly. Instead, it encrypts the key specified in DeriveKey with the key specified in Key (via AES), and uses this encrypted key as a new key value for the authentication of security level SecLevel.

If one or more of the SessionKey , MACed , Encrypted or ContinuousIV bits are set, it is not possible to authenticate without the corresponding authentication mode setting.

Parameters
[in]protocolused to execute the command
[in]ContinuousIVIf true , encryption/MACing will use Cipher Block Chaining (CBC). In this case, a continuous initial vector (IV) will be used. If this bit is not set, CBC is not used, i.e. the IV will be reset to all zeros (00 00 ... 00) before every command or response is encrypted/MACed.
[in]EncryptedRequires that commands running in this security level always have to be encrypted. This flag cannot be set at the same time as the MACed flag.
[in]MACedRequires that commands running in this security level always have to be MACed. This flag cannot be set at the same time as the Encrypted flag.
[in]SessionKeyRequires a two-phase authentication to be able to enter a security level. This two-phase authentication process needs to be performed using the Sec.AuthPhase1 and Sec.AuthPhase2 commands.
[in]DeriveKeyThis value specifies a key which will be encrypted by the Key value and used as authentication key for security level SecLevel. If this parameter is 0, the authentication key is directly set by the Key parameter.
[in]SecLevelThe security level for which the key has to be set.
[in]KeyKey/Password for authentication of security level SecLevel.