radius 0.2.0.0 → 0.3.0.0
raw patch · 3 files changed
+25/−19 lines, 3 filesdep +cryptohash-md5PVP ok
version bump matches the API change (PVP)
Dependencies added: cryptohash-md5
API changes (from Hackage documentation)
- Network.RADIUS.Encoding: fromEnum32 :: (Enum a) => Word32 -> a
+ Network.RADIUS.Encoding: sign :: ByteString -> ByteString -> ByteString
+ Network.RADIUS.Types: ISDNAsyncV110Port :: NASPortType
Files
- radius.cabal +2/−1
- src/Network/RADIUS/Encoding.hs +22/−18
- src/Network/RADIUS/Types.hs +1/−0
radius.cabal view
@@ -1,5 +1,5 @@ name: radius-version: 0.2.0.0+version: 0.3.0.0 synopsis: Remote Authentication Dial In User Service (RADIUS) description: This module provides types and on the wire de/coding of RADIUS packets as per RFC2865 homepage: https://github.com/erickg/radius#readme@@ -20,6 +20,7 @@ build-depends: base >= 4.7 && < 5 , binary , bytestring+ , cryptohash-md5 , iproute , pretty-hex default-language: Haskell2010
src/Network/RADIUS/Encoding.hs view
@@ -18,14 +18,15 @@ import Control.Monad (when) import Data.Binary (Binary(..), encode) import Data.Binary.Put (Put, putLazyByteString, putWord8, putWord16be, putWord32be)-import Data.Binary.Get (Get, getLazyByteString, getWord8, getWord16be, isEmpty)-import Data.ByteString.Lazy.Char8 (ByteString)+import Data.Binary.Get (Get, getLazyByteString, getWord8, getWord16be, getWord32be, isEmpty)+import Data.ByteString.Lazy.Char8 (ByteString, append) import Data.IP (IPv4, IPv6) import Data.Int (Int64)-import Data.Word (Word8, Word16, Word32)+import Data.Word (Word8, Word16) import Network.RADIUS.Types import qualified Data.ByteString.Lazy.Char8 as B+import qualified Crypto.Hash.MD5 as MD5 -- | Self explanatory. It can be useful when reading a RADIUS packet from a socket for example, -- so one can retrieve the packet header (containing the packet length) first and then use that@@ -74,9 +75,16 @@ return Packet { getHeader = header, getPacketAttributes = attributes } +sign :: ByteString -> ByteString -> ByteString+sign packet secret =+ let authenticator = B.fromStrict . MD5.hashlazy $ packet `append` secret+ prologue = B.take 4 packet -- size of type, id, length+ attributes = B.drop (fromIntegral radiusHeaderSize) packet+ in prologue `append` authenticator `append` attributes+ instance Binary PacketType where- put = putEnum- get = getEnum+ put = putWord8 . fromIntegral . fromEnum+ get = getWord8 >>= return . toEnum . fromIntegral -- | Used internally to encode a list of RADIUS attributes. You probably don't need this. encodeAttributes :: [PacketAttribute] -> ByteString@@ -243,22 +251,22 @@ getAttribute 62 = getAttributeValue >>= return . PortLimitAttribute getAttribute 4 = getAttributeValue >>= return . NASIPAddress getAttribute 95 = getAttributeValue >>= return . NASIPv6Address-getAttribute 6 = getAttributeValue >>= return . ServiceTypeAttribute . fromEnum32-getAttribute 7 = getAttributeValue >>= return . FramedProtocolAttribute . fromEnum32+getAttribute 6 = getAttributeValue >>= return . ServiceTypeAttribute+getAttribute 7 = getAttributeValue >>= return . FramedProtocolAttribute getAttribute 8 = getAttributeValue >>= return . FramedIPAddressAttribute getAttribute 9 = getAttributeValue >>= return . FramedIPNetmaskAttribute-getAttribute 10 = getAttributeValue >>= return . FramedRoutingAttribute . fromEnum32-getAttribute 13 = getAttributeValue >>= return . FramedCompressionAttribute . fromEnum32+getAttribute 10 = getAttributeValue >>= return . FramedRoutingAttribute+getAttribute 13 = getAttributeValue >>= return . FramedCompressionAttribute getAttribute 96 = getAttributeValue >>= return . FramedInterfaceIdAttribute getAttribute 14 = getAttributeValue >>= return . LoginIPHostAttribute getAttribute 98 = getAttributeValue >>= return . LoginIPv6HostAttribute-getAttribute 15 = getAttributeValue >>= return . LoginServiceAttribute . fromEnum32-getAttribute 29 = getAttributeValue >>= return . TerminationActionAttribute . fromEnum32-getAttribute 61 = getAttributeValue >>= return . NASPortTypeAttribute . fromEnum32+getAttribute 15 = getAttributeValue >>= return . LoginServiceAttribute+getAttribute 29 = getAttributeValue >>= return . TerminationActionAttribute+getAttribute 61 = getAttributeValue >>= return . NASPortTypeAttribute getAttribute 52 = getAttributeValue >>= return . AccountInputGigawordsAttribute getAttribute 53 = getAttributeValue >>= return . AccountOutputGigawordsAttribute getAttribute 55 = getAttributeValue >>= return . EventTimeStampAttribute-getAttribute 72 = getAttributeValue >>= return . ARAPZoneAccessAttribute . fromEnum32+getAttribute 72 = getAttributeValue >>= return . ARAPZoneAccessAttribute getAttribute 73 = getAttributeValue >>= return . ARAPSecurityAttribute getAttribute 75 = getAttributeValue >>= return . PasswordRetryAttribute getAttribute 76 = getAttributeValue >>= return . PromptAttribute@@ -330,8 +338,4 @@ -- | For internal use. getEnum :: (Enum a) => Get a-getEnum = getWord8 >>= return . toEnum . fromIntegral---- | For internal use.-fromEnum32 :: (Enum a) => Word32 -> a-fromEnum32 = toEnum . fromIntegral+getEnum = getWord32be >>= return . toEnum . fromIntegral
src/Network/RADIUS/Types.hs view
@@ -226,6 +226,7 @@ | SyncNASPort | ISDNSyncPort | ISDNAsyncV120Port+ | ISDNAsyncV110Port | VirtualNASPort | PIAFSNASPort | HDLCClearChannelNASPort