diff options
author | Yves-Alexis Perez <corsac@debian.org> | 2013-01-02 14:18:20 +0100 |
---|---|---|
committer | Yves-Alexis Perez <corsac@debian.org> | 2013-01-02 14:18:20 +0100 |
commit | c1343b3278cdf99533b7902744d15969f9d6fdc1 (patch) | |
tree | d5ed3dc5677a59260ec41cd39bb284d3e94c91b3 /src/libsimaka/simaka_message.c | |
parent | b34738ed08c2227300d554b139e2495ca5da97d6 (diff) | |
download | vyos-strongswan-c1343b3278cdf99533b7902744d15969f9d6fdc1.tar.gz vyos-strongswan-c1343b3278cdf99533b7902744d15969f9d6fdc1.zip |
Imported Upstream version 5.0.1
Diffstat (limited to 'src/libsimaka/simaka_message.c')
-rw-r--r-- | src/libsimaka/simaka_message.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/src/libsimaka/simaka_message.c b/src/libsimaka/simaka_message.c index a5754b985..aa36a0974 100644 --- a/src/libsimaka/simaka_message.c +++ b/src/libsimaka/simaka_message.c @@ -499,8 +499,10 @@ static bool decrypt(private_simaka_message_t *this) eap_type_names, this->hdr->type); return FALSE; } - - crypter->decrypt(crypter, this->encr, this->iv, &plain); + if (!crypter->decrypt(crypter, this->encr, this->iv, &plain)) + { + return FALSE; + } this->encrypted = TRUE; success = parse_attributes(this, plain); @@ -599,8 +601,8 @@ METHOD(simaka_message_t, verify, bool, return TRUE; } -METHOD(simaka_message_t, generate, chunk_t, - private_simaka_message_t *this, chunk_t sigdata) +METHOD(simaka_message_t, generate, bool, + private_simaka_message_t *this, chunk_t sigdata, chunk_t *gen) { /* buffers large enough for messages we generate */ char out_buf[1024], encr_buf[512]; @@ -771,13 +773,19 @@ METHOD(simaka_message_t, generate, chunk_t, out = chunk_skip(out, 4); rng = this->crypto->get_rng(this->crypto); - rng->get_bytes(rng, iv.len, out.ptr); + if (!rng->get_bytes(rng, iv.len, out.ptr)) + { + return FALSE; + } iv = chunk_clonea(chunk_create(out.ptr, iv.len)); out = chunk_skip(out, iv.len); /* inline encryption */ - crypter->encrypt(crypter, encr, iv, NULL); + if (!crypter->encrypt(crypter, encr, iv, NULL)) + { + return FALSE; + } /* add ENCR_DATA attribute */ hdr = (attr_hdr_t*)out.ptr; @@ -822,12 +830,16 @@ METHOD(simaka_message_t, generate, chunk_t, if (mac.len) { data = chunk_cata("cc", out, sigdata); - signer->get_signature(signer, data, mac.ptr); + if (!signer->get_signature(signer, data, mac.ptr)) + { + return FALSE; + } } call_hook(this, FALSE, FALSE); - return chunk_clone(out); + *gen = chunk_clone(out); + return TRUE; } METHOD(simaka_message_t, destroy, void, |