From a71ceb0daa255a5e767c4600a061b5bbb0cfa4d7 Mon Sep 17 00:00:00 2001 From: Giorgio Marinelli Date: Wed, 4 Sep 2024 10:55:26 +0200 Subject: [PATCH 1/3] Switch to crypton --- one-time-password.cabal | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/one-time-password.cabal b/one-time-password.cabal index 9474984..b98599b 100644 --- a/one-time-password.cabal +++ b/one-time-password.cabal @@ -79,7 +79,7 @@ test-suite tests , base32 ^>=0.4 , bytestring , chronos - , cryptonite + , crypton , one-time-password , sel , tasty @@ -127,5 +127,5 @@ executable one-time-password , torsor ^>=0.1 other-modules: Paths_one_time_password - autogen-modules: Paths_one_time_password + autogen-modules: Paths_one_time_password ghc-options: -Wall From 49cce800ae09170db8e61410057bce23fc5152a4 Mon Sep 17 00:00:00 2001 From: Giorgio Marinelli Date: Wed, 4 Sep 2024 11:31:58 +0200 Subject: [PATCH 2/3] Re-export interface types; fix formatting --- app/Main.hs | 12 ++++++------ src/OTP/HOTP.hs | 5 +++++ src/OTP/TOTP.hs | 11 +++++++++++ test/Test/HOTP.hs | 1 - 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/app/Main.hs b/app/Main.hs index 5306475..435abe8 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -1,20 +1,20 @@ module Main (main) where -import Chronos (Time (..), Timespan (..), datetimeToTime, decode_YmdHMS, now, second, w3c) +import Chronos (datetimeToTime, decode_YmdHMS, now, second, w3c) import Data.ByteString (StrictByteString) -import qualified Data.ByteString.Char8 as BSC8 +import Data.ByteString.Char8 qualified as BSC8 import Data.Maybe (fromJust) import Data.Text (Text) import Data.Text.Display -import qualified Data.Text.Encoding as TE -import qualified Data.Text.IO as TIO +import Data.Text.Encoding qualified as TE +import Data.Text.IO qualified as TIO import Data.Version (showVersion) import Data.Word import Options.Applicative import Paths_one_time_password (version) import Sel (secureMain) -import qualified Sel.HMAC.SHA256 as SHA256 -import qualified Sel.HMAC.SHA512 as SHA512 +import Sel.HMAC.SHA256 qualified as SHA256 +import Sel.HMAC.SHA512 qualified as SHA512 import System.Exit (exitFailure) import Torsor (scale) diff --git a/src/OTP/HOTP.hs b/src/OTP/HOTP.hs index 2ea787c..1100280 100644 --- a/src/OTP/HOTP.hs +++ b/src/OTP/HOTP.hs @@ -15,6 +15,11 @@ module OTP.HOTP , newSHA512Key , hotpSHA512 , hotpSHA512Check + + -- ** Re-exports for convenience + , OTP.Commons.Digits + , SHA256.AuthenticationKey + , mkDigits ) where import Crypto.Hash.SHA1 qualified as SHA1 diff --git a/src/OTP/TOTP.hs b/src/OTP/TOTP.hs index 96890c0..0518adb 100644 --- a/src/OTP/TOTP.hs +++ b/src/OTP/TOTP.hs @@ -25,6 +25,15 @@ module OTP.TOTP -- ** URI Generation , totpToURI + + -- ** Re-exports for convenience + , Chronos.Time + , Chronos.Timespan + , OTP.Commons.Algorithm + , OTP.Commons.Digits + , SHA256.AuthenticationKey + , digitsToWord32 + , mkDigits ) where import Chronos (Time (..), Timespan (..), asSeconds) @@ -40,6 +49,8 @@ import OTP.Commons ( Algorithm , Digits , OTP + , digitsToWord32 + , mkDigits , totpCounter , totpCounterRange ) diff --git a/test/Test/HOTP.hs b/test/Test/HOTP.hs index 37f64d6..03eeba6 100644 --- a/test/Test/HOTP.hs +++ b/test/Test/HOTP.hs @@ -9,7 +9,6 @@ import Sel.HMAC.SHA256 qualified as SHA256 import Sel.HMAC.SHA512 qualified as SHA512 import Data.Text qualified as Text -import OTP.Commons import Test.Tasty import Test.Tasty.HUnit import Test.Utils From 3d238a6dc22e4911edf26eedcb36461f120099c7 Mon Sep 17 00:00:00 2001 From: Giorgio Marinelli Date: Wed, 4 Sep 2024 17:06:09 +0200 Subject: [PATCH 3/3] Do not re-export 3rd party libraries --- app/Main.hs | 2 +- src/OTP/HOTP.hs | 7 +++---- src/OTP/TOTP.hs | 15 ++++++--------- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/app/Main.hs b/app/Main.hs index 435abe8..5762e3d 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -1,6 +1,6 @@ module Main (main) where -import Chronos (datetimeToTime, decode_YmdHMS, now, second, w3c) +import Chronos (Time (..), Timespan (..), datetimeToTime, decode_YmdHMS, now, second, w3c) import Data.ByteString (StrictByteString) import Data.ByteString.Char8 qualified as BSC8 import Data.Maybe (fromJust) diff --git a/src/OTP/HOTP.hs b/src/OTP/HOTP.hs index 1100280..9cd8ddf 100644 --- a/src/OTP/HOTP.hs +++ b/src/OTP/HOTP.hs @@ -1,5 +1,5 @@ module OTP.HOTP - ( OTP + ( OTP (..) -- ** HMAC-SHA-1 , newSHA1Key @@ -16,9 +16,8 @@ module OTP.HOTP , hotpSHA512 , hotpSHA512Check - -- ** Re-exports for convenience - , OTP.Commons.Digits - , SHA256.AuthenticationKey + -- ** Re-exports from OTP.Commons + , Digits , mkDigits ) where diff --git a/src/OTP/TOTP.hs b/src/OTP/TOTP.hs index 0518adb..a64d58e 100644 --- a/src/OTP/TOTP.hs +++ b/src/OTP/TOTP.hs @@ -6,7 +6,7 @@ module OTP.TOTP ( -- ** Usage -- $usage - OTP + OTP (..) -- ** HMAC-SHA-1 , newSHA1Key @@ -26,12 +26,9 @@ module OTP.TOTP -- ** URI Generation , totpToURI - -- ** Re-exports for convenience - , Chronos.Time - , Chronos.Timespan - , OTP.Commons.Algorithm - , OTP.Commons.Digits - , SHA256.AuthenticationKey + -- ** Re-exports from OTP.Commons + , Algorithm (..) + , Digits , digitsToWord32 , mkDigits ) where @@ -46,9 +43,9 @@ import Sel.HMAC.SHA256 qualified as SHA256 import Sel.HMAC.SHA512 qualified as SHA512 import OTP.Commons - ( Algorithm + ( Algorithm (..) , Digits - , OTP + , OTP (..) , digitsToWord32 , mkDigits , totpCounter