{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (garetxe@gmail.com) An opaque structure representing a HMAC operation. To create a new GHmac, use g_hmac_new(). To free a GHmac, use g_hmac_unref(). -} module GI.GLib.Structs.Hmac ( -- * Exported types Hmac(..) , noHmac , -- * Methods -- ** hmacGetDigest hmacGetDigest , -- ** hmacGetString hmacGetString , -- ** hmacUnref hmacUnref , -- ** hmacUpdate hmacUpdate , ) where import Prelude () import Data.GI.Base.ShortPrelude import qualified Data.Text as T import qualified Data.ByteString.Char8 as B import qualified Data.Map as Map import GI.GLib.Types import GI.GLib.Callbacks newtype Hmac = Hmac (ForeignPtr Hmac) noHmac :: Maybe Hmac noHmac = Nothing -- method Hmac::get_digest -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Hmac", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "buffer", argType = TBasicType TUInt8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "digest_len", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Hmac", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "buffer", argType = TBasicType TUInt8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "digest_len", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TVoid -- throws : False -- Skip return : False foreign import ccall "g_hmac_get_digest" g_hmac_get_digest :: Ptr Hmac -> -- _obj : TInterface "GLib" "Hmac" Word8 -> -- buffer : TBasicType TUInt8 Word64 -> -- digest_len : TBasicType TUInt64 IO () hmacGetDigest :: (MonadIO m) => Hmac -> -- _obj Word8 -> -- buffer Word64 -> -- digest_len m () hmacGetDigest _obj buffer digest_len = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj g_hmac_get_digest _obj' buffer digest_len touchManagedPtr _obj return () -- method Hmac::get_string -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Hmac", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Hmac", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TUTF8 -- throws : False -- Skip return : False foreign import ccall "g_hmac_get_string" g_hmac_get_string :: Ptr Hmac -> -- _obj : TInterface "GLib" "Hmac" IO CString hmacGetString :: (MonadIO m) => Hmac -> -- _obj m T.Text hmacGetString _obj = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj result <- g_hmac_get_string _obj' checkUnexpectedReturnNULL "g_hmac_get_string" result result' <- cstringToText result touchManagedPtr _obj return result' -- method Hmac::unref -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Hmac", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Hmac", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TVoid -- throws : False -- Skip return : False foreign import ccall "g_hmac_unref" g_hmac_unref :: Ptr Hmac -> -- _obj : TInterface "GLib" "Hmac" IO () hmacUnref :: (MonadIO m) => Hmac -> -- _obj m () hmacUnref _obj = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj g_hmac_unref _obj' touchManagedPtr _obj return () -- method Hmac::update -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Hmac", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "data", argType = TCArray False (-1) 2 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "length", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [Arg {argName = "length", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Hmac", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "data", argType = TCArray False (-1) 2 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TVoid -- throws : False -- Skip return : False foreign import ccall "g_hmac_update" g_hmac_update :: Ptr Hmac -> -- _obj : TInterface "GLib" "Hmac" Ptr Word8 -> -- data : TCArray False (-1) 2 (TBasicType TUInt8) Int64 -> -- length : TBasicType TInt64 IO () hmacUpdate :: (MonadIO m) => Hmac -> -- _obj ByteString -> -- data m () hmacUpdate _obj data_ = liftIO $ do let length_ = fromIntegral $ B.length data_ let _obj' = unsafeManagedPtrGetPtr _obj data_' <- packByteString data_ g_hmac_update _obj' data_' length_ touchManagedPtr _obj freeMem data_' return ()