summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--HACKING11
-rw-r--r--KeyRing.hs16
2 files changed, 25 insertions, 2 deletions
diff --git a/HACKING b/HACKING
index b61c9f5..37c366c 100644
--- a/HACKING
+++ b/HACKING
@@ -25,3 +25,14 @@ contributers to the kiki project.
25 25
26* This approach keeps the code base fresh without limiting it's ease of install 26* This approach keeps the code base fresh without limiting it's ease of install
27 and utility on existing systems. 27 and utility on existing systems.
28
29
30Note about current dependency status:
31
32Because cryptohash is already packaged for Wheezy and I want to avoid depending
33a newer version of the library, I've backported the following to work with
34cryptohash-0.7.5:
35
36 crypto-pubkey-0.2.4 (needed to add conditional compilation)
37 x509-v1.4.5 (changed only the constraint in the cabal file)
38
diff --git a/KeyRing.hs b/KeyRing.hs
index c7ea5fb..b359dab 100644
--- a/KeyRing.hs
+++ b/KeyRing.hs
@@ -67,6 +67,7 @@ module KeyRing
67 , UserIDRecord(..) 67 , UserIDRecord(..)
68 , pkcs8 68 , pkcs8
69 , RSAPublicKey(..) 69 , RSAPublicKey(..)
70 , PKCS8_RSAPublicKey(..)
70 , rsaKeyFromPacket 71 , rsaKeyFromPacket
71 , secretToPublic 72 , secretToPublic
72 , selectPublicKey 73 , selectPublicKey
@@ -78,6 +79,8 @@ module KeyRing
78 , getBindings 79 , getBindings
79 , accBindings 80 , accBindings
80 , isSubkeySignature 81 , isSubkeySignature
82 , extractPEM
83 , torhash
81 ) where 84 ) where
82 85
83import System.Environment 86import System.Environment
@@ -101,7 +104,7 @@ import Text.Show.Pretty as PP ( ppShow )
101import Data.Binary {- decode, decodeOrFail -} 104import Data.Binary {- decode, decodeOrFail -}
102import ControlMaybe ( handleIO_ ) 105import ControlMaybe ( handleIO_ )
103import Data.ASN1.Types ( toASN1, ASN1Object, fromASN1 106import Data.ASN1.Types ( toASN1, ASN1Object, fromASN1
104 , ASN1(Start,End,IntVal,OID,BitString), ASN1ConstructionType(Sequence) ) 107 , ASN1(Start,End,IntVal,OID,BitString,Null), ASN1ConstructionType(Sequence) )
105import Data.ASN1.BitArray ( BitArray(..), toBitArray ) 108import Data.ASN1.BitArray ( BitArray(..), toBitArray )
106import Data.ASN1.Encoding ( encodeASN1, encodeASN1', decodeASN1, decodeASN1' ) 109import Data.ASN1.Encoding ( encodeASN1, encodeASN1', decodeASN1, decodeASN1' )
107import Data.ASN1.BinaryEncoding ( DER(..) ) 110import Data.ASN1.BinaryEncoding ( DER(..) )
@@ -426,7 +429,10 @@ instance ASN1Object RSAPublicKey where
426 : IntVal e 429 : IntVal e
427 : End Sequence 430 : End Sequence
428 : xs 431 : xs
429 fromASN1 _ = 432 fromASN1 (Start Sequence:IntVal n:IntVal e:End Sequence:xs) =
433 Right (RSAKey (MPI n) (MPI e), xs)
434
435 fromASN1 _ =
430 Left "fromASN1: RSAPublicKey: unexpected format" 436 Left "fromASN1: RSAPublicKey: unexpected format"
431 437
432instance ASN1Object PKCS8_RSAPublicKey where 438instance ASN1Object PKCS8_RSAPublicKey where
@@ -446,6 +452,12 @@ instance ASN1Object PKCS8_RSAPublicKey where
446 452
447 fromASN1 (Start Sequence:IntVal modulus:IntVal pubexp:End Sequence:xs) = 453 fromASN1 (Start Sequence:IntVal modulus:IntVal pubexp:End Sequence:xs) =
448 Right (RSAKey8 (MPI modulus) (MPI pubexp) , xs) 454 Right (RSAKey8 (MPI modulus) (MPI pubexp) , xs)
455 fromASN1 (Start Sequence:Start Sequence:OID [1,2,840,113549,1,1,1]:Null:End Sequence:BitString b:End Sequence:xs) =
456 case decodeASN1' DER bs of
457 Right as -> fromASN1 as
458 Left e -> Left ("fromASN1: RSAPublicKey: "++show e)
459 where
460 BitArray _ bs = b
449 fromASN1 (Start Sequence:Start Sequence:OID [1,2,840,113549,1,1,1]:End Sequence:BitString b:End Sequence:xs) = 461 fromASN1 (Start Sequence:Start Sequence:OID [1,2,840,113549,1,1,1]:End Sequence:BitString b:End Sequence:xs) =
450 case decodeASN1' DER bs of 462 case decodeASN1' DER bs of
451 Right as -> fromASN1 as 463 Right as -> fromASN1 as