/**
* Encrypt a chunk of data and allocate space for the encrypted value.
*
- * The length of the iv must equal to get_block_size(), while the length
- * of data must be a multiple it.
+ * The length of the iv must equal to get_iv_size(), while the length
+ * of data must be a multiple of get_block_size().
* If encrypted is NULL, the encryption is done in-place (overwriting data).
*
* @param data data to encrypt
/**
* Decrypt a chunk of data and allocate space for the decrypted value.
*
- * The length of the iv must equal to get_block_size(), while the length
- * of data must be a multiple it.
+ * The length of the iv must equal to get_iv_size(), while the length
+ * of data must be a multiple of get_block_size().
* If decrpyted is NULL, the encryption is done in-place (overwriting data).
*
* @param data data to decrypt
/**
* Get the block size of the crypto algorithm.
*
- * @return block size in bytes
+ * @return block size in bytes
*/
size_t (*get_block_size) (crypter_t *this);
+ /**
+ * Get the IV size of the crypto algorithm.
+ *
+ * @return initialization vector size in bytes
+ */
+ size_t (*get_iv_size)(crypter_t *this);
+
/**
* Get the key size of the crypto algorithm.
*
- * @return key size in bytes
+ * @return key size in bytes
*/
size_t (*get_key_size) (crypter_t *this);
*
* The length of the key must match get_key_size().
*
- * @param key key to set
+ * @param key key to set
*/
void (*set_key) (crypter_t *this, chunk_t key);
return AES_BLOCK_SIZE;
}
+METHOD(crypter_t, get_iv_size, size_t,
+ private_aes_crypter_t *this)
+{
+ return AES_BLOCK_SIZE;
+}
+
METHOD(crypter_t, get_key_size, size_t,
private_aes_crypter_t *this)
{
.encrypt = _encrypt,
.decrypt = _decrypt,
.get_block_size = _get_block_size,
+ .get_iv_size = _get_iv_size,
.get_key_size = _get_key_size,
.set_key = _set_key,
.destroy = _destroy,
return BLOWFISH_BLOCK_SIZE;
}
+METHOD(crypter_t, get_iv_size, size_t,
+ private_blowfish_crypter_t *this)
+{
+ return BLOWFISH_BLOCK_SIZE;
+}
+
METHOD(crypter_t, get_key_size, size_t,
private_blowfish_crypter_t *this)
{
.encrypt = _encrypt,
.decrypt = _decrypt,
.get_block_size = _get_block_size,
+ .get_iv_size = _get_iv_size,
.get_key_size = _get_key_size,
.set_key = _set_key,
.destroy = _destroy,
return sizeof(des_cblock);
}
+METHOD(crypter_t, get_iv_size, size_t,
+ private_des_crypter_t *this)
+{
+ return sizeof(des_cblock);
+}
+
METHOD(crypter_t, get_key_size, size_t,
private_des_crypter_t *this)
{
INIT(this,
.public.crypter = {
.get_block_size = _get_block_size,
+ .get_iv_size = _get_iv_size,
.get_key_size = _get_key_size,
.destroy = _destroy,
},
return len;
}
+METHOD(crypter_t, get_iv_size, size_t,
+ private_gcrypt_crypter_t *this)
+{
+ size_t len = 0;
+
+ gcry_cipher_algo_info(this->alg, GCRYCTL_GET_BLKLEN, NULL, &len);
+ return len;
+}
+
METHOD(crypter_t, get_key_size, size_t,
private_gcrypt_crypter_t *this)
{
.encrypt = _encrypt,
.decrypt = _decrypt,
.get_block_size = _get_block_size,
+ .get_iv_size = _get_iv_size,
.get_key_size = _get_key_size,
.set_key = _set_key,
.destroy = _destroy,
return this->cipher->block_size;
}
+METHOD(crypter_t, get_iv_size, size_t,
+ private_openssl_crypter_t *this)
+{
+ return this->cipher->block_size;
+}
+
METHOD(crypter_t, get_key_size, size_t,
private_openssl_crypter_t *this)
{
.encrypt = _encrypt,
.decrypt = _decrypt,
.get_block_size = _get_block_size,
+ .get_iv_size = _get_iv_size,
.get_key_size = _get_key_size,
.set_key = _set_key,
.destroy = _destroy,
return AES_BLOCK_SIZE;
}
+METHOD(crypter_t, get_iv_size, size_t,
+ private_padlock_aes_crypter_t *this)
+{
+ return AES_BLOCK_SIZE;
+}
+
METHOD(crypter_t, get_key_size, size_t,
private_padlock_aes_crypter_t *this)
{
.encrypt = _encrypt,
.decrypt = _decrypt,
.get_block_size = _get_block_size,
+ .get_iv_size = _get_iv_size,
.get_key_size = _get_key_size,
.set_key = _set_key,
.destroy = _destroy,