Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Add deriving of Ord instances for private and public RSA and DSA keys types #3

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Crypto/Types/PubKey/DSA.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type Signature = (Integer,Integer)
data PublicKey = PublicKey
{ public_params :: Params -- ^ DSA parameters
, public_y :: Integer -- ^ DSA public Y
} deriving (Show,Read,Eq,Data,Typeable)
} deriving (Show,Read,Eq,Ord,Data,Typeable)

-- | Represent a DSA private key.
--
Expand All @@ -34,4 +34,4 @@ data PublicKey = PublicKey
data PrivateKey = PrivateKey
{ private_params :: Params -- ^ DSA parameters
, private_x :: Integer -- ^ DSA private X
} deriving (Show,Read,Eq,Data,Typeable)
} deriving (Show,Read,Eq,Ord,Data,Typeable)
6 changes: 3 additions & 3 deletions Crypto/Types/PubKey/RSA.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ 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,Data,Typeable)
} deriving (Show,Read,Eq,Ord,Data,Typeable)

-- | Represent a RSA private key.
--
--
-- Only the pub, d fields are mandatory to fill.
--
-- p, q, dP, dQ, qinv are by-product during RSA generation,
Expand All @@ -40,7 +40,7 @@ data PrivateKey = PrivateKey
, 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,Data,Typeable)
} deriving (Show,Read,Eq,Ord,Data,Typeable)

private_size = public_size . private_pub
private_n = public_n . private_pub
Expand Down