- fixed encryption bug
authorMartin Willi <martin@strongswan.org>
Wed, 30 Nov 2005 09:11:48 +0000 (09:11 -0000)
committerMartin Willi <martin@strongswan.org>
Wed, 30 Nov 2005 09:11:48 +0000 (09:11 -0000)
Source/charon/encoding/message.c
Source/charon/encoding/payloads/encryption_payload.c

index 36ff4df..8046031 100644 (file)
@@ -438,22 +438,17 @@ static void add_payload(private_message_t *this, payload_t *payload)
        if (this->payloads->get_count(this->payloads) > 0)
        {
                this->payloads->get_last(this->payloads,(void **) &last_payload);
        if (this->payloads->get_count(this->payloads) > 0)
        {
                this->payloads->get_last(this->payloads,(void **) &last_payload);
-       }
-       
-       this->payloads->insert_last(this->payloads, payload);
-
-       if (this->payloads->get_count(this->payloads) == 1)
-       {
-               this->first_payload = payload->get_type(payload);
+               last_payload->set_next_type(last_payload, payload->get_type(payload));
        }
        else
        {
        }
        else
        {
-               last_payload->set_next_type(last_payload,payload->get_type(payload));
+               this->first_payload = payload->get_type(payload);
        }
        }
-       
+       payload->set_next_type(payload, NO_PAYLOAD);
+       this->payloads->insert_last(this->payloads, (void*)payload);
+
        this->logger->log(this->logger, CONTROL|MORE, "added payload of type %s to message", 
                                                mapping_find(payload_type_m, payload->get_type(payload)));
        this->logger->log(this->logger, CONTROL|MORE, "added payload of type %s to message", 
                                                mapping_find(payload_type_m, payload->get_type(payload)));
-       
 }
 
 /**
 }
 
 /**
@@ -660,7 +655,8 @@ static status_t parse_body(private_message_t *this, crypter_t *crypter, signer_t
        status_t status = SUCCESS;
        payload_type_t current_payload_type = this->first_payload;
                
        status_t status = SUCCESS;
        payload_type_t current_payload_type = this->first_payload;
                
-       this->logger->log(this->logger, CONTROL, "parsing body of message");
+       this->logger->log(this->logger, CONTROL, "parsing body of message, first payload %s",
+                                               mapping_find(payload_type_m, current_payload_type));
 
        while ((current_payload_type != NO_PAYLOAD))
        {
 
        while ((current_payload_type != NO_PAYLOAD))
        {
@@ -953,7 +949,7 @@ static status_t encrypt_payloads (private_message_t *this,crypter_t *crypter, si
        {
                encryption_payload->set_transforms(encryption_payload,crypter,signer);
                status = encryption_payload->encrypt(encryption_payload);
        {
                encryption_payload->set_transforms(encryption_payload,crypter,signer);
                status = encryption_payload->encrypt(encryption_payload);
-               this->payloads->insert_last(this->payloads,encryption_payload);
+               this->public.add_payload(&(this->public), (payload_t*)encryption_payload);
        }
        
        all_payloads->destroy(all_payloads);
        }
        
        all_payloads->destroy(all_payloads);
index 4acfa61..1212937 100644 (file)
@@ -159,59 +159,7 @@ encoding_rule_t encryption_payload_encodings[] = {
  */
 static status_t verify(private_encryption_payload_t *this)
 {
  */
 static status_t verify(private_encryption_payload_t *this)
 {
-//     int proposal_number = 1;
-       status_t status;
-//     iterator_t *iterator;
-//     bool first = TRUE;
-//     
-//     if (this->critical)
-//     {
-//             /* critical bit set! */
-//             return FAILED;
-//     }
-// 
-//     /* check proposal numbering */          
-//     status = this->proposals->create_iterator(this->proposals,&iterator,TRUE);
-//     if (status != SUCCESS)
-//     {
-//             return status;
-//     }
-//     
-//     while(iterator->has_next(iterator))
-//     {
-//             proposal_substructure_t *current_proposal;
-//             status = iterator->current(iterator,(void **)&current_proposal);
-//             {
-//                     break;
-//             }
-//             if (current_proposal->get_proposal_number(current_proposal) > proposal_number)
-//             {
-//                     if (first) 
-//                     {
-//                             /* first number must be 1 */
-//                             status = FAILED;
-//                             break;
-//                     }
-//                     
-//                     if (current_proposal->get_proposal_number(current_proposal) != (proposal_number + 1))
-//                     {
-//                             /* must be only one more then previous proposal */
-//                             status = FAILED;
-//                             break;
-//                     }
-//             }
-//             else if (current_proposal->get_proposal_number(current_proposal) < proposal_number)
-//             {
-//                     iterator->destroy(iterator);
-//                     /* must not be smaller then proceeding one */
-//                     status = FAILED;
-//                     break;
-//             }
-//             first = FALSE;
-//     }
-//     
-//     iterator->destroy(iterator);
-       return status;
+       return SUCCESS;
 }
 
 /**
 }
 
 /**