[QA] fix issues from HSE so that it parse files
This commit is contained in:
parent
937b5d08dd
commit
87777784c1
@ -57,7 +57,7 @@ secretKey bs
|
|||||||
withByteArray bs $ \inp -> do
|
withByteArray bs $ \inp -> do
|
||||||
valid <- isValidPtr inp
|
valid <- isValidPtr inp
|
||||||
if valid
|
if valid
|
||||||
then Right . SecretKey <$> B.copy bs (\_ -> return ())
|
then (Right . SecretKey) <$> B.copy bs (\_ -> return ())
|
||||||
else return $ Left "invalid secret key"
|
else return $ Left "invalid secret key"
|
||||||
| otherwise = Left "secret key invalid size"
|
| otherwise = Left "secret key invalid size"
|
||||||
where
|
where
|
||||||
|
|||||||
@ -58,16 +58,15 @@ publicKey bs
|
|||||||
-- | Try to build a secret key from a bytearray
|
-- | Try to build a secret key from a bytearray
|
||||||
secretKey :: ByteArrayAccess ba => ba -> CryptoFailable SecretKey
|
secretKey :: ByteArrayAccess ba => ba -> CryptoFailable SecretKey
|
||||||
secretKey bs
|
secretKey bs
|
||||||
| B.length bs == secretKeySize = unsafeDoIO $ do
|
| B.length bs == secretKeySize = unsafeDoIO $ withByteArray bs initialize
|
||||||
withByteArray bs $ \inp -> do
|
| otherwise = CryptoFailed CryptoError_SecretKeyStructureInvalid
|
||||||
|
where
|
||||||
|
initialize inp = do
|
||||||
valid <- isValidPtr inp
|
valid <- isValidPtr inp
|
||||||
if valid
|
if valid
|
||||||
then CryptoPassed . SecretKey <$> B.copy bs (\_ -> return ())
|
then (CryptoPassed . SecretKey) <$> B.copy bs (\_ -> return ())
|
||||||
else return $ CryptoFailed CryptoError_SecretKeyStructureInvalid
|
else return $ CryptoFailed CryptoError_SecretKeyStructureInvalid
|
||||||
| otherwise = CryptoFailed CryptoError_SecretKeyStructureInvalid
|
isValidPtr _ =
|
||||||
where
|
|
||||||
isValidPtr :: Ptr Word8 -> IO Bool
|
|
||||||
isValidPtr _ = do
|
|
||||||
return True
|
return True
|
||||||
{-# NOINLINE secretKey #-}
|
{-# NOINLINE secretKey #-}
|
||||||
|
|
||||||
@ -83,7 +82,7 @@ signature bs
|
|||||||
toPublic :: SecretKey -> PublicKey
|
toPublic :: SecretKey -> PublicKey
|
||||||
toPublic (SecretKey sec) = PublicKey <$>
|
toPublic (SecretKey sec) = PublicKey <$>
|
||||||
B.allocAndFreeze publicKeySize $ \result ->
|
B.allocAndFreeze publicKeySize $ \result ->
|
||||||
withByteArray sec $ \psec ->
|
withByteArray sec $ \psec ->
|
||||||
ccryptonite_ed25519_publickey psec result
|
ccryptonite_ed25519_publickey psec result
|
||||||
{-# NOINLINE toPublic #-}
|
{-# NOINLINE toPublic #-}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user