module Data.X509.OID
( OIDTable
, lookupByOID
, lookupOID
, curvesOIDTable
) where
import Control.Applicative
import Crypto.PubKey.ECC.Types
import Data.ASN1.OID
import Data.List (find)
type OIDTable a = [(a,OID)]
lookupByOID :: OIDTable a -> OID -> Maybe a
lookupByOID :: forall a. OIDTable a -> OID -> Maybe a
lookupByOID OIDTable a
table OID
oid = (a, OID) -> a
forall a b. (a, b) -> a
fst ((a, OID) -> a) -> Maybe (a, OID) -> Maybe a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((a, OID) -> Bool) -> OIDTable a -> Maybe (a, OID)
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Maybe a
find (OID -> OID -> Bool
forall a. Eq a => a -> a -> Bool
(==) OID
oid (OID -> Bool) -> ((a, OID) -> OID) -> (a, OID) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a, OID) -> OID
forall a b. (a, b) -> b
snd) OIDTable a
table
lookupOID :: Eq a => OIDTable a -> a -> Maybe OID
lookupOID :: forall a. Eq a => OIDTable a -> a -> Maybe OID
lookupOID OIDTable a
table a
a = a -> OIDTable a -> Maybe OID
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup a
a OIDTable a
table
curvesOIDTable :: OIDTable CurveName
curvesOIDTable :: OIDTable CurveName
curvesOIDTable =
[ (CurveName
SEC_p112r1, [Integer
1,Integer
3,Integer
132,Integer
0,Integer
6])
, (CurveName
SEC_p112r2, [Integer
1,Integer
3,Integer
132,Integer
0,Integer
7])
, (CurveName
SEC_p128r1, [Integer
1,Integer
3,Integer
132,Integer
0,Integer
28])
, (CurveName
SEC_p128r2, [Integer
1,Integer
3,Integer
132,Integer
0,Integer
29])
, (CurveName
SEC_p160k1, [Integer
1,Integer
3,Integer
132,Integer
0,Integer
9])
, (CurveName
SEC_p160r1, [Integer
1,Integer
3,Integer
132,Integer
0,Integer
8])
, (CurveName
SEC_p160r2, [Integer
1,Integer
3,Integer
132,Integer
0,Integer
30])
, (CurveName
SEC_p192k1, [Integer
1,Integer
3,Integer
132,Integer
0,Integer
31])
, (CurveName
SEC_p192r1, [Integer
1,Integer
2,Integer
840,Integer
10045,Integer
3,Integer
1,Integer
1])
, (CurveName
SEC_p224k1, [Integer
1,Integer
3,Integer
132,Integer
0,Integer
32])
, (CurveName
SEC_p224r1, [Integer
1,Integer
3,Integer
132,Integer
0,Integer
33])
, (CurveName
SEC_p256k1, [Integer
1,Integer
3,Integer
132,Integer
0,Integer
10])
, (CurveName
SEC_p256r1, [Integer
1,Integer
2,Integer
840,Integer
10045,Integer
3,Integer
1,Integer
7])
, (CurveName
SEC_p384r1, [Integer
1,Integer
3,Integer
132,Integer
0,Integer
34])
, (CurveName
SEC_p521r1, [Integer
1,Integer
3,Integer
132,Integer
0,Integer
35])
, (CurveName
SEC_t113r1, [Integer
1,Integer
3,Integer
132,Integer
0,Integer
4])
, (CurveName
SEC_t113r2, [Integer
1,Integer
3,Integer
132,Integer
0,Integer
5])
, (CurveName
SEC_t131r1, [Integer
1,Integer
3,Integer
132,Integer
0,Integer
22])
, (CurveName
SEC_t131r2, [Integer
1,Integer
3,Integer
132,Integer
0,Integer
23])
, (CurveName
SEC_t163k1, [Integer
1,Integer
3,Integer
132,Integer
0,Integer
1])
, (CurveName
SEC_t163r1, [Integer
1,Integer
3,Integer
132,Integer
0,Integer
2])
, (CurveName
SEC_t163r2, [Integer
1,Integer
3,Integer
132,Integer
0,Integer
15])
, (CurveName
SEC_t193r1, [Integer
1,Integer
3,Integer
132,Integer
0,Integer
24])
, (CurveName
SEC_t193r2, [Integer
1,Integer
3,Integer
132,Integer
0,Integer
25])
, (CurveName
SEC_t233k1, [Integer
1,Integer
3,Integer
132,Integer
0,Integer
26])
, (CurveName
SEC_t233r1, [Integer
1,Integer
3,Integer
132,Integer
0,Integer
27])
, (CurveName
SEC_t239k1, [Integer
1,Integer
3,Integer
132,Integer
0,Integer
3])
, (CurveName
SEC_t283k1, [Integer
1,Integer
3,Integer
132,Integer
0,Integer
16])
, (CurveName
SEC_t283r1, [Integer
1,Integer
3,Integer
132,Integer
0,Integer
17])
, (CurveName
SEC_t409k1, [Integer
1,Integer
3,Integer
132,Integer
0,Integer
36])
, (CurveName
SEC_t409r1, [Integer
1,Integer
3,Integer
132,Integer
0,Integer
37])
, (CurveName
SEC_t571k1, [Integer
1,Integer
3,Integer
132,Integer
0,Integer
38])
, (CurveName
SEC_t571r1, [Integer
1,Integer
3,Integer
132,Integer
0,Integer
39])
]