diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2019-11-09 21:24:57 +0100 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2019-11-09 21:24:57 +0100 |
commit | 2169f1030cded87e6ab38b4ae8293e7f147b5e96 (patch) | |
tree | b5de80318e48c2a59f657d17567e1f6085ae8714 /src/PubKey.hs | |
parent | 4521fc3c4a898f046b030985159c63c5379df46f (diff) |
Attach device service
Diffstat (limited to 'src/PubKey.hs')
-rw-r--r-- | src/PubKey.hs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/PubKey.hs b/src/PubKey.hs index d7134c8..8f39bf1 100644 --- a/src/PubKey.hs +++ b/src/PubKey.hs @@ -48,7 +48,11 @@ signedSignature = signedSignature_ instance KeyPair SecretKey PublicKey where keyGetPublic (SecretKey _ pub) = pub keyGetData (SecretKey sec _) = convert sec - keyFromData kdata spub = SecretKey <$> maybeCryptoError (ED.secretKey kdata) <*> pure spub + keyFromData kdata spub = do + skey <- maybeCryptoError $ ED.secretKey kdata + let PublicKey pkey = fromStored spub + guard $ ED.toPublic skey == pkey + return $ SecretKey skey spub generateKeys st = do secret <- ED.generateSecretKey public <- wrappedStore st $ PublicKey $ ED.toPublic secret @@ -115,7 +119,11 @@ data SecretKexKey = SecretKexKey CX.SecretKey (Stored PublicKexKey) instance KeyPair SecretKexKey PublicKexKey where keyGetPublic (SecretKexKey _ pub) = pub keyGetData (SecretKexKey sec _) = convert sec - keyFromData kdata spub = SecretKexKey <$> maybeCryptoError (CX.secretKey kdata) <*> pure spub + keyFromData kdata spub = do + skey <- maybeCryptoError $ CX.secretKey kdata + let PublicKexKey pkey = fromStored spub + guard $ CX.toPublic skey == pkey + return $ SecretKexKey skey spub generateKeys st = do secret <- CX.generateSecretKey public <- wrappedStore st $ PublicKexKey $ CX.toPublic secret |