]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
Add a return value to tls_prf_t.set_key()
authorMartin Willi <martin@revosec.ch>
Fri, 6 Jul 2012 07:49:25 +0000 (09:49 +0200)
committerMartin Willi <martin@revosec.ch>
Mon, 16 Jul 2012 12:53:33 +0000 (14:53 +0200)
src/libtls/tls_crypto.c
src/libtls/tls_prf.c
src/libtls/tls_prf.h

index 5f7002c3afce13df4a593245fcb9693d49862d07..fde03b800d1f2418c3957647f247c0dc10bac712 100644 (file)
@@ -1483,13 +1483,14 @@ static bool derive_master(private_tls_crypto_t *this, chunk_t premaster,
 
        /* derive master secret */
        seed = chunk_cata("cc", client_random, server_random);
-       this->prf->set_key(this->prf, premaster);
-       if (!this->prf->get_bytes(this->prf, "master secret", seed,
-                                                sizeof(master), master))
+
+       if (!this->prf->set_key(this->prf, premaster) ||
+               !this->prf->get_bytes(this->prf, "master secret", seed,
+                                                         sizeof(master), master) ||
+               !this->prf->set_key(this->prf, chunk_from_thing(master)))
        {
                return FALSE;
        }
-       this->prf->set_key(this->prf, chunk_from_thing(master));
 
        if (this->cache && session.len)
        {
@@ -1624,8 +1625,8 @@ METHOD(tls_crypto_t, resume_session, tls_cipher_suite_t,
                        this->suite = select_cipher_suite(this, &this->suite, 1, KEY_ANY);
                        if (this->suite)
                        {
-                               this->prf->set_key(this->prf, master);
-                               if (!expand_keys(this, client_random, server_random))
+                               if (!this->prf->set_key(this->prf, master) ||
+                                       !expand_keys(this, client_random, server_random))
                                {
                                        this->suite = 0;
                                }
index 0ef4418147d9ac78a90ee43332b972b23263ae31..09f6934489276f4622ee476d2cbfe505ef70dc3d 100644 (file)
@@ -33,10 +33,11 @@ struct private_tls_prf12_t {
        prf_t *prf;
 };
 
-METHOD(tls_prf_t, set_key12, void,
+METHOD(tls_prf_t, set_key12, bool,
        private_tls_prf12_t *this, chunk_t key)
 {
        this->prf->set_key(this->prf, key);
+       return TRUE;
 }
 
 /**
@@ -136,13 +137,14 @@ struct private_tls_prf10_t {
        prf_t *sha1;
 };
 
-METHOD(tls_prf_t, set_key10, void,
+METHOD(tls_prf_t, set_key10, bool,
        private_tls_prf10_t *this, chunk_t key)
 {
        size_t len = key.len / 2 + key.len % 2;
 
        this->md5->set_key(this->md5, chunk_create(key.ptr, len));
        this->sha1->set_key(this->sha1, chunk_create(key.ptr + key.len - len, len));
+       return TRUE;
 }
 
 METHOD(tls_prf_t, get_bytes10, bool,
index c78842e741d9c7baec3ca7b34c978e28e681f717..095eaea3afd053477139d0f6d4f189d7399348b8 100644 (file)
@@ -34,8 +34,9 @@ struct tls_prf_t {
         * Set the key of the PRF function.
         *
         * @param key           key to set
+        * @return                      TRUE if key set successfully
         */
-       void (*set_key)(tls_prf_t *this, chunk_t key);
+       bool (*set_key)(tls_prf_t *this, chunk_t key);
 
        /**
         * Generate a series of bytes using a label and a seed.