embedded IPsec source code documentation


sa_test.c File Reference


Detailed Description

Test functions for Security Association Database.

Author:
Niklaus Schild <n.schild@gmx.ch>
OUTLINE:

This file contains test functions used to verify the SA code.

IMPLEMENTATION:

There are no implementation hints to be mentioned.

NOTES:

This document is part of embedded IPsec
Copyright (c) 2003 Niklaus Schild and Christian Scheurer, HTI Biel/Bienne
All rights reserved.


Definition in file sa_test.c.

#include <string.h>
#include "ipsec/util.h"
#include "ipsec/debug.h"
#include "testing/structural/structural_test.h"
#include "ipsec/sa.h"

Go to the source code of this file.

Defines

#define MAX_IP_ADD_LENGTH   (15)

Functions

int test_spd_init (void)
int test_spd_get_free (void)
int test_spd_add (void)
int test_spd_del (void)
int test_spd_lookup (void)
int test_sad_lookup (void)
int test_sad_get_spi (void)
int test_spd_flush (void)
int test_sad_flush (void)
int test_sad_add (void)
int test_sad_del (void)
void sa_test (test_result *global_results)

Variables

sad_entry inbound_sad_test [IPSEC_MAX_SAD_ENTRIES]
spd_entry inbound_spd_test [IPSEC_MAX_SAD_ENTRIES]
sad_entry outbound_sad_test [IPSEC_MAX_SAD_ENTRIES]
spd_entry outbound_spd_test [IPSEC_MAX_SPD_ENTRIES]
spd_entry outbound_spd [IPSEC_MAX_SPD_ENTRIES]
spd_entry inbound_spd [IPSEC_MAX_SPD_ENTRIES]
sad_entry outbound_sad [IPSEC_MAX_SAD_ENTRIES]
sad_entry inbound_sad [IPSEC_MAX_SAD_ENTRIES]
unsigned char ip_ftp_1 [70]
unsigned char ip_ftp_2 [67]
unsigned char ip_rip [28]
unsigned char ip_ah [20]
unsigned char ip_esp [20]
unsigned char ip_def [70]
unsigned char esp_hdr [32]
unsigned char ah_hdr [48]


Define Documentation

#define MAX_IP_ADD_LENGTH   (15)
 

Definition at line 203 of file sa_test.c.


Function Documentation

void sa_test test_result global_results  ) 
 

Main test function for the SA tests. It does nothing but calling the subtests one after the other.

Definition at line 887 of file sa_test.c.

int test_sad_add void   ) 
 

Definition at line 871 of file sa_test.c.

int test_sad_del void   ) 
 

Definition at line 877 of file sa_test.c.

int test_sad_flush void   ) 
 

Definition at line 865 of file sa_test.c.

int test_sad_get_spi void   ) 
 

Check if SPI lookup in the SAD works. 2 tests are performed here.

Definition at line 836 of file sa_test.c.

int test_sad_lookup void   ) 
 

Check if the Security Association Database (SAD) lookup function works. 4 tests are performed here

Definition at line 777 of file sa_test.c.

int test_spd_add void   ) 
 

Test adding of SPD entries 5 tests are performed here

Definition at line 425 of file sa_test.c.

int test_spd_del void   ) 
 

Test removing of SPD entries 10 tests are performed here

Definition at line 544 of file sa_test.c.

int test_spd_flush void   ) 
 

Definition at line 859 of file sa_test.c.

int test_spd_get_free void   ) 
 

Check if SPD lookup for free entries works. 4 tests are performed here.

Definition at line 345 of file sa_test.c.

int test_spd_init void   ) 
 

Check if the SPD initialization works correctly. 16 tests are performed here.

Definition at line 210 of file sa_test.c.

int test_spd_lookup void   ) 
 

Check if the Security Policy Database (SPD) lookup function works. 6 tests are performed here.

Definition at line 703 of file sa_test.c.


Variable Documentation

unsigned char ah_hdr[48]
 

Initial value:

{
    0x45, 0x00, 0x00, 0x68, 0x79, 0x9C, 0x00, 0x00, 0x40, 0x33, 0x7D, 0x4B, 0xC0, 0xA8, 0x01, 0x28,
    0xC0, 0xA8, 0x01, 0x03, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10, 0x09, 0x00, 0x00, 0x00, 0x01,
    0x45, 0x2F, 0x1D, 0xE9, 0xEE, 0x8B, 0x41, 0x26, 0x44, 0x51, 0xCC, 0x8D, 0x45, 0x00, 0x00, 0x3C,
}

Definition at line 196 of file sa_test.c.

unsigned char esp_hdr[32]
 

Initial value:

{
    0x45, 0x00, 0x00, 0x64, 0x79, 0x30, 0x00, 0x00, 0x40, 0x32, 0x7D, 0xBC, 0xC0, 0xA8, 0x01, 0x28,
    0xC0, 0xA8, 0x01, 0x03, 0x00, 0x00, 0x10, 0x06, 0x00, 0x00, 0x00, 0x01, 0x87, 0xC5, 0xBA, 0x8C,
}

Definition at line 190 of file sa_test.c.

sad_entry inbound_sad[IPSEC_MAX_SAD_ENTRIES]
 

Definition at line 141 of file sa_test.c.

sad_entry inbound_sad_test[IPSEC_MAX_SAD_ENTRIES]
 

Initial value:

 {
{       SAD_ENTRY(      192,168,1,1, 255,255,255,255, 
                                0x1001, 
                                IPSEC_PROTO_ESP, IPSEC_TUNNEL, 
                                IPSEC_3DES, 
                                0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45 , 0x67, 0x01, 0x23, 0x45, 0x67, 
                                0,  
                                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),

        SAD_ENTRY(      192,168,1,2, 255,255,255,255, 
                                0x1002, 
                                IPSEC_PROTO_AH, IPSEC_TUNNEL, 
                                0, 
                                0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45 , 0x67, 0x01, 0x23, 0x45, 0x67,  
                                IPSEC_HMAC_MD5,  
                                0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45, 0x67, 0, 0, 0, 0),

        SAD_ENTRY(      192,168,156,189, 255,255,255,255, 
                                0x0010002, 
                                IPSEC_PROTO_AH, IPSEC_TUNNEL, 
                                0, 
                                0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45 , 0x67, 0x01, 0x23, 0x45, 0x67, 
                                IPSEC_HMAC_SHA1,  
                                0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45, 0x67, 0, 0, 0, 0)}
}

Definition at line 60 of file sa_test.c.

spd_entry inbound_spd[IPSEC_MAX_SPD_ENTRIES]
 

Definition at line 138 of file sa_test.c.

spd_entry inbound_spd_test[IPSEC_MAX_SAD_ENTRIES]
 

Initial value:

 {

{ SPD_ENTRY(  204,152,189,116, 255,255,255,0,   147,87,70,105,   255,255,255,255, IPSEC_PROTO_TCP,  21,    0,     POLICY_DISCARD, 0)},
{ SPD_ENTRY(  147,87,70,105,   255,255,255,255, 204,152,189,116, 255,255,255,255, IPSEC_PROTO_TCP,  0,     21,    POLICY_APPLY,   0)},
{ SPD_ENTRY(  147,87,70,250,   255,255,255,0,   255,255,255,255, 255,255,255,255, IPSEC_PROTO_UDP,  0,     0,     POLICY_APPLY,   0)},
{ SPD_ENTRY(  192,168,1,0,     255,255,255,0,   192,168,1,3,     255,255,255,255, IPSEC_PROTO_AH,   0,     0,     POLICY_APPLY,   0)},
{ SPD_ENTRY(  192,168,1,40,    255,255,255,255, 192,168,1,3,     255,255,255,255, IPSEC_PROTO_ESP,  0,     0,     POLICY_APPLY,   0)},
{ SPD_ENTRY(  0,0,0,0,         0,0,0,0,         0,0,0,0,         0,0,0,0,         0,                0,     0,     POLICY_BYPASS,  0)}
}

Definition at line 87 of file sa_test.c.

unsigned char ip_ah[20]
 

Initial value:

{
    0x45, 0x00, 0x00, 0x68, 0x79, 0x9C, 0x00, 0x00, 0x40, 0x33, 0x7D, 0x4B, 0xC0, 0xA8, 0x01, 0x28,
    0xC0, 0xA8, 0x01, 0x03,
}

Definition at line 169 of file sa_test.c.

unsigned char ip_def[70]
 

Initial value:

{
    0x45, 0x00, 0x00, 0x46, 0x8E, 0xF2, 0x40, 0x00, 0x31, 0x06, 0x56, 0xF2, 0xCA, 0x92, 0xB0, 0x74,
    0x93, 0x57, 0x46, 0x69, 0x00, 0x15, 0x11, 0xEF, 0x38, 0x57, 0xC8, 0x7F, 0xEC, 0x0F, 0x03, 0x14,
    0x50, 0x18, 0x16, 0xD0, 0x76, 0x2A, 0x00, 0x00, 0x32, 0x30, 0x30, 0x20, 0x50, 0x4F, 0x52, 0x54,
    0x20, 0x63, 0x6F, 0x6D, 0x6D, 0x61, 0x6E, 0x64, 0x20, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73,
    0x66, 0x75, 0x6C, 0x2E, 0x0D, 0x0A,
}

Definition at line 181 of file sa_test.c.

unsigned char ip_esp[20]
 

Initial value:

{
    0x45, 0x00, 0x00, 0x64, 0x79, 0x30, 0x00, 0x00, 0x40, 0x32, 0x7D, 0xBC, 0xC0, 0xA8, 0x01, 0x28,
    0xC0, 0xA8, 0x01, 0x03,
}

Definition at line 175 of file sa_test.c.

unsigned char ip_ftp_1[70]
 

Initial value:

{
    0x45, 0x00, 0x00, 0x46, 0x8E, 0xF2, 0x40, 0x00, 0x31, 0x06, 0x56, 0xF2, 0xCC, 0x98, 0xBD, 0x74,
    0x93, 0x57, 0x46, 0x69, 0x00, 0x15, 0x11, 0xEF, 0x38, 0x57, 0xC8, 0x7F, 0xEC, 0x0F, 0x03, 0x14,
    0x50, 0x18, 0x16, 0xD0, 0x76, 0x2A, 0x00, 0x00, 0x32, 0x30, 0x30, 0x20, 0x50, 0x4F, 0x52, 0x54,
    0x20, 0x63, 0x6F, 0x6D, 0x6D, 0x61, 0x6E, 0x64, 0x20, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73,
    0x66, 0x75, 0x6C, 0x2E, 0x0D, 0x0A,
}

Definition at line 145 of file sa_test.c.

unsigned char ip_ftp_2[67]
 

Initial value:

{
    0x45, 0x00, 0x00, 0x43, 0xB6, 0x8F, 0x40, 0x00, 0x80, 0x06, 0x00, 0x00, 0x93, 0x57, 0x46, 0x69,
    0xCC, 0x98, 0xBD, 0x74, 0x11, 0xEF, 0x00, 0x15, 0xEC, 0x0F, 0x02, 0xF9, 0x38, 0x57, 0xC8, 0x7F,
    0x50, 0x18, 0xFF, 0x62, 0x64, 0x03, 0x00, 0x00, 0x50, 0x4F, 0x52, 0x54, 0x20, 0x31, 0x34, 0x37,
    0x2C, 0x38, 0x37, 0x2C, 0x37, 0x30, 0x2C, 0x31, 0x30, 0x35, 0x2C, 0x31, 0x37, 0x2C, 0x32, 0x34,
    0x30, 0x0D, 0x0A,
}

Definition at line 154 of file sa_test.c.

unsigned char ip_rip[28]
 

Initial value:

{
    0x45, 0xC0, 0x02, 0x14, 0x00, 0x00, 0x00, 0x00, 0x02, 0x11, 0xDB, 0xC8, 0x93, 0x57, 0x46, 0xFA,
    0xFF, 0xFF, 0xFF, 0xFF, 0x02, 0x08, 0x02, 0x08, 0x02, 0x00, 0x96, 0x98,
}

Definition at line 163 of file sa_test.c.

sad_entry outbound_sad[IPSEC_MAX_SAD_ENTRIES]
 

Definition at line 140 of file sa_test.c.

sad_entry outbound_sad_test[IPSEC_MAX_SAD_ENTRIES]
 

Initial value:

 {
{       SAD_ENTRY(      192,168,156,189, 255,255,255,255, 
                                0x100000, 
                                IPSEC_PROTO_AH, IPSEC_TUNNEL, 
                                IPSEC_3DES, 
                                0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45 , 0x67, 0x01, 0x23, 0x45, 0x67, 
                                IPSEC_HMAC_SHA1,  
                                0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45, 0x67, 0, 0, 0, 0),

        SAD_ENTRY(      192,168,156,189, 255,255,255,255, 
                                0x100000, 
                                IPSEC_PROTO_ESP, IPSEC_TUNNEL, 
                                IPSEC_3DES, 
                                0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45 , 0x67, 0x01, 0x23, 0x45, 0x67, 
                                IPSEC_HMAC_SHA1,  
                                0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45, 0x67, 0, 0, 0, 0),

        SAD_ENTRY(      192,168,156,189, 255,255,255,255, 
                                0x100000, 
                                IPSEC_PROTO_AH, IPSEC_TUNNEL, 
                                0, 
                                0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45 , 0x67, 0x01, 0x23, 0x45, 0x67, 
                                IPSEC_HMAC_SHA1,  
                                0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45, 0x67, 0, 0, 0, 0)}
}

Definition at line 101 of file sa_test.c.

spd_entry outbound_spd[IPSEC_MAX_SPD_ENTRIES]
 

Definition at line 137 of file sa_test.c.

spd_entry outbound_spd_test[IPSEC_MAX_SPD_ENTRIES]
 

Initial value:

 {

{ SPD_ENTRY(  192,168,1,1,     255,255,255,255, 192,168,1,3,     255,255,255,255, IPSEC_PROTO_ICMP, 0,     0,     POLICY_APPLY,   0)},
{ SPD_ENTRY(  192,168,1,2,     255,255,255,255, 192,168,1,3,     255,255,255,255, 0,                0,     80,    POLICY_DISCARD, 0)},
{ SPD_ENTRY(  192,168,1,2,     255,255,255,255, 192,168,1,3,     255,255,255,255, 0,                0,     0,     POLICY_BYPASS,  0)},
{ SPD_ENTRY(  0,0,0,0,         0,0,0,0,         0,0,0,0,         0,0,0,0,         0,                0,     0,     POLICY_BYPASS,  0)}
}

Definition at line 128 of file sa_test.c.


Copyright 2003 by Christian Scheurer and Niklaus Schild