summaryrefslogtreecommitdiff
path: root/src/libstrongswan/plugins/ctr/ctr_ipsec_crypter.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstrongswan/plugins/ctr/ctr_ipsec_crypter.c')
-rw-r--r--src/libstrongswan/plugins/ctr/ctr_ipsec_crypter.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/libstrongswan/plugins/ctr/ctr_ipsec_crypter.c b/src/libstrongswan/plugins/ctr/ctr_ipsec_crypter.c
index ddcae423b..59d201a6f 100644
--- a/src/libstrongswan/plugins/ctr/ctr_ipsec_crypter.c
+++ b/src/libstrongswan/plugins/ctr/ctr_ipsec_crypter.c
@@ -45,7 +45,7 @@ struct private_ctr_ipsec_crypter_t {
/**
* Do the CTR crypto operation
*/
-static void crypt_ctr(private_ctr_ipsec_crypter_t *this,
+static bool crypt_ctr(private_ctr_ipsec_crypter_t *this,
chunk_t in, chunk_t out)
{
size_t is, bs;
@@ -63,8 +63,11 @@ static void crypt_ctr(private_ctr_ipsec_crypter_t *this,
memset(iv, 0, is);
memcpy(block, state.ptr, bs);
- this->crypter->encrypt(this->crypter,
- chunk_create(block, bs), chunk_create(iv, is), NULL);
+ if (!this->crypter->encrypt(this->crypter, chunk_create(block, bs),
+ chunk_create(iv, is), NULL))
+ {
+ return FALSE;
+ }
chunk_increment(state);
if (in.ptr != out.ptr)
@@ -75,9 +78,10 @@ static void crypt_ctr(private_ctr_ipsec_crypter_t *this,
in = chunk_skip(in, bs);
out = chunk_skip(out, bs);
}
+ return TRUE;
}
-METHOD(crypter_t, crypt, void,
+METHOD(crypter_t, crypt, bool,
private_ctr_ipsec_crypter_t *this, chunk_t in, chunk_t iv, chunk_t *out)
{
memcpy(this->state.iv, iv.ptr, sizeof(this->state.iv));
@@ -85,12 +89,9 @@ METHOD(crypter_t, crypt, void,
if (out)
{
*out = chunk_alloc(in.len);
- crypt_ctr(this, in, *out);
- }
- else
- {
- crypt_ctr(this, in, in);
+ return crypt_ctr(this, in, *out);
}
+ return crypt_ctr(this, in, in);
}
METHOD(crypter_t, get_block_size, size_t,
@@ -112,13 +113,13 @@ METHOD(crypter_t, get_key_size, size_t,
+ sizeof(this->state.nonce);
}
-METHOD(crypter_t, set_key, void,
+METHOD(crypter_t, set_key, bool,
private_ctr_ipsec_crypter_t *this, chunk_t key)
{
memcpy(this->state.nonce, key.ptr + key.len - sizeof(this->state.nonce),
sizeof(this->state.nonce));
key.len -= sizeof(this->state.nonce);
- this->crypter->set_key(this->crypter, key);
+ return this->crypter->set_key(this->crypter, key);
}
METHOD(crypter_t, destroy, void,