diff options
Diffstat (limited to 'DNSKey.hs')
-rw-r--r-- | DNSKey.hs | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -5,8 +5,7 @@ import Data.Binary.Get | |||
5 | import Data.Binary.Put | 5 | import Data.Binary.Put |
6 | import Data.Bits | 6 | import Data.Bits |
7 | import qualified Data.ByteString as B | 7 | import qualified Data.ByteString as B |
8 | import qualified Data.ByteString.Lazy as L | 8 | import Data.Int |
9 | import Data.Word | ||
10 | 9 | ||
11 | -- RSA n e | 10 | -- RSA n e |
12 | -- n = modulus | 11 | -- n = modulus |
@@ -14,6 +13,7 @@ import Data.Word | |||
14 | data RSA = RSA Integer Integer | 13 | data RSA = RSA Integer Integer |
15 | deriving (Eq,Show) | 14 | deriving (Eq,Show) |
16 | 15 | ||
16 | getRSA :: Int64 -> Get RSA | ||
17 | getRSA len = do | 17 | getRSA len = do |
18 | elen <- do | 18 | elen <- do |
19 | tog <- get | 19 | tog <- get |
@@ -27,6 +27,7 @@ getRSA len = do | |||
27 | n = snd $ B.foldl' (\(c,a) w8 -> (c-1, a + 256^c * fromIntegral w8)) (nlen-1,0) nbs | 27 | n = snd $ B.foldl' (\(c,a) w8 -> (c-1, a + 256^c * fromIntegral w8)) (nlen-1,0) nbs |
28 | return $ RSA n e | 28 | return $ RSA n e |
29 | 29 | ||
30 | putRSA :: RSA -> PutM () | ||
30 | putRSA (RSA n e) = do | 31 | putRSA (RSA n e) = do |
31 | if elen > 255 || elen==0 | 32 | if elen > 255 || elen==0 |
32 | then do | 33 | then do |