@ -14,7 +14,7 @@ import {
IPacketAttributes ,
IPacketAttributes ,
IPacketHandler ,
IPacketHandler ,
IPacketHandlerResult ,
IPacketHandlerResult ,
PacketResponseCode
PacketResponseCode ,
} from '../../../../types/PacketHandler' ;
} from '../../../../types/PacketHandler' ;
import { MAX_RADIUS_ATTRIBUTE_SIZE , newDeferredPromise } from '../../../../helpers' ;
import { MAX_RADIUS_ATTRIBUTE_SIZE , newDeferredPromise } from '../../../../helpers' ;
import { IEAPMethod } from '../../../../types/EAPMethod' ;
import { IEAPMethod } from '../../../../types/EAPMethod' ;
@ -108,7 +108,7 @@ export class EAPTTLS implements IEAPMethod {
0 , // length (1/2)
0 , // length (1/2)
0 , // length (2/2)
0 , // length (2/2)
msgType , // 1 = identity, 21 = EAP-TTLS, 2 = notificaiton, 4 = md5-challenge, 3 = NAK
msgType , // 1 = identity, 21 = EAP-TTLS, 2 = notificaiton, 4 = md5-challenge, 3 = NAK
flags // flags: 000000 (L include lenghts, M .. more to come)
flags , // flags: 000000 (L include lenghts, M .. more to come)
] ) ;
] ) ;
// append length
// append length
@ -132,7 +132,7 @@ export class EAPTTLS implements IEAPMethod {
dataLength : ( data && data . byteLength ) || 0 ,
dataLength : ( data && data . byteLength ) || 0 ,
msgType : msgType.toString ( 10 ) ,
msgType : msgType.toString ( 10 ) ,
flags : ` 00000000 ${ flags . toString ( 2 ) } ` . substr ( - 8 ) ,
flags : ` 00000000 ${ flags . toString ( 2 ) } ` . substr ( - 8 ) ,
data
data ,
} ) ;
} ) ;
if ( dataToQueue ) {
if ( dataToQueue ) {
@ -161,7 +161,7 @@ export class EAPTTLS implements IEAPMethod {
if ( resBuffer . length > 0 ) {
if ( resBuffer . length > 0 ) {
attributes . push ( [
attributes . push ( [
'EAP-Message' ,
'EAP-Message' ,
resBuffer . slice ( sentDataSize , sentDataSize + MAX_RADIUS_ATTRIBUTE_SIZE )
resBuffer . slice ( sentDataSize , sentDataSize + MAX_RADIUS_ATTRIBUTE_SIZE ) ,
] ) ;
] ) ;
sentDataSize += MAX_RADIUS_ATTRIBUTE_SIZE ;
sentDataSize += MAX_RADIUS_ATTRIBUTE_SIZE ;
}
}
@ -169,7 +169,7 @@ export class EAPTTLS implements IEAPMethod {
return {
return {
code : PacketResponseCode.AccessChallenge ,
code : PacketResponseCode.AccessChallenge ,
attributes
attributes ,
} ;
} ;
}
}
@ -212,7 +212,7 @@ export class EAPTTLS implements IEAPMethod {
// R
// R
// reserved: flags & 0b00011000,
// reserved: flags & 0b00011000,
// V
// V
version : flags & 0 b00000111
version : flags & 0 b00000111 ,
} ;
} ;
let msglength ;
let msglength ;
@ -226,14 +226,14 @@ export class EAPTTLS implements IEAPMethod {
decodedFlags ,
decodedFlags ,
identifier ,
identifier ,
msglength ,
msglength ,
data
data ,
// dataStr: data.toString()
// dataStr: data.toString()
} ) ;
} ) ;
return {
return {
decodedFlags ,
decodedFlags ,
msglength ,
msglength ,
data
data ,
} ;
} ;
}
}
@ -247,7 +247,7 @@ export class EAPTTLS implements IEAPMethod {
success ? 3 : 4 , // 3.. success, 4... failure
success ? 3 : 4 , // 3.. success, 4... failure
identifier + 1 ,
identifier + 1 ,
0 , // length (1/2)
0 , // length (1/2)
4 // length (2/2)
4 , // length (2/2)
] ) ;
] ) ;
const attributes : any [ ] = [ ] ;
const attributes : any [ ] = [ ] ;
@ -268,13 +268,13 @@ export class EAPTTLS implements IEAPMethod {
attributes . push ( [
attributes . push ( [
'Vendor-Specific' ,
'Vendor-Specific' ,
311 ,
311 ,
[ [ 16 , encodeTunnelPW ( keyingMaterial . slice ( 64 ) , packet . authenticator , secret ) ] ]
[ [ 16 , encodeTunnelPW ( keyingMaterial . slice ( 64 ) , packet . authenticator , secret ) ] ] ,
] ) ; // MS-MPPE-Send-Key
] ) ; // MS-MPPE-Send-Key
attributes . push ( [
attributes . push ( [
'Vendor-Specific' ,
'Vendor-Specific' ,
311 ,
311 ,
[ [ 17 , encodeTunnelPW ( keyingMaterial . slice ( 0 , 64 ) , packet . authenticator , secret ) ] ]
[ [ 17 , encodeTunnelPW ( keyingMaterial . slice ( 0 , 64 ) , packet . authenticator , secret ) ] ] ,
] ) ; // MS-MPPE-Recv-Key
] ) ; // MS-MPPE-Recv-Key
} else {
} else {
console . error (
console . error (
@ -284,7 +284,7 @@ export class EAPTTLS implements IEAPMethod {
return {
return {
code : success ? PacketResponseCode.AccessAccept : PacketResponseCode.AccessReject ,
code : success ? PacketResponseCode.AccessAccept : PacketResponseCode.AccessReject ,
attributes
attributes ,
} ;
} ;
}
}
@ -338,7 +338,7 @@ export class EAPTTLS implements IEAPMethod {
// build attributes for packet handler
// build attributes for packet handler
const attributes : IPacketAttributes = { } ;
const attributes : IPacketAttributes = { } ;
AVPs . forEach ( avp = > {
AVPs . forEach ( ( avp ) = > {
attributes [ attr_id_to_name ( avp . type ) ] = avp . data ;
attributes [ attr_id_to_name ( avp . type ) ] = avp . data ;
} ) ;
} ) ;
@ -347,7 +347,7 @@ export class EAPTTLS implements IEAPMethod {
// handle incoming package via inner tunnel
// handle incoming package via inner tunnel
const result = await this . innerTunnel . handlePacket (
const result = await this . innerTunnel . handlePacket (
{
{
attributes
attributes ,
} ,
} ,
this . getEAPType ( )
this . getEAPType ( )
) ;
) ;
@ -367,15 +367,15 @@ export class EAPTTLS implements IEAPMethod {
. . . packet ,
. . . packet ,
attributes : {
attributes : {
. . . packet . attributes ,
. . . packet . attributes ,
. . . this . transformAttributesArrayToMap ( result . attributes )
. . . this . transformAttributesArrayToMap ( result . attributes ) ,
}
} ,
}
}
)
)
) ;
) ;
return ;
return ;
}
}
const eapMessage = result . attributes ? . find ( attr = > attr [ 0 ] === 'EAP-Message' ) ;
const eapMessage = result . attributes ? . find ( ( attr ) = > attr [ 0 ] === 'EAP-Message' ) ;
if ( ! eapMessage ) {
if ( ! eapMessage ) {
throw new Error ( 'no eap message found' ) ;
throw new Error ( 'no eap message found' ) ;
}
}
@ -456,7 +456,7 @@ export class EAPTTLS implements IEAPMethod {
// L
// L
V : ! ! ( flags & 0 b10000000 ) ,
V : ! ! ( flags & 0 b10000000 ) ,
// M
// M
M : ! ! ( flags & 0 b01000000 )
M : ! ! ( flags & 0 b01000000 ) ,
} ;
} ;
// const length = buffer.slice(5, 8).readUInt16BE(0); // actually a Int24BE
// const length = buffer.slice(5, 8).readUInt16BE(0); // actually a Int24BE
@ -478,7 +478,7 @@ export class EAPTTLS implements IEAPMethod {
decodedFlags ,
decodedFlags ,
length ,
length ,
vendorId ,
vendorId ,
data
data ,
} ) ;
} ) ;
// ensure length is a multiple of 4 octect
// ensure length is a multiple of 4 octect