fradrive/backend/test/Jose/Jwk/TestInstances.hs
Sarah Vaupel 72f5a9fb37 build: move backend-related files into backend dir; implement and connect services via docker-compose
TODOs left: reimplement clean and help, sync static,well-known and assets between services
2025-03-23 04:52:49 +01:00

39 lines
977 B
Haskell

-- SPDX-FileCopyrightText: 2022 Sarah Vaupel <sarah.vaupel@ifi.lmu.de>
--
-- SPDX-License-Identifier: AGPL-3.0-or-later
module Jose.Jwk.TestInstances
() where
import TestImport
import Crypto.Random
import Jose.Jwk
import Jose.Jwt
instance Arbitrary KeyUse where
arbitrary = genericArbitrary
instance Arbitrary JwkSet where
arbitrary = fmap (JwkSet . concat) . listOf $ do
kId <- UTCKeyId <$> arbitrary
kUse <- arbitrary
oneof
[ withDRG' $ do
(kPub, kPriv) <- generateRsaKeyPair 2048 kId kUse Nothing
return [kPub, kPriv]
, withDRG' $
pure <$> generateSymmetricKey 32 kId kUse Nothing
]
where
withDRG' c = do
seed <- (,,,,)
<$> arbitraryBoundedRandom
<*> arbitraryBoundedRandom
<*> arbitraryBoundedRandom
<*> arbitraryBoundedRandom
<*> arbitraryBoundedRandom
let chacha = drgNewTest seed
return . fst $ withDRG chacha c