2.3.4.12 Initialization Vector Generation (Agile Encryption)
Initialization vectors are used in all cases for agile encryption. An initialization vector MUST be generated by using the following method, where H() is a hash function that MUST be the same as specified in section 2.3.4.11 and a plus sign (+) represents concatenation:
If a blockKey is provided, let IV be a hash of the KeySalt and the following value:
blockKey:IV = H(KeySalt + blockKey)
If a blockKey is not provided, let IV be equal to the following value:
KeySalt:IV = KeySalt.
If the number of bytes in the value of IV is less than the value of the blockSize attribute corresponding to the cipherAlgorithm attribute, pad the array of bytes by appending 0x36 until the array is blockSize bytes. If the array of bytes is larger than blockSize bytes, truncate the array to blockSize bytes.