Invoke attribute/key hooks from libsimaka
authorMartin Willi <martin@strongswan.org>
Fri, 27 Nov 2009 10:16:20 +0000 (11:16 +0100)
committerMartin Willi <martin@strongswan.org>
Mon, 30 Nov 2009 08:27:34 +0000 (09:27 +0100)
src/libsimaka/simaka_crypto.c
src/libsimaka/simaka_message.c

index 4afab23..b855020 100644 (file)
@@ -124,6 +124,8 @@ static chunk_t derive_keys_full(private_simaka_crypto_t *this,
        this->signer->set_key(this->signer, k_auth);
        this->crypter->set_key(this->crypter, k_encr);
 
+       charon->sim->key_hook(charon->sim, k_encr, k_auth);
+
        this->derived = TRUE;
        return chunk_clone(msk);
 }
@@ -150,6 +152,8 @@ static void derive_keys_reauth(private_simaka_crypto_t *this, chunk_t mk)
        this->signer->set_key(this->signer, k_auth);
        this->crypter->set_key(this->crypter, k_encr);
 
+       charon->sim->key_hook(charon->sim, k_encr, k_auth);
+
        this->derived = TRUE;
 }
 
index b64ff1b..22d111b 100644 (file)
@@ -256,12 +256,16 @@ static void add_attribute(private_simaka_message_t *this,
 {
        attr_t *attr;
 
-       attr = malloc(sizeof(attr_t) + data.len);
-       attr->len = data.len;
-       attr->type = type;
-       memcpy(attr->data, data.ptr, data.len);
+       if (!charon->sim->attribute_hook(charon->sim, this->hdr->code,
+                                                       this->hdr->type, this->hdr->subtype, type, data))
+       {
+               attr = malloc(sizeof(attr_t) + data.len);
+               attr->len = data.len;
+               attr->type = type;
+               memcpy(attr->data, data.ptr, data.len);
 
-       this->attributes->insert_last(this->attributes, attr);
+               this->attributes->insert_last(this->attributes, attr);
+       }
 }
 
 /**