diff options
-rw-r--r-- | HACKING | 11 | ||||
-rw-r--r-- | KeyRing.hs | 16 |
2 files changed, 25 insertions, 2 deletions
@@ -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 | |||
30 | Note about current dependency status: | ||
31 | |||
32 | Because cryptohash is already packaged for Wheezy and I want to avoid depending | ||
33 | a newer version of the library, I've backported the following to work with | ||
34 | cryptohash-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 | |||
@@ -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 | ||
83 | import System.Environment | 86 | import System.Environment |
@@ -101,7 +104,7 @@ import Text.Show.Pretty as PP ( ppShow ) | |||
101 | import Data.Binary {- decode, decodeOrFail -} | 104 | import Data.Binary {- decode, decodeOrFail -} |
102 | import ControlMaybe ( handleIO_ ) | 105 | import ControlMaybe ( handleIO_ ) |
103 | import Data.ASN1.Types ( toASN1, ASN1Object, fromASN1 | 106 | import 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) ) |
105 | import Data.ASN1.BitArray ( BitArray(..), toBitArray ) | 108 | import Data.ASN1.BitArray ( BitArray(..), toBitArray ) |
106 | import Data.ASN1.Encoding ( encodeASN1, encodeASN1', decodeASN1, decodeASN1' ) | 109 | import Data.ASN1.Encoding ( encodeASN1, encodeASN1', decodeASN1, decodeASN1' ) |
107 | import Data.ASN1.BinaryEncoding ( DER(..) ) | 110 | import 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 | ||
432 | instance ASN1Object PKCS8_RSAPublicKey where | 438 | instance 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 |