Search in sources :

Example 6 with EAP

use of org.onlab.packet.EAP in project aaa by opencord.

the class AaaStatisticsTest method checkRadiusPacketFromSupplicant.

/**
 * Extracts the RADIUS packet from a packet sent by the supplicant.
 *
 * @param radius RADIUS packet sent by the supplicant
 * @throws DeserializationException if deserialization of the packet contents fails.
 */
private void checkRadiusPacketFromSupplicant(RADIUS radius) throws DeserializationException {
    assertThat(radius, notNullValue());
    EAP eap = radius.decapsulateMessage();
    assertThat(eap, notNullValue());
}
Also used : EAP(org.onlab.packet.EAP)

Example 7 with EAP

use of org.onlab.packet.EAP in project aaa by opencord.

the class AaaTestBase method constructSupplicantIdentifyPacket.

/**
 * Constructs an Ethernet packet containing identification payload.
 *
 * @return Ethernet packet
 */
Ethernet constructSupplicantIdentifyPacket(StateMachine stateMachine, byte type, byte id, Ethernet radiusChallenge) throws Exception {
    Ethernet eth = new Ethernet();
    eth.setDestinationMACAddress(clientMac.toBytes());
    eth.setSourceMACAddress(serverMac.toBytes());
    eth.setEtherType(EthType.EtherType.EAPOL.ethType().toShort());
    eth.setVlanID((short) 2);
    String username = "testuser";
    byte[] data = username.getBytes();
    if (type == EAP.ATTR_MD5) {
        String password = "testpassword";
        EAPOL eapol = (EAPOL) radiusChallenge.getPayload();
        EAP eap = (EAP) eapol.getPayload();
        byte[] identifier = new byte[password.length() + eap.getData().length];
        identifier[0] = stateMachine.challengeIdentifier();
        System.arraycopy(password.getBytes(), 0, identifier, 1, password.length());
        System.arraycopy(eap.getData(), 1, identifier, 1 + password.length(), 16);
        MessageDigest md = MessageDigest.getInstance("MD5");
        byte[] hash = md.digest(identifier);
        data = new byte[17];
        data[0] = (byte) 16;
        System.arraycopy(hash, 0, data, 1, 16);
    }
    EAP eap = new EAP(EAP.RESPONSE, (byte) 1, type, data);
    eap.setIdentifier(id);
    // eapol header
    EAPOL eapol = new EAPOL();
    eapol.setEapolType(EAPOL.EAPOL_PACKET);
    eapol.setPacketLength(eap.getLength());
    // eap part
    eapol.setPayload(eap);
    eth.setPayload(eapol);
    eth.setPad(true);
    return eth;
}
Also used : EAP(org.onlab.packet.EAP) Ethernet(org.onlab.packet.Ethernet) EAPOL(org.onlab.packet.EAPOL) MessageDigest(java.security.MessageDigest)

Example 8 with EAP

use of org.onlab.packet.EAP in project aaa by opencord.

the class AaaTestBase method checkRadiusPacket.

/**
 * Checks the contents of a RADIUS packet being sent to the RADIUS server.
 *
 * @param radiusPacket packet to check
 * @param code         expected code
 */
void checkRadiusPacket(AaaManager aaaManager, Ethernet radiusPacket, byte code) {
    assertThat(radiusPacket.getSourceMAC(), is(MacAddress.valueOf(aaaManager.nasMacAddress)));
    assertThat(radiusPacket.getDestinationMAC(), is(serverMac));
    assertThat(radiusPacket.getPayload(), instanceOf(EAPOL.class));
    EAPOL eapol = (EAPOL) radiusPacket.getPayload();
    assertThat(eapol, notNullValue());
    assertThat(eapol.getEapolType(), is(EAPOL.EAPOL_PACKET));
    assertThat(eapol.getPayload(), instanceOf(EAP.class));
    EAP eap = (EAP) eapol.getPayload();
    assertThat(eap, notNullValue());
    assertThat(eap.getCode(), is(code));
}
Also used : EAP(org.onlab.packet.EAP) EAPOL(org.onlab.packet.EAPOL)

Example 9 with EAP

use of org.onlab.packet.EAP in project aaa by opencord.

the class AaaTestBase method constructSupplicantStartPacket.

/**
 * Constructs an Ethernet packet containing a EAPOL_START Payload.
 *
 * @return Ethernet packet
 */
Ethernet constructSupplicantStartPacket() {
    Ethernet eth = new Ethernet();
    eth.setDestinationMACAddress(clientMac.toBytes());
    eth.setSourceMACAddress(serverMac.toBytes());
    eth.setEtherType(EthType.EtherType.EAPOL.ethType().toShort());
    eth.setVlanID((short) 2);
    EAP eap = new EAP(EAPOL.EAPOL_START, (byte) 3, EAPOL.EAPOL_START, null);
    // eapol header
    EAPOL eapol = new EAPOL();
    eapol.setEapolType(EAPOL.EAPOL_START);
    eapol.setPacketLength(eap.getLength());
    // eap part
    eapol.setPayload(eap);
    eth.setPayload(eapol);
    eth.setPad(true);
    return eth;
}
Also used : EAP(org.onlab.packet.EAP) Ethernet(org.onlab.packet.Ethernet) EAPOL(org.onlab.packet.EAPOL)

Example 10 with EAP

use of org.onlab.packet.EAP in project aaa by opencord.

the class AaaTestBase method constructRadiusCodeAccessChallengePacket.

/**
 * Constructs an Ethernet packet containing a RADIUS challenge
 * packet.
 *
 * @param challengeCode code to use in challenge packet
 * @param challengeType type to use in challenge packet
 * @return Ethernet packet
 */
RADIUS constructRadiusCodeAccessChallengePacket(byte challengeCode, byte challengeType, byte identifier, byte[] messageAuth) {
    String challenge = "12345678901234567";
    EAP eap = new EAP(challengeType, (byte) 4, challengeType, challenge.getBytes(Charsets.US_ASCII));
    // eap.setIdentifier((byte) 4);
    eap.setIdentifier(identifier);
    RADIUS radius = new RADIUS();
    radius.setCode(challengeCode);
    // radius.setIdentifier((byte) 4);
    radius.setIdentifier(identifier);
    radius.setAttribute(RADIUSAttribute.RADIUS_ATTR_STATE, challenge.getBytes(Charsets.US_ASCII));
    radius.setPayload(eap);
    radius.setAttribute(RADIUSAttribute.RADIUS_ATTR_EAP_MESSAGE, eap.serialize());
    radius.setAttribute(RADIUSAttribute.RADIUS_ATTR_MESSAGE_AUTH, messageAuth);
    return radius;
}
Also used : RADIUS(org.onlab.packet.RADIUS) EAP(org.onlab.packet.EAP)

Aggregations

EAP (org.onlab.packet.EAP)10 EAPOL (org.onlab.packet.EAPOL)6 Ethernet (org.onlab.packet.Ethernet)6 MessageDigest (java.security.MessageDigest)1 Test (org.junit.Test)1 DeserializationException (org.onlab.packet.DeserializationException)1 MacAddress (org.onlab.packet.MacAddress)1 RADIUS (org.onlab.packet.RADIUS)1 RADIUSAttribute (org.onlab.packet.RADIUSAttribute)1 ConnectPoint (org.onosproject.net.ConnectPoint)1 AaaMachineStatisticsEvent (org.opencord.aaa.AaaMachineStatisticsEvent)1 AaaSupplicantMachineStats (org.opencord.aaa.AaaSupplicantMachineStats)1