Skip to content

Commit

Permalink
Add usage of secureMain in the examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Kleidukos committed May 5, 2024
1 parent 72f3817 commit fc7e7d8
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 11 deletions.
4 changes: 3 additions & 1 deletion sel/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# CHANGELOG

## [Unreleased]
## sel-0.0.2.0 -- XXXX-XX-XX

* Add usages of `secureMain` in examples
3 changes: 2 additions & 1 deletion sel/src/Sel/HMAC/SHA256.hs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ import Sel.Internal (allocateWith, foreignPtrEq, foreignPtrOrd)
-- $usage
--
-- > import Sel.HMAC.SHA256 qualified as HMAC
-- > import Sel (secureMain)
-- >
-- > main = do
-- > main = secureMain $ do
-- > -- The parties agree on a shared secret key
-- > authKey <- HMAC.newAuthenticationKey
-- > -- An authentication tag is computed for the message by the server
Expand Down
3 changes: 2 additions & 1 deletion sel/src/Sel/HMAC/SHA512.hs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ import Sel.Internal (allocateWith, foreignPtrEq, foreignPtrOrd)
-- $usage
--
-- > import Sel.HMAC.SHA512 qualified as HMAC
-- > import Sel (secureMain)
-- >
-- > main = do
-- > main = secureMain $ do
-- > -- The parties agree on a shared secret key
-- > authKey <- HMAC.newAuthenticationKey
-- > -- An authentication tag is computed for the message by the server
Expand Down
3 changes: 2 additions & 1 deletion sel/src/Sel/HMAC/SHA512_256.hs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ import Sel.Internal (allocateWith, foreignPtrEq, foreignPtrOrd)
-- $usage
--
-- > import Sel.HMAC.SHA512_256 qualified as HMAC
-- > import Sel (secureMain)
-- >
-- > main = do
-- > main = secureMain $ do
-- > -- The parties agree on a shared secret key
-- > authKey <- HMAC.newAuthenticationKey
-- > -- An authentication tag is computed for the message by the server
Expand Down
3 changes: 2 additions & 1 deletion sel/src/Sel/PublicKey/Cipher.hs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ import Sel.Internal
-- $usage
--
-- > import qualified Sel.PublicKey.Cipher as Cipher
-- > import Sel (secureMain)
-- >
-- > main = do
-- > main = secureMain $ do
-- > -- We get the sender their pair of keys:
-- > (senderSecretKey, senderPublicKey) <- newKeyPair
-- > -- We get the nonce from the other party with the message, or with 'encrypt' and our own message.
Expand Down
3 changes: 2 additions & 1 deletion sel/src/Sel/PublicKey/Seal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ import Sel.PublicKey.Cipher (CipherText (CipherText), EncryptionError (..), KeyP
-- $usage
--
-- > import qualified Sel.PublicKey.Seal as Seal
-- > import Sel (secureMain)
-- >
-- > main = do
-- > main = secureMain $ do
-- > -- We get the recipient their pair of keys:
-- > (recipientPublicKey, recipientSecretKey) <- newKeyPair
-- > encryptedMessage <- Seal.encrypt "hello hello" recipientPublicKey
Expand Down
3 changes: 2 additions & 1 deletion sel/src/Sel/SecretKey/Authentication.hs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ import Sel.Internal
-- $usage
--
-- > import Sel.SecretKey.Authentication qualified as Auth
-- > import Sel (secureMain)
-- >
-- > main = do
-- > main = secureMain $ do
-- > -- The parties agree on a shared secret key
-- > authKey <- Auth.newAuthenticationKey
-- > -- An authentication tag is computed for the message by the server
Expand Down
3 changes: 2 additions & 1 deletion sel/src/Sel/SecretKey/Cipher.hs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ import Sel.Internal
-- $usage
--
-- > import qualified Sel.SecretKey.Cipher as Cipher
-- > import Sel (secureMain)
-- >
-- > main = do
-- > main = secureMain $ do
-- > -- We get the secretKey from the other party or with 'newSecretKey'.
-- > -- We get the nonce from the other party with the message, or with 'encrypt' and our own message.
-- > -- Do not reuse a nonce with the same secret key!
Expand Down
5 changes: 2 additions & 3 deletions sel/test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module Main where

import Test.Tasty

import LibSodium.Bindings.Main (sodiumInit)
import qualified Test.HMAC as HMAC
import qualified Test.Hashing as Hashing
import qualified Test.Hashing.Password as Password
Expand All @@ -15,10 +14,10 @@ import qualified Test.Scrypt as Scrypt
import qualified Test.SecretKey.Authentication as SecretKey.Authentication
import qualified Test.SecretKey.Cipher as SecretKey.Cipher
import qualified Test.SecretKey.Stream as SecretKey.Stream
import Sel (secureMain)

main :: IO ()
main = do
sodiumInit
main = secureMain $ do
defaultMain . testGroup "sel tests" $ specs

specs :: [TestTree]
Expand Down

0 comments on commit fc7e7d8

Please sign in to comment.