crypton-0.34: Cryptography Primitives sink

License | BSD-style
Maintainer | Vincent Hanquez <vincent@snarc.org>
Stability | Experimental
Portability | Excellent
Safe Haskell | Safe-Inferred
Language | Haskell2010

Crypto.PubKey.ECC.Types

Contents

- Recommended curves definition

Description

Synopsis

- data Curve
  - = CurveF2m CurveBinary
  - | CurveFP CurvePrime
- data Point
  - = Point Integer Integer
  - | PointO
- type PublicPoint = Point
- type PrivateNumber = Integer
- data CurveBinary = CurveBinary Integer CurveCommon
- data CurvePrime = CurvePrime Integer CurveCommon
- common_curve :: Curve -> CurveCommon
- curveSizeBits :: Curve -> Int
- ecc_fx :: CurveBinary -> Integer
- ecc_p :: CurvePrime -> Integer
- data CurveCommon = CurveCommon {
  - ecc_a :: Integer
  - ecc_b :: Integer
  - ecc_g :: Point
  - ecc_n :: Integer
  - ecc_h :: Integer
  }
- data CurveName
  - = SEC_p112r1
  - | SEC_p112r2
  - | SEC_p128r1
  - | SEC_p128r2
  - | SEC_p160k1
  - | SEC_p160r1
  - | SEC_p160r2
  - | SEC_p192k1
  - | SEC_p192r1
  - | SEC_p224k1
  - | SEC_p224r1
  - | SEC_p256k1
  - | SEC_p256r1
  - | SEC_p384r1
  - | SEC_p521r1
  - | SEC_t113r1
  - | SEC_t113r2
  - | SEC_t131r1
  - | SEC_t131r2
  - | SEC_t163k1
  - | SEC_t163r1
  - | SEC_t163r2
  - | SEC_t193r1
  - | SEC_t193r2
  - | SEC_t233k1
  - | SEC_t233r1
  - | SEC_t239k1
  - | SEC_t283k1
  - | SEC_t283r1
  - | SEC_t409k1
  - | SEC_t409r1
  - | SEC_t571k1
  - | SEC_t571r1
- getCurveByName :: CurveName -> Curve

# Documentation

data Curve Source #

Define either a binary curve or a prime curve.

Constructors

CurveF2m CurveBinary | 𝔽(2^m)
CurveFP CurvePrime | 𝔽p

#### Instances

Instances details

Data Curve Source # |

Instance details

Defined in Crypto.PubKey.ECC.Types

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Curve -> c Curve Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Curve Source #

toConstr :: Curve -> Constr Source #

dataTypeOf :: Curve -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Curve) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Curve) Source #

gmapT :: (forall b. Data b => b -> b) -> Curve -> Curve Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Curve -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Curve -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Curve -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Curve -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Curve -> m Curve Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Curve -> m Curve Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Curve -> m Curve Source #

Read Curve Source # |
Instance details Defined in Crypto.PubKey.ECC.Types Methods readsPrec :: Int -> ReadS Curve Source # readList :: ReadS [Curve] Source # readPrec :: ReadPrec Curve Source # readListPrec :: ReadPrec [Curve] Source #
Show Curve Source # |
Instance details Defined in Crypto.PubKey.ECC.Types Methods showsPrec :: Int -> Curve -> ShowS Source # show :: Curve -> String Source # showList :: [Curve] -> ShowS Source #
Eq Curve Source # |
Instance details Defined in Crypto.PubKey.ECC.Types Methods (==) :: Curve -> Curve -> Bool Source # (/=) :: Curve -> Curve -> Bool Source #

data Point Source #

Define a point on a curve.

Constructors

Point Integer Integer |
PointO | Point at Infinity

#### Instances

Instances details

Data Point Source # |

Instance details

Defined in Crypto.PubKey.ECC.Types

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Point -> c Point Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Point Source #

toConstr :: Point -> Constr Source #

dataTypeOf :: Point -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Point) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Point) Source #

gmapT :: (forall b. Data b => b -> b) -> Point -> Point Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Point -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Point -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Point -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Point -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Point -> m Point Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Point -> m Point Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Point -> m Point Source #

Read Point Source # |
Instance details Defined in Crypto.PubKey.ECC.Types Methods readsPrec :: Int -> ReadS Point Source # readList :: ReadS [Point] Source # readPrec :: ReadPrec Point Source # readListPrec :: ReadPrec [Point] Source #
Show Point Source # |
Instance details Defined in Crypto.PubKey.ECC.Types Methods showsPrec :: Int -> Point -> ShowS Source # show :: Point -> String Source # showList :: [Point] -> ShowS Source #
NFData Point Source # |
Instance details Defined in Crypto.PubKey.ECC.Types Methods rnf :: Point -> () Source #
Eq Point Source # |
Instance details Defined in Crypto.PubKey.ECC.Types Methods (==) :: Point -> Point -> Bool Source # (/=) :: Point -> Point -> Bool Source #

type PublicPoint = Point Source #

ECC Public Point

type PrivateNumber = Integer Source #

ECC Private Number

data CurveBinary Source #

Define an elliptic curve in 𝔽(2^m). The firt parameter is the Integer representatioin of the irreducible polynomial f(x).

Constructors

CurveBinary Integer CurveCommon |

#### Instances

Instances details

Data CurveBinary Source # |

Instance details

Defined in Crypto.PubKey.ECC.Types

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> CurveBinary -> c CurveBinary Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c CurveBinary Source #

toConstr :: CurveBinary -> Constr Source #

dataTypeOf :: CurveBinary -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c CurveBinary) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CurveBinary) Source #

gmapT :: (forall b. Data b => b -> b) -> CurveBinary -> CurveBinary Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CurveBinary -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CurveBinary -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> CurveBinary -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> CurveBinary -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> CurveBinary -> m CurveBinary Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> CurveBinary -> m CurveBinary Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> CurveBinary -> m CurveBinary Source #

Read CurveBinary Source # |
Instance details Defined in Crypto.PubKey.ECC.Types Methods readsPrec :: Int -> ReadS CurveBinary Source # readList :: ReadS [CurveBinary] Source # readPrec :: ReadPrec CurveBinary Source # readListPrec :: ReadPrec [CurveBinary] Source #
Show CurveBinary Source # |
Instance details Defined in Crypto.PubKey.ECC.Types Methods showsPrec :: Int -> CurveBinary -> ShowS Source # show :: CurveBinary -> String Source # showList :: [CurveBinary] -> ShowS Source #
NFData CurveBinary Source # |
Instance details Defined in Crypto.PubKey.ECC.Types Methods rnf :: CurveBinary -> () Source #
Eq CurveBinary Source # |
Instance details Defined in Crypto.PubKey.ECC.Types Methods (==) :: CurveBinary -> CurveBinary -> Bool Source # (/=) :: CurveBinary -> CurveBinary -> Bool Source #

data CurvePrime Source #

Define an elliptic curve in 𝔽p. The first parameter is the Prime Number.

Constructors

CurvePrime Integer CurveCommon |

#### Instances

Instances details

Data CurvePrime Source # |

Instance details

Defined in Crypto.PubKey.ECC.Types

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> CurvePrime -> c CurvePrime Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c CurvePrime Source #

toConstr :: CurvePrime -> Constr Source #

dataTypeOf :: CurvePrime -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c CurvePrime) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CurvePrime) Source #

gmapT :: (forall b. Data b => b -> b) -> CurvePrime -> CurvePrime Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CurvePrime -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CurvePrime -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> CurvePrime -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> CurvePrime -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> CurvePrime -> m CurvePrime Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> CurvePrime -> m CurvePrime Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> CurvePrime -> m CurvePrime Source #

Read CurvePrime Source # |
Instance details Defined in Crypto.PubKey.ECC.Types Methods readsPrec :: Int -> ReadS CurvePrime Source # readList :: ReadS [CurvePrime] Source # readPrec :: ReadPrec CurvePrime Source # readListPrec :: ReadPrec [CurvePrime] Source #
Show CurvePrime Source # |
Instance details Defined in Crypto.PubKey.ECC.Types Methods showsPrec :: Int -> CurvePrime -> ShowS Source # show :: CurvePrime -> String Source # showList :: [CurvePrime] -> ShowS Source #
Eq CurvePrime Source # |
Instance details Defined in Crypto.PubKey.ECC.Types Methods (==) :: CurvePrime -> CurvePrime -> Bool Source # (/=) :: CurvePrime -> CurvePrime -> Bool Source #

common_curve :: Curve -> CurveCommon Source #

Parameters in common between binary and prime curves.

curveSizeBits :: Curve -> Int Source #

get the size of the curve in bits

ecc_fx :: CurveBinary -> Integer Source #

Irreducible polynomial representing the characteristic of a CurveBinary.

ecc_p :: CurvePrime -> Integer Source #

Prime number representing the characteristic of a CurvePrime.

data CurveCommon Source #

Define common parameters in a curve definition of the form: y^2 = x^3 + ax + b.

Constructors

CurveCommon |

Fields

- ecc_a :: Integer

  curve parameter a

- ecc_b :: Integer

  curve parameter b

- ecc_g :: Point

  base point

- ecc_n :: Integer

  order of G

- ecc_h :: Integer

  cofactor

#### Instances

Instances details

Data CurveCommon Source # |

Instance details

Defined in Crypto.PubKey.ECC.Types

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> CurveCommon -> c CurveCommon Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c CurveCommon Source #

toConstr :: CurveCommon -> Constr Source #

dataTypeOf :: CurveCommon -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c CurveCommon) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CurveCommon) Source #

gmapT :: (forall b. Data b => b -> b) -> CurveCommon -> CurveCommon Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CurveCommon -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CurveCommon -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> CurveCommon -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> CurveCommon -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> CurveCommon -> m CurveCommon Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> CurveCommon -> m CurveCommon Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> CurveCommon -> m CurveCommon Source #

Read CurveCommon Source # |
Instance details Defined in Crypto.PubKey.ECC.Types Methods readsPrec :: Int -> ReadS CurveCommon Source # readList :: ReadS [CurveCommon] Source # readPrec :: ReadPrec CurveCommon Source # readListPrec :: ReadPrec [CurveCommon] Source #
Show CurveCommon Source # |
Instance details Defined in Crypto.PubKey.ECC.Types Methods showsPrec :: Int -> CurveCommon -> ShowS Source # show :: CurveCommon -> String Source # showList :: [CurveCommon] -> ShowS Source #
Eq CurveCommon Source # |
Instance details Defined in Crypto.PubKey.ECC.Types Methods (==) :: CurveCommon -> CurveCommon -> Bool Source # (/=) :: CurveCommon -> CurveCommon -> Bool Source #

# Recommended curves definition

data CurveName Source #

Define names for known recommended curves.

Constructors

SEC_p112r1 |
SEC_p112r2 |
SEC_p128r1 |
SEC_p128r2 |
SEC_p160k1 |
SEC_p160r1 |
SEC_p160r2 |
SEC_p192k1 |
SEC_p192r1 |
SEC_p224k1 |
SEC_p224r1 |
SEC_p256k1 |
SEC_p256r1 |
SEC_p384r1 |
SEC_p521r1 |
SEC_t113r1 |
SEC_t113r2 |
SEC_t131r1 |
SEC_t131r2 |
SEC_t163k1 |
SEC_t163r1 |
SEC_t163r2 |
SEC_t193r1 |
SEC_t193r2 |
SEC_t233k1 |
SEC_t233r1 |
SEC_t239k1 |
SEC_t283k1 |
SEC_t283r1 |
SEC_t409k1 |
SEC_t409r1 |
SEC_t571k1 |
SEC_t571r1 |

#### Instances

Instances details

Data CurveName Source # |

Instance details

Defined in Crypto.PubKey.ECC.Types

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> CurveName -> c CurveName Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c CurveName Source #

toConstr :: CurveName -> Constr Source #

dataTypeOf :: CurveName -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c CurveName) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CurveName) Source #

gmapT :: (forall b. Data b => b -> b) -> CurveName -> CurveName Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CurveName -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CurveName -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> CurveName -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> CurveName -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> CurveName -> m CurveName Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> CurveName -> m CurveName Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> CurveName -> m CurveName Source #

Bounded CurveName Source # |
Instance details Defined in Crypto.PubKey.ECC.Types Methods minBound :: CurveName Source # maxBound :: CurveName Source #
Enum CurveName Source # |

Instance details

Defined in Crypto.PubKey.ECC.Types

Methods

succ :: CurveName -> CurveName Source #

pred :: CurveName -> CurveName Source #

toEnum :: Int -> CurveName Source #

fromEnum :: CurveName -> Int Source #

enumFrom :: CurveName -> [CurveName] Source #

enumFromThen :: CurveName -> CurveName -> [CurveName] Source #

enumFromTo :: CurveName -> CurveName -> [CurveName] Source #

enumFromThenTo :: CurveName -> CurveName -> CurveName -> [CurveName] Source #

Read CurveName Source # |
Instance details Defined in Crypto.PubKey.ECC.Types Methods readsPrec :: Int -> ReadS CurveName Source # readList :: ReadS [CurveName] Source # readPrec :: ReadPrec CurveName Source # readListPrec :: ReadPrec [CurveName] Source #
Show CurveName Source # |
Instance details Defined in Crypto.PubKey.ECC.Types Methods showsPrec :: Int -> CurveName -> ShowS Source # show :: CurveName -> String Source # showList :: [CurveName] -> ShowS Source #
Eq CurveName Source # |
Instance details Defined in Crypto.PubKey.ECC.Types Methods (==) :: CurveName -> CurveName -> Bool Source # (/=) :: CurveName -> CurveName -> Bool Source #
Ord CurveName Source # |

Instance details

Defined in Crypto.PubKey.ECC.Types

Methods

compare :: CurveName -> CurveName -> Ordering Source #

(<) :: CurveName -> CurveName -> Bool Source #

(<=) :: CurveName -> CurveName -> Bool Source #

(>) :: CurveName -> CurveName -> Bool Source #

(>=) :: CurveName -> CurveName -> Bool Source #

max :: CurveName -> CurveName -> CurveName Source #

min :: CurveName -> CurveName -> CurveName Source #

getCurveByName :: CurveName -> Curve Source #

Get the curve definition associated with a recommended known curve name.