diff options
Diffstat (limited to 'overlays/spm/server/Crypto')
-rw-r--r-- | overlays/spm/server/Crypto/JOSE/JWK/Instances.hs | 9 | ||||
-rw-r--r-- | overlays/spm/server/Crypto/Random/Instances.hs | 27 |
2 files changed, 36 insertions, 0 deletions
diff --git a/overlays/spm/server/Crypto/JOSE/JWK/Instances.hs b/overlays/spm/server/Crypto/JOSE/JWK/Instances.hs new file mode 100644 index 00000000..44a5cfe0 --- /dev/null +++ b/overlays/spm/server/Crypto/JOSE/JWK/Instances.hs | |||
@@ -0,0 +1,9 @@ | |||
1 | {-# LANGUAGE TemplateHaskell #-} | ||
2 | {-# OPTIONS_GHC -fno-warn-orphans #-} | ||
3 | |||
4 | module Crypto.JOSE.JWK.Instances () where | ||
5 | |||
6 | import Control.Lens.TH | ||
7 | import Crypto.JOSE.JWK | ||
8 | |||
9 | makeWrapped ''JWKSet | ||
diff --git a/overlays/spm/server/Crypto/Random/Instances.hs b/overlays/spm/server/Crypto/Random/Instances.hs new file mode 100644 index 00000000..6b0890be --- /dev/null +++ b/overlays/spm/server/Crypto/Random/Instances.hs | |||
@@ -0,0 +1,27 @@ | |||
1 | {-# OPTIONS_GHC -fno-warn-orphans #-} | ||
2 | |||
3 | module Crypto.Random.Instances () where | ||
4 | |||
5 | import Prelude | ||
6 | import Crypto.Random | ||
7 | import System.Random | ||
8 | |||
9 | import qualified Data.ByteString as BS | ||
10 | |||
11 | import Data.Bits | ||
12 | |||
13 | |||
14 | instance RandomGen ChaChaDRG where | ||
15 | split = flip withDRG drgNew | ||
16 | |||
17 | genWord64 g = withRandomBytes g 8 $ \case | ||
18 | (map fromIntegral . BS.unpack -> [b1, b2, b3, b4, b5, b6, b7, b8]) | ||
19 | -> b1 `shiftL` 56 | ||
20 | .|. b2 `shiftL` 48 | ||
21 | .|. b3 `shiftL` 40 | ||
22 | .|. b4 `shiftL` 32 | ||
23 | .|. b5 `shiftL` 24 | ||
24 | .|. b6 `shiftL` 16 | ||
25 | .|. b7 `shiftL` 8 | ||
26 | .|. b8 | ||
27 | _other -> error "withRandomBytes did not return correct number of bytes" | ||