Use IV length of a crypter instead of block size for IV calculations
This commit is contained in:
@@ -121,7 +121,7 @@ static bool test_crypter(private_crypto_tester_t *this,
|
||||
|
||||
key = chunk_create(vector->key, crypter->get_key_size(crypter));
|
||||
crypter->set_key(crypter, key);
|
||||
iv = chunk_create(vector->iv, crypter->get_block_size(crypter));
|
||||
iv = chunk_create(vector->iv, crypter->get_iv_size(crypter));
|
||||
|
||||
/* allocated encryption */
|
||||
plain = chunk_create(vector->plain, vector->len);
|
||||
|
||||
@@ -559,7 +559,7 @@ static bool parse_envelopedData(private_pkcs7_t *this, chunk_t serialNumber,
|
||||
DBG1(DBG_LIB, "IV could not be parsed");
|
||||
goto end;
|
||||
}
|
||||
if (iv.len != crypter->get_block_size(crypter))
|
||||
if (iv.len != crypter->get_iv_size(crypter))
|
||||
{
|
||||
DBG1(DBG_LIB, "IV has wrong length");
|
||||
goto end;
|
||||
@@ -752,7 +752,7 @@ bool build_envelopedData(private_pkcs7_t *this, x509_t *cert,
|
||||
rng->destroy(rng);
|
||||
|
||||
rng = lib->crypto->create_rng(lib->crypto, RNG_WEAK);
|
||||
rng->allocate_bytes(rng, crypter->get_block_size(crypter), &iv);
|
||||
rng->allocate_bytes(rng, crypter->get_iv_size(crypter), &iv);
|
||||
DBG4(DBG_LIB, " initialization vector: %B", &iv);
|
||||
rng->destroy(rng);
|
||||
}
|
||||
|
||||
@@ -127,8 +127,8 @@ static status_t pem_decrypt(chunk_t *blob, encryption_algorithm_t alg,
|
||||
}
|
||||
crypter->set_key(crypter, key);
|
||||
|
||||
if (iv.len != crypter->get_block_size(crypter) ||
|
||||
blob->len % iv.len)
|
||||
if (iv.len != crypter->get_iv_size(crypter) ||
|
||||
blob->len % crypter->get_block_size(crypter))
|
||||
{
|
||||
crypter->destroy(crypter);
|
||||
DBG1(DBG_LIB, " data size is not multiple of block size");
|
||||
|
||||
Reference in New Issue
Block a user