cryptonite-openssl-0.6: Crypto stuff using OpenSSL cryptographic library

LicenseBSD-style
Stabilityexperimental
PortabilityUnix
Safe HaskellNone
LanguageHaskell2010

Crypto.OpenSSL.ECC

Contents

Description

 

Synopsis

Documentation

data EcPoint #

An elliptic curve point

data EcGroup #

An ellitic curve group

data EcKey #

An elliptic curve key

Curve group

ecGroupFromCurveOID :: String -> Maybe EcGroup #

try to get a curve group from an ASN1 description string (OID)

e.g.

  • "1.3.132.0.35" == SEC_P521_R1
  • "1.2.840.10045.3.1.7" == SEC_P256_R1

ecGroupGFp #

Arguments

:: Integer

p

-> Integer

a

-> Integer

b

-> (Integer, Integer)

generator

-> Integer

order

-> Integer

cofactor

-> EcGroup 

Create a new GFp group with explicit (p,a,b,(x,y),order,h)

Generally, this interface should not be used, and user should really not stray away from already defined curves.

Use at your own risks.

ecGroupGF2m #

Arguments

:: Integer

p

-> Integer

a

-> Integer

b

-> (Integer, Integer)

generator

-> Integer

order

-> Integer

cofactor

-> EcGroup 

Create a new GF2m group with explicit (p,a,b,(x,y),order,h)

same warning as ecGroupGFp

ecGroupGetDegree :: EcGroup -> Int #

get the group degree (number of bytes)

ecGroupGetOrder :: EcGroup -> Integer #

get the order of the subgroup generated by the generator

ecGroupGetGenerator :: EcGroup -> EcPoint #

Get the group generator

ecGroupGetCurveGFp :: EcGroup -> (Integer, Integer, Integer) #

get curve's (prime,a,b)

ecGroupGetCurveGF2m :: EcGroup -> (Integer, Integer, Integer) #

get curve's (polynomial,a,b)

EcPoint arithmetic

ecPointAdd :: EcGroup -> EcPoint -> EcPoint -> EcPoint #

add 2 points together, r = p1 + p2

ecPointsSum :: EcGroup -> [EcPoint] -> EcPoint #

Add many points together

ecPointDbl :: EcGroup -> EcPoint -> EcPoint #

compute the doubling of the point p, r = p^2

ecPointMul #

Arguments

:: EcGroup 
-> EcPoint

q

-> Integer

m

-> EcPoint 

compute q * m

ecPointMulWithGenerator #

Arguments

:: EcGroup 
-> Integer

n

-> EcPoint

q

-> Integer

m

-> EcPoint 

compute generator * n + q * m

ecPointsMulAndSum :: EcGroup -> [(EcPoint, Integer)] -> EcPoint #

compute sum ((q,m) -> q * m) l

ecPointsMulOfPowerAndSum :: EcGroup -> [EcPoint] -> Integer -> EcPoint #

Compute the sum of the point to the nth power

f [p1,p2,..,pi] n = p1 * (n ^ 0) + p2 * (n ^ 1) + .. + pi * (n ^ i-1)

ecPointGeneratorMul :: EcGroup -> Integer -> EcPoint #

compute generator * n

ecPointInvert :: EcGroup -> EcPoint -> EcPoint #

compute the inverse on the curve on the point p, r = p^(-1)

ecPointIsAtInfinity :: EcGroup -> EcPoint -> Bool #

get if the point is at infinity

ecPointIsOnCurve :: EcGroup -> EcPoint -> Bool #

get if the point is on the curve

ecPointEq :: EcGroup -> EcPoint -> EcPoint -> Bool #

return if a point eq another point

EcPoint serialization

ecPointToOct :: ByteArray outBytes => EcGroup -> EcPoint -> PointConversionForm -> outBytes #

Create a binary represention of a point using the specific format

ecPointFromOct :: ByteArrayAccess inBytes => EcGroup -> inBytes -> Either String EcPoint #

Try to parse a binary representation to a point

ecPointFromAffineGFp :: EcGroup -> (Integer, Integer) -> EcPoint #

Convert a (x,y) to a point representation on a prime curve.

ecPointToAffineGFp :: EcGroup -> EcPoint -> (Integer, Integer) #

Convert a point of a prime curve to affine representation (x,y)

Key

ecKeyGenerateNew :: EcGroup -> IO EcKey #

generate a new key in a specific group

ecKeyFromPair :: EcGroup -> (Integer, EcPoint) -> EcKey #

create a key from a group and a private integer and public point keypair

ecKeyToPair :: EcKey -> (Integer, EcPoint) #

return the private integer and public point of a key