packages feed

libsodium-bindings 0.0.2.0 → 0.0.3.0

raw patch · 6 files changed

+74/−32 lines, 6 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ LibSodium.Bindings.Comparison: sodiumCompare :: Ptr CUChar -> Ptr CUChar -> CSize -> IO CInt
- LibSodium.Bindings.Main: secureMain :: forall (a :: Type). IO a -> IO a
+ LibSodium.Bindings.Main: secureMain :: IO a -> IO a
- LibSodium.Bindings.Main: secureMainWithError :: forall (a :: Type). IO a -> IO a -> IO a
+ LibSodium.Bindings.Main: secureMainWithError :: IO a -> IO a -> IO a
- LibSodium.Bindings.SecureMemory: finalizerSodiumFree :: forall a. FinalizerPtr a
+ LibSodium.Bindings.SecureMemory: finalizerSodiumFree :: FinalizerPtr a
- LibSodium.Bindings.SecureMemory: sodiumAllocArray :: forall a. CSize -> CSize -> IO (Ptr a)
+ LibSodium.Bindings.SecureMemory: sodiumAllocArray :: CSize -> CSize -> IO (Ptr a)
- LibSodium.Bindings.SecureMemory: sodiumFree :: forall a. Ptr a -> IO ()
+ LibSodium.Bindings.SecureMemory: sodiumFree :: Ptr a -> IO ()
- LibSodium.Bindings.SecureMemory: sodiumMalloc :: forall a. CSize -> IO (Ptr a)
+ LibSodium.Bindings.SecureMemory: sodiumMalloc :: CSize -> IO (Ptr a)

Files

CHANGELOG.md view
@@ -1,5 +1,9 @@ # CHANGELOG +## 0.0.3.0++* Add constant-time pointer comparison [#171](https://github.com/haskell-cryptography/libsodium-bindings/pull/171)+ ## 0.0.2.0  * Add secret key Stream [#144](https://github.com/haskell-cryptography/libsodium-bindings/pull/144)
README.md view
@@ -1,4 +1,6 @@ # libsodium-bindings [![CI](https://github.com/haskell-cryptography/libsodium-bindings/actions/workflows/ci.yaml/badge.svg)](https://github.com/haskell-cryptography/libsodium-bindings/actions/workflows/ci.yaml) [![made with Haskell](https://img.shields.io/badge/Made%20in-Haskell-%235e5086?logo=haskell&style=flat-square)](https://haskell.org) -`libsodium-bindings` exposes a set of FFI bindings from the `libsodium-1.0.18-stable` library.+`libsodium-bindings` exposes a set of FFI bindings from the `libsodium` library, version 1.0.18 and above. It has no other dependency than `base`, and the documentation is strong enough to stand alone.++See [LibSodium.Bindings](https://hackage-content.haskell.org/package/libsodium-bindings/candidate/docs/LibSodium-Bindings.html) for a list of available functions.
libsodium-bindings.cabal view
@@ -1,69 +1,82 @@-cabal-version:      3.0-name:               libsodium-bindings-version:            0.0.2.0-category:           Cryptography-synopsis:           FFI bindings to libsodium+cabal-version: 3.0+name: libsodium-bindings+version: 0.0.3.0+category: Cryptography+synopsis: FFI bindings to libsodium description:   This library embeds FFI bindings to the stable version of libsodium 1.0.18.   The interface exposed by this library is kept close to the C library. -homepage:           https://github.com/haskell-cryptography/libsodium-bindings+homepage: https://github.com/haskell-cryptography/libsodium-bindings bug-reports:   https://github.com/haskell-cryptography/libsodium-bindings/issues -author:             Hécate Moonlight, Koz Ross-maintainer:         The Haskell Cryptography contributors-license:            BSD-3-Clause-build-type:         Simple+author: Hécate Moonlight, Koz Ross+maintainer: The Haskell Cryptography contributors+license: BSD-3-Clause+build-type: Simple tested-with:-  GHC ==9.2.8 || ==9.4.8 || ==9.6.6 || ==9.8.2 || ==9.10.1+  GHC ==9.2.8 || ==9.4.8 || ==9.6.6 || ==9.8.2 || ==9.10.1 || ==9.12.1  extra-source-files:   LICENSE   README.md -extra-doc-files:    CHANGELOG.md+extra-doc-files: CHANGELOG.md  flag pkg-config   description: Use pkg-config to find Libsodium (macOS and linux only).-  default:     False-  manual:      True+  default: False+  manual: True  flag homebrew   description: Use Homebrew version of Libsodium (macOS only).-  default:     False-  manual:      True+  default: False+  manual: True  source-repository head-  type:     git+  type: git   location: https://github.com/haskell-cryptography/libsodium-bindings+  subdir: libsodium-bindings  common common-  build-depends:    base >=4.14 && <5+  build-depends: base >=4.14 && <5   ghc-options:-    -Wall -Wcompat -Widentities -Wincomplete-record-updates-    -Wincomplete-uni-patterns -Wpartial-fields -Wredundant-constraints-    -fhide-source-paths -Wno-unused-do-bind+    -Wall+    -Wcompat+    -Widentities+    -Wincomplete-record-updates+    -Wincomplete-uni-patterns+    -Wpartial-fields+    -Wredundant-constraints+    -fhide-source-paths+    -Wno-unused-do-bind    if (os(osx) && flag(homebrew))-    include-dirs:   /opt/local/include /opt/homebrew/include-    extra-lib-dirs: /user/local/opt/libsodium/lib /opt/homebrew/lib+    include-dirs:+      /opt/homebrew/include+      /opt/local/include +    extra-lib-dirs:+      /opt/homebrew/lib+      /user/local/opt/libsodium/lib+   if flag(pkg-config)     pkgconfig-depends: libsodium >=1.0.18-   else     extra-libraries: sodium    default-language: Haskell2010  common common-rts-options-  ghc-options: -rtsopts -threaded -with-rtsopts=-N+  ghc-options:+    -rtsopts+    -threaded+    -with-rtsopts=-N  library-  import:          common-  hs-source-dirs:  src-+  import: common+  hs-source-dirs: src   -- cabal-fmt: expand src/   exposed-modules:     LibSodium.Bindings@@ -78,12 +91,12 @@     LibSodium.Bindings.Main     LibSodium.Bindings.PasswordHashing     LibSodium.Bindings.Random+    LibSodium.Bindings.SHA2     LibSodium.Bindings.Scrypt     LibSodium.Bindings.SealedBoxes-    LibSodium.Bindings.Secretbox     LibSodium.Bindings.SecretStream+    LibSodium.Bindings.Secretbox     LibSodium.Bindings.SecureMemory-    LibSodium.Bindings.SHA2     LibSodium.Bindings.ShortHashing     LibSodium.Bindings.Utils     LibSodium.Bindings.XChaCha20
src/LibSodium/Bindings/Comparison.hs view
@@ -3,7 +3,7 @@  -- | Module: LibSodium.Bindings.Comparison -- Description: Helper functions for constant-time comparison--- Copyright: (C) Koz Ross 2022+-- Copyright: (C) Koz Ross 2022, Jack Henahan 2025 -- License: BSD-3-Clause -- Maintainer: koz.ross@retro-freedom.nz -- Stability: Stable@@ -13,6 +13,7 @@ -- input length. module LibSodium.Bindings.Comparison   ( sodiumMemcmp+  , sodiumCompare   , sodiumIsZero   ) where@@ -36,6 +37,26 @@     -- ^ How many bytes to compare     -> CInt     -- ^ 0 if all bytes match, -1 otherwise++-- | Lexicographically compares the requested bytes of the given+-- pointers in constant time.+--+-- /See:/ [sodium_compare()](https://libsodium.gitbook.io/doc/helpers#comparing-large-numbers)+--+-- @since 0.0.3.0+foreign import capi "sodium.h sodium_compare"+  sodiumCompare+    :: Ptr CUChar+    -- ^ First pointer data (lhs)+    -> Ptr CUChar+    -- ^ Second pointer data (rhs)+    -> CSize+    -- ^ Bytes to compare+    -> IO CInt+    -- ^ Comparison result+    -- lhs == rhs -> 0+    -- lhs < rhs -> -1+    -- lhs > rhs -> 1  -- | Checks if the given number of bytes at the given location are all equal to -- zero. Constant-time for any given length.
src/LibSodium/Bindings/SealedBoxes.hs view
@@ -23,6 +23,7 @@  import Foreign (Ptr) import Foreign.C (CInt (CInt), CSize (CSize), CUChar, CULLong (CULLong))+ import LibSodium.Bindings.CryptoBox (cryptoBoxKeyPair, cryptoBoxSeedKeyPair)  -- $introduction
src/LibSodium/Bindings/ShortHashing.hs view
@@ -35,6 +35,7 @@ import Data.Word (Word8) import Foreign.C (CInt (CInt), CSize (CSize), CUChar, CULLong (CULLong)) import Foreign.Ptr (Ptr, castPtr)+ import LibSodium.Bindings.Random (randombytesBuf)  -- | Create a secret key of size 'cryptoShortHashKeyBytes'.