crypto-pubkey-types (empty) → 0.1.0
raw patch · 6 files changed
+155/−0 lines, 6 filesdep +basedep +crypto-apisetup-changed
Dependencies added: base, crypto-api
Files
- Crypto/Types/PubKey/DH.hs +29/−0
- Crypto/Types/PubKey/DSA.hs +34/−0
- Crypto/Types/PubKey/RSA.hs +39/−0
- LICENSE +27/−0
- Setup.hs +2/−0
- crypto-pubkey-types.cabal +24/−0
+ Crypto/Types/PubKey/DH.hs view
@@ -0,0 +1,29 @@+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+-- |+-- Module : Crypto.Types.PubKey.DH+-- License : BSD-style+-- Maintainer : Vincent Hanquez <vincent@snarc.org>+-- Stability : Stable+-- Portability : Excellent+--+module Crypto.Types.PubKey.DH+ ( Params+ , PublicNumber(..)+ , PrivateNumber(..)+ , SharedKey(..)+ ) where++-- | Represent Diffie Hellman parameters namely P (prime), and G (generator).+type Params = (Integer,Integer)++-- | Represent Diffie Hellman public number Y.+newtype PublicNumber = PublicNumber Integer+ deriving (Show,Read,Eq,Enum,Real,Num,Ord)++-- | Represent Diffie Hellman private number X.+newtype PrivateNumber = PrivateNumber Integer+ deriving (Show,Read,Eq,Enum,Real,Num,Ord)++-- | Represent Diffie Hellman shared secret.+newtype SharedKey = SharedKey Integer+ deriving (Show,Read,Eq,Enum,Real,Num,Ord)
+ Crypto/Types/PubKey/DSA.hs view
@@ -0,0 +1,34 @@+-- |+-- Module : Crypto.Types.PubKey.DSA+-- License : BSD-style+-- Maintainer : Vincent Hanquez <vincent@snarc.org>+-- Stability : Stable+-- Portability : Excellent+--+module Crypto.Types.PubKey.DSA+ ( Params+ , Signature+ , PublicKey(..)+ , PrivateKey(..)+ ) where++-- | Represent DSA parameters namely P, G, and Q.+type Params = (Integer,Integer,Integer)++-- | Represent a DSA signature namely R and S.+type Signature = (Integer,Integer)++-- | Represent a DSA public key.+data PublicKey = PublicKey+ { public_params :: Params -- ^ DSA parameters+ , public_y :: Integer -- ^ DSA public Y+ } deriving (Show,Read,Eq)++-- | Represent a DSA private key.+--+-- Only x need to be secret.+-- the DSA parameters are publicly shared with the other side.+data PrivateKey = PrivateKey+ { private_params :: Params -- ^ DSA parameters+ , private_x :: Integer -- ^ DSA private X+ } deriving (Show,Read,Eq)
+ Crypto/Types/PubKey/RSA.hs view
@@ -0,0 +1,39 @@+-- |+-- Module : Crypto.Types.PubKey.RSA+-- License : BSD-style+-- Maintainer : Vincent Hanquez <vincent@snarc.org>+-- Stability : Stable+-- Portability : Excellent+--+module Crypto.Types.PubKey.RSA+ ( PublicKey(..)+ , PrivateKey(..)+ ) where++-- | Represent a RSA public key+data PublicKey = PublicKey+ { public_size :: Int -- ^ size of key in bytes+ , public_n :: Integer -- ^ public p*q+ , public_e :: Integer -- ^ public exponant e+ } deriving (Show,Read,Eq)++-- | Represent a RSA private key.+-- +-- Only the sz, n and d fields are mandatory to fill.+--+-- p, q, dP, dQ, qinv are by-product during RSA generation,+-- but are useful to record here to speed up massively+-- the decrypt and sign operation.+--+-- implementations can leave optional fields to 0.+--+data PrivateKey = PrivateKey+ { private_size :: Int -- ^ size of key in bytes+ , private_n :: Integer -- ^ private p*q+ , private_d :: Integer -- ^ private exponant d+ , private_p :: Integer -- ^ p prime number+ , private_q :: Integer -- ^ q prime number+ , private_dP :: Integer -- ^ d mod (p-1)+ , private_dQ :: Integer -- ^ d mod (q-1)+ , private_qinv :: Integer -- ^ q^(-1) mod p+ } deriving (Show,Read,Eq)
+ LICENSE view
@@ -0,0 +1,27 @@+Copyright (c) 2010-2011 Vincent Hanquez <vincent@snarc.org>++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions+are met:+1. Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.+2. Redistributions in binary form must reproduce the above copyright+ notice, this list of conditions and the following disclaimer in the+ documentation and/or other materials provided with the distribution.+3. Neither the name of the author nor the names of his contributors+ may be used to endorse or promote products derived from this software+ without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE+ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF+SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ crypto-pubkey-types.cabal view
@@ -0,0 +1,24 @@+Name: crypto-pubkey-types+Version: 0.1.0+Description: Generic cryptography public keys algorithm types+License: BSD3+License-file: LICENSE+Copyright: Vincent Hanquez <vincent@snarc.org>+Author: Vincent Hanquez <vincent@snarc.org>+Maintainer: Vincent Hanquez <vincent@snarc.org>+Synopsis: Generic cryptography Public keys algorithm types+Category: Cryptography+Build-Type: Simple+Homepage: http://github.com/vincenthz/hs-crypto-pubkey-types+Cabal-Version: >=1.6++Library+ Exposed-modules: Crypto.Types.PubKey.RSA+ Crypto.Types.PubKey.DSA+ Crypto.Types.PubKey.DH+ Build-depends: base >= 4 && < 5,+ crypto-api >= 0.5++source-repository head+ type: git+ location: git://github.com/vincenthz/hs-crypto-pubkey-types