Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions botan-bindings/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## ?.?.?.? -- ????-??-??

* BREAKING: for all newtypes with a record field name like `run*`, change the
name to `ptr`. See PR's
[#114](https://github.com/haskell-cryptography/botan/pull/114) and
[#117](https://github.com/haskell-cryptography/botan/pull/117). For example.
`runBotanBlockCipher` is changed to `ptr`.
* BREAKING: re-enable `FieldSelectors` for the `ConstPtr` module. See PR
[#117](https://github.com/haskell-cryptography/botan/pull/117).

## 0.2.0.0 -- 2025-12-30

* BREAKING: remove experimental FFI code related to `x509`. See PR
Expand Down
5 changes: 3 additions & 2 deletions botan-bindings/src/Botan/Bindings/ConstPtr.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE FieldSelectors #-}

module Botan.Bindings.ConstPtr (
ConstPtr(..)
Expand Down Expand Up @@ -27,7 +28,7 @@ import Foreign.Storable
-- botan_version_string
type ConstPtr :: Type -> Type
type role ConstPtr phantom
newtype ConstPtr a = ConstPtr { ptr :: Ptr a }
newtype ConstPtr a = ConstPtr { unConstPtr :: Ptr a }
deriving stock (Data)
deriving newtype (Eq, Ord, Storable)

Expand Down
5 changes: 5 additions & 0 deletions botan-low/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
* BREAKING: `x509CertAllowedUsage` now takes a list of `X509KeyConstraints`
instead of a single value. See PR
[#113](https://github.com/haskell-cryptography/botan/pull/113).
* BREAKING: for all newtypes with a record field name like `get*ForeignPtr`,
change the name to `foreignPtr`. See PR's
[#114](https://github.com/haskell-cryptography/botan/pull/114) and
[#117](https://github.com/haskell-cryptography/botan/pull/117). For example.
`getBlockCipherForeignPtr` is changed to `foreignPtr`.

## 0.1.0.0 -- 2025-12-30

Expand Down
14 changes: 2 additions & 12 deletions botan-low/src/Botan/Low/Error/Internal.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{-# LANGUAGE CPP #-}

{-|
Module : Botan.Low.Error
Description : Error codes and exception handling
Expand Down Expand Up @@ -75,11 +73,7 @@ newtype BotanErrorCode = BotanErrorCode CInt
botanErrorDescription :: BotanErrorCode -> IO ByteString
botanErrorDescription (BotanErrorCode e) = do
descPtr <- botan_error_description e
#if MIN_VERSION_base (4,18,0)
peekCString (unConstPtr descPtr)
#else
peekCString descPtr.ptr
#endif
peekCString descPtr.unConstPtr

newtype BotanErrorMessage = BotanErrorMessage ByteString
deriving newtype Show
Expand All @@ -90,11 +84,7 @@ newtype BotanErrorMessage = BotanErrorMessage ByteString
botanErrorLastExceptionMessage :: IO BotanErrorMessage
botanErrorLastExceptionMessage = do
msgPtr <- botan_error_last_exception_message
#if MIN_VERSION_base (4,18,0)
BotanErrorMessage <$> peekCString (unConstPtr msgPtr)
#else
BotanErrorMessage <$> peekCString msgPtr.ptr
#endif
BotanErrorMessage <$> peekCString msgPtr.unConstPtr

{-------------------------------------------------------------------------------
Exception hierarchy
Expand Down
2 changes: 1 addition & 1 deletion botan-low/src/Botan/Low/RNG.hs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ You can also seed it with your own entropy; this is safe and can never
-}

-- NOTE: Does not take advantage of Remake
-- NOTE: Uses ConstPtr / ptr manually (unConstPtr if base <= 4.18 )
-- NOTE: Uses ConstPtr / unConstPtr manually
-- TODO: Take advantage of Remake / better peek / (peekConst or constPeek) functions

newtype RNG = MkRNG { foreignPtr :: ForeignPtr BotanRNGStruct }
Expand Down
9 changes: 2 additions & 7 deletions botan-low/src/Botan/Low/Version.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{-# LANGUAGE CPP #-}

{-|
Module : Botan.Low.Version
Description : Botan version info
Expand Down Expand Up @@ -45,12 +43,9 @@ botanFFIAPIVersion = fromIntegral <$> botan_ffi_api_version
botanFFISupportsAPI :: Int -> IO Bool
botanFFISupportsAPI version = do
throwBotanCatchingInvalidInput $ botan_ffi_supports_api (fromIntegral version)

botanVersionString :: IO ByteString
#if MIN_VERSION_base (4,18,0)
botanVersionString = botan_version_string >>= peekCString . unConstPtr
#else
botanVersionString = botan_version_string >>= peekCString . (.ptr)
#endif
botanVersionString = botan_version_string >>= peekCString . (.unConstPtr)

-- | Returns the major version of the library
botanVersionMajor :: IO Int
Expand Down
8 changes: 2 additions & 6 deletions botan-low/src/Botan/Low/X509.hs
Original file line number Diff line number Diff line change
Expand Up @@ -346,12 +346,8 @@ x509CertValidationStatus code = do
status <- botan_x509_cert_validation_status (fromIntegral code)
if status == ConstPtr nullPtr
then return Nothing
else
#if MIN_VERSION_base (4,18,0)
Just <$> packCString (unConstPtr status)
#else
Just <$> packCString status.ptr
#endif
else Just <$> packCString status.unConstPtr

-- /*
-- * X.509 CRL
-- **************************/
Expand Down