summaryrefslogtreecommitdiff
path: root/DNSKey.hs
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2019-07-06 17:33:40 -0400
committerJoe Crayne <joe@jerkface.net>2019-07-06 17:33:40 -0400
commitb7da6a23a4ae94e8ce376376df77401ee779f028 (patch)
treeb126cf0b6bc6cb0fb6e383409f35430a32fe58bf /DNSKey.hs
parentb1ae1ecdc9d1f16134ea40b07a6cedcc26a94db8 (diff)
sigs
Diffstat (limited to 'DNSKey.hs')
-rw-r--r--DNSKey.hs5
1 files changed, 3 insertions, 2 deletions
diff --git a/DNSKey.hs b/DNSKey.hs
index 5c71c16..03767cf 100644
--- a/DNSKey.hs
+++ b/DNSKey.hs
@@ -5,8 +5,7 @@ import Data.Binary.Get
5import Data.Binary.Put 5import Data.Binary.Put
6import Data.Bits 6import Data.Bits
7import qualified Data.ByteString as B 7import qualified Data.ByteString as B
8import qualified Data.ByteString.Lazy as L 8import Data.Int
9import 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
14data RSA = RSA Integer Integer 13data RSA = RSA Integer Integer
15 deriving (Eq,Show) 14 deriving (Eq,Show)
16 15
16getRSA :: Int64 -> Get RSA
17getRSA len = do 17getRSA 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
30putRSA :: RSA -> PutM ()
30putRSA (RSA n e) = do 31putRSA (RSA n e) = do
31 if elen > 255 || elen==0 32 if elen > 255 || elen==0
32 then do 33 then do