Skip to content

Commit c6f5933

Browse files
authored
Merge pull request #31 from haskell-cryptography/prepare-3.0.1.0
Prepare 3.0.1.0
2 parents a360e1a + cbcc16b commit c6f5933

File tree

9 files changed

+57
-40
lines changed

9 files changed

+57
-40
lines changed

.github/workflows/linting.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
- uses: haskell-actions/run-fourmolu@v11
1515
with:
16-
version: "0.14.1.0"
16+
version: "0.17.0.0"
1717
pattern: |
1818
src/**/*.hs
1919
test/**/*.hs
@@ -26,7 +26,7 @@ jobs:
2626
- name: 'Set up HLint'
2727
uses: haskell-actions/hlint-setup@v2
2828
with:
29-
version: '3.8'
29+
version: '3.10'
3030

3131
- name: 'Run HLint'
3232
uses: haskell-actions/hlint-run@v2

.github/workflows/one-time-password.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,34 @@ jobs:
3030
steps:
3131
- name: Checkout base repo
3232
uses: actions/checkout@v4
33+
3334
- name: Set up Haskell
3435
id: setup-haskell
3536
uses: haskell-actions/setup@v2
3637
with:
3738
ghc-version: ${{ matrix.ghc }}
3839
cabal-version: 'latest'
40+
3941
- name: Configure
4042
run: |
4143
./.github/workflows/install-libsodium.sh
4244
cabal freeze
45+
4346
- name: Cache
4447
uses: actions/cache@v4
4548
with:
4649
path: ${{ steps.setup-haskell.outputs.cabal-store }}
4750
key: ${{ runner.os }}-ghc-${{ matrix.ghc }}-cabal-${{ hashFiles('**/plan.json') }}
4851
restore-keys: ${{ runner.os }}-ghc-${{ matrix.ghc }}-
49-
- name: Build
50-
run: cabal build
51-
- name: Test
52-
run: cabal test
52+
53+
- name: Test with homebrew on macOS
54+
if: ${{ matrix.os == 'macos-latest' }}
55+
run: |
56+
cabal build --project-file=cabal.homebrew.project -v2 all
57+
cabal test --project-file=cabal.homebrew.project all
58+
59+
- name: Test with pkg-config
60+
if: ${{ matrix.os == 'ubuntu-latest' }}
61+
run: |
62+
cabal build --project-file=cabal.pkg-config.project -v2 all
63+
cabal test --project-file=cabal.pkg-config.project all

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# CHANGELOG
22

3+
## 3.0.1.0 — 20-05-2025
4+
* Support latest versions of `text`, `text-display` and `sel`
5+
36
## 3.0.0.0 — 13-04-2024
47

58
* The library has been transferred to the Haskell Cryptography Group's stewardship;

cabal.homebrew.project

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import: ./cabal.project
2+
3+
package libsodium-bindings
4+
flags: +homebrew -pkg-config

cabal.pkg-config.project

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import: ./cabal.project
2+
3+
package libsodium-bindings
4+
flags: -homebrew +pkg-config
5+

cabal.project

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,3 @@ package *
1010
documentation: true
1111

1212
test-show-details: direct
13-
14-
source-repository-package
15-
type: git
16-
location: https://github.com/haskell-cryptography/libsodium-bindings
17-
tag: 1d86e29a6819bd65df89c5885ce0cf941b6f7012
18-
subdir:
19-
./libsodium-bindings
20-
./sel

one-time-password.cabal

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ category: Cryptography
2020
build-type: Simple
2121
extra-source-files: README.md
2222
extra-doc-files: CHANGELOG.md
23-
tested-with: GHC ==9.4.8 || ==9.6.4 || ==9.8.2
23+
tested-with:
24+
GHC ==9.4.8 || ==9.6.4 || ==9.6.7 || ==9.8.2 || ==9.8.4 || ==9.10.2
2425

2526
source-repository head
2627
type: git
27-
location: git://github.com/haskell-cryptography/one-time-password.git
28+
location:
29+
https://github.com/haskell-cryptography/one-time-password.git
2830

2931
common ghc-options
3032
ghc-options:
@@ -48,16 +50,16 @@ library
4850
OTP.TOTP
4951

5052
build-depends:
51-
, base >=4.17 && <5
52-
, bytestring ^>=0.12
53-
, cereal ^>=0.5
54-
, chronos ^>=1.1.6
55-
, cryptohash-sha1 ^>=0.11
56-
, network-uri ^>=2.6
57-
, sel >=0.1.0.0
58-
, text >=2.0
59-
, text-display ^>=1.0
60-
, text-builder-linear >=0.1
53+
, base >=4.17 && <5
54+
, bytestring ^>=0.12
55+
, cereal ^>=0.5
56+
, chronos ^>=1.1.6
57+
, cryptohash-sha1 ^>=0.11
58+
, network-uri ^>=2.6
59+
, sel ^>=0.1
60+
, text >=2.0
61+
, text-builder-linear >=0.1
62+
, text-display ^>=1.0
6163

6264
ghc-options: -Wall
6365

@@ -128,5 +130,5 @@ executable one-time-password
128130
, torsor ^>=0.1
129131

130132
other-modules: Paths_one_time_password
131-
autogen-modules: Paths_one_time_password
133+
autogen-modules: Paths_one_time_password
132134
ghc-options: -Wall

src/OTP/Commons.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ module OTP.Commons
1515

1616
import Chronos (Time (..), Timespan (..), asSeconds, sinceEpoch)
1717
import Data.Int (Int64)
18-
import Data.Text.Display
1918
import Data.Text.Builder.Linear (Builder)
19+
import Data.Text.Display
2020
import Data.Word
2121
import Text.Printf (printf)
2222

src/OTP/HOTP.hs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,13 @@ hotpSHA256
101101
-- ^ Number of digits in a password. MUST be 6 digits at a minimum, and possibly 7 and 8 digits.
102102
-> OTP
103103
-- ^ HOTP
104-
hotpSHA256 key counter digits' = unsafePerformIO $ do
104+
hotpSHA256 key counter digits' =
105105
let digits = digitsToWord32 digits'
106-
let msg = runPut $ putWord64be counter
107-
hash <- SHA256.authenticationTagToBinary <$> SHA256.authenticate msg key
108-
let code = truncateHash $ BS.unpack hash
109-
let result = code `rem` (10 ^ digits)
110-
pure $ OTP digits result
106+
msg = runPut $ putWord64be counter
107+
hash = SHA256.authenticationTagToBinary $ SHA256.authenticate msg key
108+
code = truncateHash $ BS.unpack hash
109+
result = code `rem` (10 ^ digits)
110+
in OTP digits result
111111

112112
-- | Check presented password against a valid range.
113113
--
@@ -150,13 +150,13 @@ hotpSHA512
150150
-- ^ Number of digits in a password
151151
-> OTP
152152
-- ^ HOTP
153-
hotpSHA512 key counter digits' = unsafePerformIO $ do
153+
hotpSHA512 key counter digits' =
154154
let digits = digitsToWord32 digits'
155-
let msg = runPut $ putWord64be counter
156-
hash <- SHA512.authenticationTagToBinary <$> SHA512.authenticate msg key
157-
let code = truncateHash $ BS.unpack hash
158-
let result = code `rem` (10 ^ digits)
159-
pure $ OTP digits result
155+
msg = runPut $ putWord64be counter
156+
hash = SHA512.authenticationTagToBinary $ SHA512.authenticate msg key
157+
code = truncateHash $ BS.unpack hash
158+
result = code `rem` (10 ^ digits)
159+
in OTP digits result
160160

161161
-- |
162162
--

0 commit comments

Comments
 (0)