summaryrefslogtreecommitdiff
path: root/overlays/spm/server/Crypto
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2022-05-26 13:58:07 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2022-05-26 13:58:07 +0200
commitfc6cf6169868e60c189e4b243330c3717ff159f3 (patch)
tree3f6dea9c1420e23756257b5abea27ec9ed92d58a /overlays/spm/server/Crypto
parent84f2affd66a0ff3947b91a30308cb8e6a8ff7594 (diff)
downloadnixos-fc6cf6169868e60c189e4b243330c3717ff159f3.tar
nixos-fc6cf6169868e60c189e4b243330c3717ff159f3.tar.gz
nixos-fc6cf6169868e60c189e4b243330c3717ff159f3.tar.bz2
nixos-fc6cf6169868e60c189e4b243330c3717ff159f3.tar.xz
nixos-fc6cf6169868e60c189e4b243330c3717ff159f3.zip
...
Diffstat (limited to 'overlays/spm/server/Crypto')
-rw-r--r--overlays/spm/server/Crypto/JOSE/JWK/Instances.hs9
-rw-r--r--overlays/spm/server/Crypto/Random/Instances.hs27
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
4module Crypto.JOSE.JWK.Instances () where
5
6import Control.Lens.TH
7import Crypto.JOSE.JWK
8
9makeWrapped ''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
3module Crypto.Random.Instances () where
4
5import Prelude
6import Crypto.Random
7import System.Random
8
9import qualified Data.ByteString as BS
10
11import Data.Bits
12
13
14instance 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"