botan-low 0.1.0.0 → 0.2.0.0
raw patch · 23 files changed
+132/−130 lines, 23 filesdep ~botan-bindingsPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: botan-bindings
API changes (from Hackage documentation)
- Botan.Low.BlockCipher: [$sel:getBlockCipherForeignPtr:MkBlockCipher] :: BlockCipher -> ForeignPtr BotanBlockCipherStruct
- Botan.Low.Cipher: [$sel:getCipherForeignPtr:MkCipher] :: Cipher -> ForeignPtr BotanCipherStruct
- Botan.Low.FPE: [$sel:getFPEForeignPtr:MkFPE] :: FPE -> ForeignPtr BotanFPEStruct
- Botan.Low.HOTP: [$sel:getHOTPForeignPtr:MkHOTP] :: HOTP -> ForeignPtr BotanHOTPStruct
- Botan.Low.Hash: [$sel:getHashForeignPtr:MkHash] :: Hash -> ForeignPtr BotanHashStruct
- Botan.Low.MAC: [$sel:getMACForeignPtr:MkMAC] :: MAC -> ForeignPtr BotanMACStruct
- Botan.Low.MPI: [$sel:getMPForeignPtr:MkMP] :: MP -> ForeignPtr BotanMPStruct
- Botan.Low.PubKey: [$sel:getPrivKeyForeignPtr:MkPrivKey] :: PrivKey -> ForeignPtr BotanPrivKeyStruct
- Botan.Low.PubKey: [$sel:getPubKeyForeignPtr:MkPubKey] :: PubKey -> ForeignPtr BotanPubKeyStruct
- Botan.Low.PubKey.Decrypt: [$sel:getDecryptForeignPtr:MkDecrypt] :: Decrypt -> ForeignPtr BotanPKOpDecryptStruct
- Botan.Low.PubKey.Encrypt: [$sel:getEncryptForeignPtr:MkEncrypt] :: Encrypt -> ForeignPtr BotanPKOpEncryptStruct
- Botan.Low.PubKey.KeyAgreement: [$sel:getKeyAgreementForeignPtr:MkKeyAgreement] :: KeyAgreement -> ForeignPtr BotanPKOpKeyAgreementStruct
- Botan.Low.PubKey.KeyEncapsulation: [$sel:getKEMDecryptForeignPtr:MkKEMDecrypt] :: KEMDecrypt -> ForeignPtr BotanPKOpKEMDecryptStruct
- Botan.Low.PubKey.KeyEncapsulation: [$sel:getKEMEncryptForeignPtr:MkKEMEncrypt] :: KEMEncrypt -> ForeignPtr BotanPKOpKEMEncryptStruct
- Botan.Low.PubKey.Sign: [$sel:getSignForeignPtr:MkSign] :: Sign -> ForeignPtr BotanPKOpSignStruct
- Botan.Low.PubKey.Sign: pattern DERFormatSignature :: SigningFlags
- Botan.Low.PubKey.Sign: pattern StandardFormatSignature :: SigningFlags
- Botan.Low.PubKey.Sign: type SigningFlags = Word32
- Botan.Low.PubKey.Verify: [$sel:getVerifyForeignPtr:MkVerify] :: Verify -> ForeignPtr BotanPKOpVerifyStruct
- Botan.Low.RNG: [$sel:getRNGForeignPtr:MkRNG] :: RNG -> ForeignPtr BotanRNGStruct
- Botan.Low.SRP6: [$sel:getSRP6ServerSessionForeignPtr:MkSRP6ServerSession] :: SRP6ServerSession -> ForeignPtr BotanSRP6ServerSessionStruct
- Botan.Low.TOTP: [$sel:getTOTPForeignPtr:MkTOTP] :: TOTP -> ForeignPtr BotanTOTPStruct
- Botan.Low.X509: [$sel:getX509CRLForeignPtr:MkX509CRL] :: X509CRL -> ForeignPtr BotanX509CRLStruct
- Botan.Low.X509: [$sel:getX509CertForeignPtr:MkX509Cert] :: X509Cert -> ForeignPtr BotanX509CertStruct
- Botan.Low.X509: pattern CRLSign :: X509KeyConstraints
- Botan.Low.X509: pattern DataEncipherment :: X509KeyConstraints
- Botan.Low.X509: pattern DecipherOnly :: X509KeyConstraints
- Botan.Low.X509: pattern DigitalSignature :: X509KeyConstraints
- Botan.Low.X509: pattern EncipherOnly :: X509KeyConstraints
- Botan.Low.X509: pattern KeyAgreement :: X509KeyConstraints
- Botan.Low.X509: pattern KeyCertSign :: X509KeyConstraints
- Botan.Low.X509: pattern KeyEncipherment :: X509KeyConstraints
- Botan.Low.X509: pattern NoConstraints :: X509KeyConstraints
- Botan.Low.X509: pattern NonRepudiation :: X509KeyConstraints
- Botan.Low.X509: type X509KeyConstraints = CUInt
+ Botan.Low.BlockCipher: [$sel:foreignPtr:MkBlockCipher] :: BlockCipher -> ForeignPtr BotanBlockCipherStruct
+ Botan.Low.Cipher: [$sel:foreignPtr:MkCipher] :: Cipher -> ForeignPtr BotanCipherStruct
+ Botan.Low.FPE: [$sel:foreignPtr:MkFPE] :: FPE -> ForeignPtr BotanFPEStruct
+ Botan.Low.HOTP: [$sel:foreignPtr:MkHOTP] :: HOTP -> ForeignPtr BotanHOTPStruct
+ Botan.Low.Hash: [$sel:foreignPtr:MkHash] :: Hash -> ForeignPtr BotanHashStruct
+ Botan.Low.MAC: [$sel:foreignPtr:MkMAC] :: MAC -> ForeignPtr BotanMACStruct
+ Botan.Low.MPI: [$sel:foreignPtr:MkMP] :: MP -> ForeignPtr BotanMPStruct
+ Botan.Low.PubKey: [$sel:foreignPtr:MkPrivKey] :: PrivKey -> ForeignPtr BotanPrivKeyStruct
+ Botan.Low.PubKey: [$sel:foreignPtr:MkPubKey] :: PubKey -> ForeignPtr BotanPubKeyStruct
+ Botan.Low.PubKey.Decrypt: [$sel:foreignPtr:MkDecrypt] :: Decrypt -> ForeignPtr BotanPKOpDecryptStruct
+ Botan.Low.PubKey.Encrypt: [$sel:foreignPtr:MkEncrypt] :: Encrypt -> ForeignPtr BotanPKOpEncryptStruct
+ Botan.Low.PubKey.KeyAgreement: [$sel:foreignPtr:MkKeyAgreement] :: KeyAgreement -> ForeignPtr BotanPKOpKeyAgreementStruct
+ Botan.Low.PubKey.KeyEncapsulation: [$sel:foreignPtr:MkKEMDecrypt] :: KEMDecrypt -> ForeignPtr BotanPKOpKEMDecryptStruct
+ Botan.Low.PubKey.KeyEncapsulation: [$sel:foreignPtr:MkKEMEncrypt] :: KEMEncrypt -> ForeignPtr BotanPKOpKEMEncryptStruct
+ Botan.Low.PubKey.Sign: DERFormatSignature :: SigningFlags
+ Botan.Low.PubKey.Sign: StandardFormatSignature :: SigningFlags
+ Botan.Low.PubKey.Sign: [$sel:foreignPtr:MkSign] :: Sign -> ForeignPtr BotanPKOpSignStruct
+ Botan.Low.PubKey.Sign: data SigningFlags
+ Botan.Low.PubKey.Sign: signingFlags :: SigningFlags -> Word32
+ Botan.Low.PubKey.Verify: [$sel:foreignPtr:MkVerify] :: Verify -> ForeignPtr BotanPKOpVerifyStruct
+ Botan.Low.RNG: [$sel:foreignPtr:MkRNG] :: RNG -> ForeignPtr BotanRNGStruct
+ Botan.Low.SRP6: [$sel:foreignPtr:MkSRP6ServerSession] :: SRP6ServerSession -> ForeignPtr BotanSRP6ServerSessionStruct
+ Botan.Low.TOTP: [$sel:foreignPtr:MkTOTP] :: TOTP -> ForeignPtr BotanTOTPStruct
+ Botan.Low.X509: CRLSign :: X509KeyConstraints
+ Botan.Low.X509: DataEncipherment :: X509KeyConstraints
+ Botan.Low.X509: DecipherOnly :: X509KeyConstraints
+ Botan.Low.X509: DigitalSignature :: X509KeyConstraints
+ Botan.Low.X509: EncipherOnly :: X509KeyConstraints
+ Botan.Low.X509: KeyAgreement :: X509KeyConstraints
+ Botan.Low.X509: KeyCertSign :: X509KeyConstraints
+ Botan.Low.X509: KeyEncipherment :: X509KeyConstraints
+ Botan.Low.X509: NoConstraints :: X509KeyConstraints
+ Botan.Low.X509: NonRepudiation :: X509KeyConstraints
+ Botan.Low.X509: [$sel:foreignPtr:MkX509CRL] :: X509CRL -> ForeignPtr BotanX509CRLStruct
+ Botan.Low.X509: [$sel:foreignPtr:MkX509Cert] :: X509Cert -> ForeignPtr BotanX509CertStruct
+ Botan.Low.X509: data X509KeyConstraints
+ Botan.Low.X509: x509KeyConstraints :: X509KeyConstraints -> CUInt
+ Botan.Low.X509: x509KeyConstraintsList :: [X509KeyConstraints] -> CUInt
- Botan.Low.X509: x509CertAllowedUsage :: X509Cert -> X509KeyConstraints -> IO Bool
+ Botan.Low.X509: x509CertAllowedUsage :: X509Cert -> [X509KeyConstraints] -> IO Bool
Files
- CHANGELOG.md +17/−0
- botan-low.cabal +3/−3
- src/Botan/Low/BlockCipher.hs +3/−3
- src/Botan/Low/Cipher.hs +3/−3
- src/Botan/Low/FPE.hs +3/−3
- src/Botan/Low/HOTP.hs +3/−3
- src/Botan/Low/Hash.hs +3/−3
- src/Botan/Low/MAC.hs +3/−3
- src/Botan/Low/MPI.hs +3/−3
- src/Botan/Low/PubKey.hs +6/−6
- src/Botan/Low/PubKey/Decrypt.hs +3/−3
- src/Botan/Low/PubKey/Encrypt.hs +3/−3
- src/Botan/Low/PubKey/KeyAgreement.hs +3/−3
- src/Botan/Low/PubKey/KeyEncapsulation.hs +6/−6
- src/Botan/Low/PubKey/Sign.hs +12/−13
- src/Botan/Low/PubKey/Verify.hs +5/−5
- src/Botan/Low/RNG.hs +2/−2
- src/Botan/Low/SRP6.hs +3/−3
- src/Botan/Low/TOTP.hs +3/−3
- src/Botan/Low/X509.hs +38/−49
- test/Test/Botan/Low/PwdHash.hs +4/−4
- test/Test/Botan/Low/RNG.hs +2/−5
- test/Test/Botan/Low/X509.hs +1/−1
CHANGELOG.md view
@@ -1,5 +1,22 @@ # Changelog +## 0.2.0.0 -- 2026-03-23++* BREAKING: change more flags from numbers into datatypes. See PR+ [#113](https://github.com/haskell-cryptography/botan/pull/113). The flag+ datatypes come with new helper functions to convert the datatype into a+ number. The changed flag types are:+ - `SigningFlags`+ - `X509KeyConstraints`+* 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 * BREAKING: remove experimental FFI code related to `x509`. See PR
botan-low.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: botan-low-version: 0.1.0.0+version: 0.2.0.0 synopsis: Low-level Botan bindings description: Welcome to botan-low@@ -50,7 +50,7 @@ type: git location: https://github.com/haskell-cryptography/botan subdir: botan-low- tag: botan-low-0.1.0.0+ tag: botan-low-0.2.0.0 common warnings ghc-options:@@ -128,7 +128,7 @@ build-depends: base >=4.16 && <4.22,- botan-bindings ^>=0.2,+ botan-bindings ^>=0.3, bytestring >=0.11 && <0.13, deepseq >=1.1 && <2, text >=1.2 && <1.3 || >=2.0 && <2.2,
src/Botan/Low/BlockCipher.hs view
@@ -189,7 +189,7 @@ -------------------------------------------------------------------------------} -- | A mutable block cipher object-newtype BlockCipher = MkBlockCipher { getBlockCipherForeignPtr :: ForeignPtr BotanBlockCipherStruct }+newtype BlockCipher = MkBlockCipher { foreignPtr :: ForeignPtr BotanBlockCipherStruct } withBlockCipher :: BlockCipher -> (BotanBlockCipher -> IO a) -> IO a -- | Destroy a block cipher object immediately@@ -197,8 +197,8 @@ createBlockCipher :: (Ptr BotanBlockCipher -> IO CInt) -> IO BlockCipher (withBlockCipher, blockCipherDestroy, createBlockCipher) = mkBindings- MkBotanBlockCipher (.runBotanBlockCipher)- MkBlockCipher (.getBlockCipherForeignPtr)+ MkBotanBlockCipher (.ptr)+ MkBlockCipher (.foreignPtr) botan_block_cipher_destroy
src/Botan/Low/Cipher.hs view
@@ -195,7 +195,7 @@ -- NOTE: This is *symmetric* ciphers For the 'raw' interface to ECB mode block ciphers, see BlockCipher.hs -newtype Cipher = MkCipher { getCipherForeignPtr :: ForeignPtr BotanCipherStruct }+newtype Cipher = MkCipher { foreignPtr :: ForeignPtr BotanCipherStruct } withCipher :: Cipher -> (BotanCipher -> IO a) -> IO a -- | Destroy the cipher object immediately@@ -203,8 +203,8 @@ createCipher :: (Ptr BotanCipher -> IO CInt) -> IO Cipher (withCipher, cipherDestroy, createCipher) = mkBindings- MkBotanCipher (.runBotanCipher)- MkCipher (.getCipherForeignPtr)+ MkBotanCipher (.ptr)+ MkCipher (.foreignPtr) botan_cipher_destroy type CipherNonce = ByteString
src/Botan/Low/FPE.hs view
@@ -73,15 +73,15 @@ -- * Format Preserving Encryption -- */ -newtype FPE = MkFPE { getFPEForeignPtr :: ForeignPtr BotanFPEStruct }+newtype FPE = MkFPE { foreignPtr :: ForeignPtr BotanFPEStruct } withFPE :: FPE -> (BotanFPE -> IO a) -> IO a fpeDestroy :: FPE -> IO () createFPE :: (Ptr BotanFPE -> IO CInt) -> IO FPE (withFPE, fpeDestroy, createFPE) = mkBindings- MkBotanFPE (.runBotanFPE)- MkFPE (.getFPEForeignPtr)+ MkBotanFPE (.ptr)+ MkFPE (.foreignPtr) botan_fpe_destroy data FPEFlags =
src/Botan/Low/HOTP.hs view
@@ -166,15 +166,15 @@ -} -newtype HOTP = MkHOTP { getHOTPForeignPtr :: ForeignPtr BotanHOTPStruct }+newtype HOTP = MkHOTP { foreignPtr :: ForeignPtr BotanHOTPStruct } withHOTP :: HOTP -> (BotanHOTP -> IO a) -> IO a hotpDestroy :: HOTP -> IO () createHOTP :: (Ptr BotanHOTP -> IO CInt) -> IO HOTP (withHOTP, hotpDestroy, createHOTP) = mkBindings- MkBotanHOTP (.runBotanHOTP)- MkHOTP (.getHOTPForeignPtr)+ MkBotanHOTP (.ptr)+ MkHOTP (.foreignPtr) botan_hotp_destroy type HOTPHashName = HashName
src/Botan/Low/Hash.hs view
@@ -139,15 +139,15 @@ -} -newtype Hash = MkHash { getHashForeignPtr :: ForeignPtr BotanHashStruct }+newtype Hash = MkHash { foreignPtr :: ForeignPtr BotanHashStruct } withHash :: Hash -> (BotanHash -> IO a) -> IO a hashDestroy :: Hash -> IO () createHash :: (Ptr BotanHash -> IO CInt) -> IO Hash (withHash, hashDestroy, createHash) = mkBindings- MkBotanHash (.runBotanHash)- MkHash (.getHashForeignPtr)+ MkBotanHash (.ptr)+ MkHash (.foreignPtr) botan_hash_destroy type HashName = ByteString
src/Botan/Low/MAC.hs view
@@ -162,15 +162,15 @@ -- * Message Authentication type -- */ -newtype MAC = MkMAC { getMACForeignPtr :: ForeignPtr BotanMACStruct }+newtype MAC = MkMAC { foreignPtr :: ForeignPtr BotanMACStruct } withMAC :: MAC -> (BotanMAC -> IO a) -> IO a macDestroy :: MAC -> IO () createMAC :: (Ptr BotanMAC -> IO CInt) -> IO MAC (withMAC, macDestroy, createMAC) = mkBindings- MkBotanMAC (.runBotanMAC)- MkMAC (.getMACForeignPtr)+ MkBotanMAC (.ptr)+ MkMAC (.foreignPtr) botan_mac_destroy type MACName = ByteString
src/Botan/Low/MPI.hs view
@@ -85,15 +85,15 @@ -- NOTE: This whole module is not idiomatic - some methods mutate, some have a destination argument -- It will need furter wrapping. -newtype MP = MkMP { getMPForeignPtr :: ForeignPtr BotanMPStruct }+newtype MP = MkMP { foreignPtr :: ForeignPtr BotanMPStruct } withMP :: MP -> (BotanMP -> IO a) -> IO a mpDestroy :: MP -> IO () createMP :: (Ptr BotanMP -> IO CInt) -> IO MP (withMP, mpDestroy, createMP) = mkBindings- MkBotanMP (.runBotanMP)- MkMP (.getMPForeignPtr)+ MkBotanMP (.ptr)+ MkMP (.foreignPtr) botan_mp_destroy mpInit :: IO MP
src/Botan/Low/PubKey.hs view
@@ -281,15 +281,15 @@ -- * Public/private key creation, import, ... -- */ -newtype PrivKey = MkPrivKey { getPrivKeyForeignPtr :: ForeignPtr BotanPrivKeyStruct }+newtype PrivKey = MkPrivKey { foreignPtr :: ForeignPtr BotanPrivKeyStruct } withPrivKey :: PrivKey -> (BotanPrivKey -> IO a) -> IO a privKeyDestroy :: PrivKey -> IO () createPrivKey :: (Ptr BotanPrivKey -> IO CInt) -> IO PrivKey (withPrivKey, privKeyDestroy, createPrivKey) = mkBindings- MkBotanPrivKey (.runBotanPrivKey)- MkPrivKey (.getPrivKeyForeignPtr)+ MkBotanPrivKey (.ptr)+ MkPrivKey (.foreignPtr) botan_privkey_destroy type PKName = ByteString@@ -672,15 +672,15 @@ -- -> IO ByteString -- privKeyExportEncryptedPBKDFIter = undefined -newtype PubKey = MkPubKey { getPubKeyForeignPtr :: ForeignPtr BotanPubKeyStruct }+newtype PubKey = MkPubKey { foreignPtr :: ForeignPtr BotanPubKeyStruct } withPubKey :: PubKey -> (BotanPubKey -> IO a) -> IO a pubKeyDestroy :: PubKey -> IO () createPubKey :: (Ptr BotanPubKey -> IO CInt) -> IO PubKey (withPubKey, pubKeyDestroy, createPubKey) = mkBindings- MkBotanPubKey (.runBotanPubKey)- MkPubKey (.getPubKeyForeignPtr)+ MkBotanPubKey (.ptr)+ MkPubKey (.foreignPtr) botan_pubkey_destroy pubKeyLoad
src/Botan/Low/PubKey/Decrypt.hs view
@@ -41,15 +41,15 @@ -- * Public Key Decryption -- */ -newtype Decrypt = MkDecrypt { getDecryptForeignPtr :: ForeignPtr BotanPKOpDecryptStruct }+newtype Decrypt = MkDecrypt { foreignPtr :: ForeignPtr BotanPKOpDecryptStruct } withDecrypt :: Decrypt -> (BotanPKOpDecrypt -> IO a) -> IO a decryptDestroy :: Decrypt -> IO () createDecrypt :: (Ptr BotanPKOpDecrypt -> IO CInt) -> IO Decrypt (withDecrypt, decryptDestroy, createDecrypt) = mkBindings- MkBotanPKOpDecrypt (.runBotanPKOpDecrypt)- MkDecrypt (.getDecryptForeignPtr)+ MkBotanPKOpDecrypt (.ptr)+ MkDecrypt (.foreignPtr) botan_pk_op_decrypt_destroy decryptCreate
src/Botan/Low/PubKey/Encrypt.hs view
@@ -42,15 +42,15 @@ -- * Public Key Encryption -- */ -newtype Encrypt = MkEncrypt { getEncryptForeignPtr :: ForeignPtr BotanPKOpEncryptStruct }+newtype Encrypt = MkEncrypt { foreignPtr :: ForeignPtr BotanPKOpEncryptStruct } withEncrypt :: Encrypt -> (BotanPKOpEncrypt -> IO a) -> IO a encryptDestroy :: Encrypt -> IO () createEncrypt :: (Ptr BotanPKOpEncrypt -> IO CInt) -> IO Encrypt (withEncrypt, encryptDestroy, createEncrypt) = mkBindings- MkBotanPKOpEncrypt (.runBotanPKOpEncrypt)- MkEncrypt (.getEncryptForeignPtr)+ MkBotanPKOpEncrypt (.ptr)+ MkEncrypt (.foreignPtr) botan_pk_op_encrypt_destroy encryptCreate
src/Botan/Low/PubKey/KeyAgreement.hs view
@@ -115,15 +115,15 @@ -} -newtype KeyAgreement = MkKeyAgreement { getKeyAgreementForeignPtr :: ForeignPtr BotanPKOpKeyAgreementStruct }+newtype KeyAgreement = MkKeyAgreement { foreignPtr :: ForeignPtr BotanPKOpKeyAgreementStruct } withKeyAgreement :: KeyAgreement -> (BotanPKOpKeyAgreement -> IO a) -> IO a keyAgreementDestroy :: KeyAgreement -> IO () createKeyAgreement :: (Ptr BotanPKOpKeyAgreement -> IO CInt) -> IO KeyAgreement (withKeyAgreement, keyAgreementDestroy, createKeyAgreement) = mkBindings- MkBotanPKOpKeyAgreement (.runBotanPKOpKeyAgreement)- MkKeyAgreement (.getKeyAgreementForeignPtr)+ MkBotanPKOpKeyAgreement (.ptr)+ MkKeyAgreement (.foreignPtr) botan_pk_op_key_agreement_destroy -- NOTE: Silently uses the system RNG
src/Botan/Low/PubKey/KeyEncapsulation.hs view
@@ -120,15 +120,15 @@ type KEMSharedKey = ByteString type KEMEncapsulatedKey = ByteString -newtype KEMEncrypt = MkKEMEncrypt { getKEMEncryptForeignPtr :: ForeignPtr BotanPKOpKEMEncryptStruct }+newtype KEMEncrypt = MkKEMEncrypt { foreignPtr :: ForeignPtr BotanPKOpKEMEncryptStruct } withKEMEncrypt :: KEMEncrypt -> (BotanPKOpKEMEncrypt -> IO a) -> IO a kemEncryptDestroy :: KEMEncrypt -> IO () createKEMEncrypt :: (Ptr BotanPKOpKEMEncrypt -> IO CInt) -> IO KEMEncrypt (withKEMEncrypt, kemEncryptDestroy, createKEMEncrypt) = mkBindings- MkBotanPKOpKEMEncrypt (.runBotanPKOpKEMEncrypt)- MkKEMEncrypt (.getKEMEncryptForeignPtr)+ MkBotanPKOpKEMEncrypt (.ptr)+ MkKEMEncrypt (.foreignPtr) botan_pk_op_kem_encrypt_destroy @@ -191,15 +191,15 @@ encapPtr encapSzPtr -newtype KEMDecrypt = MkKEMDecrypt { getKEMDecryptForeignPtr :: ForeignPtr BotanPKOpKEMDecryptStruct }+newtype KEMDecrypt = MkKEMDecrypt { foreignPtr :: ForeignPtr BotanPKOpKEMDecryptStruct } withKEMDecrypt :: KEMDecrypt -> (BotanPKOpKEMDecrypt -> IO a) -> IO a kemDecryptDestroy :: KEMDecrypt -> IO () createKEMDecrypt :: (Ptr BotanPKOpKEMDecrypt -> IO CInt) -> IO KEMDecrypt (withKEMDecrypt, kemDecryptDestroy, createKEMDecrypt) = mkBindings- MkBotanPKOpKEMDecrypt (.runBotanPKOpKEMDecrypt)- MkKEMDecrypt (.getKEMDecryptForeignPtr)+ MkBotanPKOpKEMDecrypt (.ptr)+ MkKEMDecrypt (.foreignPtr) botan_pk_op_kem_decrypt_destroy kemDecryptCreate
src/Botan/Low/PubKey/Sign.hs view
@@ -13,9 +13,8 @@ -- * Public key signatures Sign(..)- , SigningFlags- , pattern StandardFormatSignature- , pattern DERFormatSignature+ , SigningFlags (..)+ , signingFlags , withSign , signCreate , signDestroy@@ -47,24 +46,24 @@ -- * Signature Generation -- */ -newtype Sign = MkSign { getSignForeignPtr :: ForeignPtr BotanPKOpSignStruct }+newtype Sign = MkSign { foreignPtr :: ForeignPtr BotanPKOpSignStruct } withSign :: Sign -> (BotanPKOpSign -> IO a) -> IO a signDestroy :: Sign -> IO () createSign :: (Ptr BotanPKOpSign -> IO CInt) -> IO Sign (withSign, signDestroy, createSign) = mkBindings- MkBotanPKOpSign (.runBotanPKOpSign)- MkSign (.getSignForeignPtr)+ MkBotanPKOpSign (.ptr)+ MkSign (.foreignPtr) botan_pk_op_sign_destroy -type SigningFlags = Word32+data SigningFlags =+ StandardFormatSignature+ | DERFormatSignature -pattern StandardFormatSignature -- ^ Not an actual flags- , DERFormatSignature- :: SigningFlags-pattern StandardFormatSignature = BOTAN_PUBKEY_STD_FORMAT_SIGNATURE-pattern DERFormatSignature = BOTAN_PUBKEY_DER_FORMAT_SIGNATURE+signingFlags :: SigningFlags -> Word32+signingFlags StandardFormatSignature = BOTAN_PUBKEY_STD_FORMAT_SIGNATURE+signingFlags DERFormatSignature = BOTAN_PUBKEY_DER_FORMAT_SIGNATURE signCreate :: PrivKey -- ^ __key__@@ -77,7 +76,7 @@ out skPtr (ConstPtr algoPtr)- flags+ (signingFlags flags) signOutputLength :: Sign -- ^ __op__
src/Botan/Low/PubKey/Verify.hs view
@@ -26,7 +26,7 @@ import Botan.Low.Error.Internal import Botan.Low.Internal.ByteString import Botan.Low.PubKey-import Botan.Low.PubKey.Sign (SigningFlags)+import Botan.Low.PubKey.Sign (SigningFlags, signingFlags) import Botan.Low.Remake import Data.ByteString (ByteString) import Foreign.C.Types@@ -37,15 +37,15 @@ -- * Signature Verification -- */ -newtype Verify = MkVerify { getVerifyForeignPtr :: ForeignPtr BotanPKOpVerifyStruct }+newtype Verify = MkVerify { foreignPtr :: ForeignPtr BotanPKOpVerifyStruct } withVerify :: Verify -> (BotanPKOpVerify -> IO a) -> IO a verifyDestroy :: Verify -> IO () createVerify :: (Ptr BotanPKOpVerify -> IO CInt) -> IO Verify (withVerify, verifyDestroy, createVerify) = mkBindings- MkBotanPKOpVerify (.runBotanPKOpVerify)- MkVerify (.getVerifyForeignPtr)+ MkBotanPKOpVerify (.ptr)+ MkVerify (.foreignPtr) botan_pk_op_verify_destroy verifyCreate@@ -59,7 +59,7 @@ out pkPtr (ConstPtr algoPtr)- flags+ (signingFlags flags) verifyUpdate :: Verify -- ^ __op__
src/Botan/Low/RNG.hs view
@@ -90,14 +90,14 @@ -- NOTE: Uses ConstPtr / unConstPtr manually -- TODO: Take advantage of Remake / better peek / (peekConst or constPeek) functions -newtype RNG = MkRNG { getRNGForeignPtr :: ForeignPtr BotanRNGStruct }+newtype RNG = MkRNG { foreignPtr :: ForeignPtr BotanRNGStruct } withRNG :: RNG -> (BotanRNG -> IO a) -> IO a -- | Destroy a random number generator object immediately rngDestroy :: RNG -> IO () createRNG :: (Ptr BotanRNG -> IO CInt) -> IO RNG (withRNG, rngDestroy, createRNG)- = mkBindings MkBotanRNG (.runBotanRNG) MkRNG (.getRNGForeignPtr) botan_rng_destroy+ = mkBindings MkBotanRNG (.ptr) MkRNG (.foreignPtr) botan_rng_destroy type RNGType = ByteString
src/Botan/Low/SRP6.hs view
@@ -276,7 +276,7 @@ type SRP6AValue = ByteString type SRP6SharedSecret = ByteString -newtype SRP6ServerSession = MkSRP6ServerSession { getSRP6ServerSessionForeignPtr :: ForeignPtr BotanSRP6ServerSessionStruct }+newtype SRP6ServerSession = MkSRP6ServerSession { foreignPtr :: ForeignPtr BotanSRP6ServerSessionStruct } withSRP6ServerSession :: SRP6ServerSession -> (BotanSRP6ServerSession -> IO a) -> IO a -- | Frees all resources of the SRP-6 server session object@@ -284,8 +284,8 @@ createSRP6ServerSession :: (Ptr BotanSRP6ServerSession -> IO CInt) -> IO SRP6ServerSession (withSRP6ServerSession, srp6ServerSessionDestroy, createSRP6ServerSession) = mkBindings- MkBotanSRP6ServerSession (.runBotanSRP6ServerSession)- MkSRP6ServerSession (.getSRP6ServerSessionForeignPtr)+ MkBotanSRP6ServerSession (.ptr)+ MkSRP6ServerSession (.foreignPtr) botan_srp6_server_session_destroy -- | Initialize an SRP-6 server session object
src/Botan/Low/TOTP.hs view
@@ -160,15 +160,15 @@ -} -newtype TOTP = MkTOTP { getTOTPForeignPtr :: ForeignPtr BotanTOTPStruct }+newtype TOTP = MkTOTP { foreignPtr :: ForeignPtr BotanTOTPStruct } withTOTP :: TOTP -> (BotanTOTP -> IO a) -> IO a totpDestroy :: TOTP -> IO () createTOTP :: (Ptr BotanTOTP -> IO CInt) -> IO TOTP (withTOTP, totpDestroy, createTOTP) = mkBindings- MkBotanTOTP (.runBotanTOTP)- MkTOTP (.getTOTPForeignPtr)+ MkBotanTOTP (.ptr)+ MkTOTP (.foreignPtr) botan_totp_destroy type TOTPHashName = HashName
src/Botan/Low/X509.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE CPP #-}+ {-| Module : Botan.Low.X509 Description : X.509 Certificates and CRLs@@ -49,17 +51,9 @@ -- * X509 Key constraints - , X509KeyConstraints- , pattern NoConstraints- , pattern DigitalSignature- , pattern NonRepudiation- , pattern KeyEncipherment- , pattern DataEncipherment- , pattern KeyAgreement- , pattern KeyCertSign- , pattern CRLSign- , pattern EncipherOnly- , pattern DecipherOnly+ , X509KeyConstraints (..)+ , x509KeyConstraints+ , x509KeyConstraintsList -- * X509 Certificate revocation list @@ -85,6 +79,7 @@ import Botan.Low.PubKey import Botan.Low.Remake import Control.Monad+import Data.Bits import Data.ByteString (ByteString, packCString) import qualified Data.ByteString.Char8 as Char8 import Data.Word@@ -104,14 +99,14 @@ type DistinguishedName = ByteString -newtype X509Cert = MkX509Cert { getX509CertForeignPtr :: ForeignPtr BotanX509CertStruct }+newtype X509Cert = MkX509Cert { foreignPtr :: ForeignPtr BotanX509CertStruct } withX509Cert :: X509Cert -> (BotanX509Cert -> IO a) -> IO a -- | Destroy an x509 cert object immediately x509CertDestroy :: X509Cert -> IO () createX509Cert :: (Ptr BotanX509Cert -> IO CInt) -> IO X509Cert (withX509Cert, x509CertDestroy, createX509Cert)- = mkBindings MkBotanX509Cert (.runBotanX509Cert) MkX509Cert (.getX509CertForeignPtr) botan_x509_cert_destroy+ = mkBindings MkBotanX509Cert (.ptr) MkX509Cert (.foreignPtr) botan_x509_cert_destroy x509CertLoad :: ByteString -- ^ __cert[]__@@ -241,40 +236,34 @@ -- only be present if at least one of the bits is set, and -- usage is unrestricted if the extension is not present. -- That is, it is an optional restriction.--- pattern NoConstraints = BOTAN_X509_CERT_KEY_CONSTRAINTS_NO_CONSTRAINTS--- pattern DigitalSignature = BOTAN_X509_CERT_KEY_CONSTRAINTS_DIGITAL_SIGNATURE--- pattern NonRepudiation = BOTAN_X509_CERT_KEY_CONSTRAINTS_NON_REPUDIATION--- pattern KeyEncipherment = BOTAN_X509_CERT_KEY_CONSTRAINTS_KEY_ENCIPHERMENT--- pattern DataEncipherment = BOTAN_X509_CERT_KEY_CONSTRAINTS_DATA_ENCIPHERMENT--- pattern KeyAgreement = BOTAN_X509_CERT_KEY_CONSTRAINTS_KEY_AGREEMENT--- pattern KeyCertSign = BOTAN_X509_CERT_KEY_CONSTRAINTS_KEY_CERT_SIGN--- pattern CRLSign = BOTAN_X509_CERT_KEY_CONSTRAINTS_CRL_SIGN--- pattern EncipherOnly = BOTAN_X509_CERT_KEY_CONSTRAINTS_ENCIPHER_ONLY--- pattern DecipherOnly = BOTAN_X509_CERT_KEY_CONSTRAINTS_DECIPHER_ONLY-type X509KeyConstraints = CUInt+data X509KeyConstraints =+ NoConstraints+ | DigitalSignature+ | NonRepudiation+ | KeyEncipherment+ | DataEncipherment+ | KeyAgreement+ | KeyCertSign+ | CRLSign+ | EncipherOnly+ | DecipherOnly -pattern NoConstraints- , DigitalSignature- , NonRepudiation- , KeyEncipherment- , DataEncipherment- , KeyAgreement- , KeyCertSign- , CRLSign- , EncipherOnly- , DecipherOnly- :: X509KeyConstraints-pattern NoConstraints = NO_CONSTRAINTS-pattern DigitalSignature = DIGITAL_SIGNATURE-pattern NonRepudiation = NON_REPUDIATION-pattern KeyEncipherment = KEY_ENCIPHERMENT-pattern DataEncipherment = DATA_ENCIPHERMENT-pattern KeyAgreement = KEY_AGREEMENT-pattern KeyCertSign = KEY_CERT_SIGN-pattern CRLSign = CRL_SIGN-pattern EncipherOnly = ENCIPHER_ONLY-pattern DecipherOnly = DECIPHER_ONLY+x509KeyConstraints :: X509KeyConstraints -> CUInt+x509KeyConstraints NoConstraints = NO_CONSTRAINTS+x509KeyConstraints DigitalSignature = DIGITAL_SIGNATURE+x509KeyConstraints NonRepudiation = NON_REPUDIATION+x509KeyConstraints KeyEncipherment = KEY_ENCIPHERMENT+x509KeyConstraints DataEncipherment = DATA_ENCIPHERMENT+x509KeyConstraints KeyAgreement = KEY_AGREEMENT+x509KeyConstraints KeyCertSign = KEY_CERT_SIGN+x509KeyConstraints CRLSign = CRL_SIGN+x509KeyConstraints EncipherOnly = ENCIPHER_ONLY+x509KeyConstraints DecipherOnly = DECIPHER_ONLY +x509KeyConstraintsList :: [X509KeyConstraints] -> CUInt+x509KeyConstraintsList [] = x509KeyConstraints NoConstraints+x509KeyConstraintsList (kc:kcs) = x509KeyConstraints kc .|. x509KeyConstraintsList kcs+ -- | -- -- NOTE: This function lacks documentation, and it is unknown whether this is@@ -284,11 +273,11 @@ -- Note: unexplained function, best-guess implementation x509CertAllowedUsage :: X509Cert -- ^ __cert__- -> X509KeyConstraints -- ^ __key_usage__+ -> [X509KeyConstraints] -- ^ __key_usage__ -> IO Bool x509CertAllowedUsage cert usage = withX509Cert cert $ \ certPtr ->- throwBotanCatchingInvalidVerifier $ botan_x509_cert_allowed_usage certPtr usage+ throwBotanCatchingInvalidVerifier $ botan_x509_cert_allowed_usage certPtr (x509KeyConstraintsList usage) {- | Check if the certificate matches the specified hostname via alternative name or CN match.@@ -365,13 +354,13 @@ -- TODO: Move to Botan.Low.X509.CRL after merging extended FFI -newtype X509CRL = MkX509CRL { getX509CRLForeignPtr :: ForeignPtr BotanX509CRLStruct }+newtype X509CRL = MkX509CRL { foreignPtr :: ForeignPtr BotanX509CRLStruct } withX509CRL :: X509CRL -> (BotanX509CRL -> IO a) -> IO a x509CRLDestroy :: X509CRL -> IO () createX509CRL :: (Ptr BotanX509CRL -> IO CInt) -> IO X509CRL (withX509CRL, x509CRLDestroy, createX509CRL)- = mkBindings MkBotanX509CRL (.runBotanX509CRL) MkX509CRL (.getX509CRLForeignPtr) botan_x509_crl_destroy+ = mkBindings MkBotanX509CRL (.ptr) MkX509CRL (.foreignPtr) botan_x509_crl_destroy x509CRLLoad :: ByteString -- ^ __crl_bits[]__
test/Test/Botan/Low/PwdHash.hs view
@@ -36,10 +36,10 @@ -------------------------------------------------------------------------------} data TestParams = TestParams {- testPbkdfName :: PBKDFName- , testIterationsParam :: Int- , testParallelismParam :: Int- , testMemoryParam :: Int+ pbkdfName :: PBKDFName+ , iterationsParam :: Int+ , parallelismParam :: Int+ , memoryParam :: Int } deriving stock (Show, Eq)
test/Test/Botan/Low/RNG.hs view
@@ -16,11 +16,6 @@ specs <- testSpec "spec_rng" spec_rng pure $ testGroup "Test.Botan.Low.RNG" [ specs-#ifdef darwin_HOST_OS- -- TODO: temporarily disabled because the test suite fails. See issue- -- #33.- | False-#endif ] rngs :: [RNGType]@@ -28,7 +23,9 @@ [ SystemRNG , UserRNG , UserThreadsafeRNG+#if x86_64_HOST_ARCH , RDRandRNG -- NOTES: Not available on all processors+#endif ] spec_rng :: Spec
test/Test/Botan/Low/X509.hs view
@@ -152,7 +152,7 @@ pass it "x509CertAllowedUsage" $ do cert <- x509CertLoad testCert- _allowed <- x509CertAllowedUsage cert NoConstraints+ _allowed <- x509CertAllowedUsage cert [] pass it "x509CertHostnameMatch" $ do cert <- x509CertLoad testCert