module Network.AWS.Signing.Internal where
import Control.Monad.IO.Class
import qualified Crypto.Hash.SHA256 as SHA256
import qualified Crypto.MAC.HMAC as HMAC
import Data.ByteString (ByteString)
import Data.Time
import Network.AWS.Types
import System.Locale
sign :: (MonadIO m, AWSRequest a, AWSSigner (Sg (Sv a)))
=> Auth
-> Region
-> Request a
-> UTCTime
-> m (Signed a (Sg (Sv a)))
sign a r rq t = withAuth a $ \e -> return $
signed e r rq defaultTimeLocale t
presign :: (MonadIO m, AWSRequest a, AWSPresigner (Sg (Sv a)))
=> Auth
-> Region
-> Request a
-> UTCTime
-> UTCTime
-> m (Signed a (Sg (Sv a)))
presign a r rq t x = withAuth a $ \e -> return $
presigned e r rq defaultTimeLocale t x
hmacSHA256 :: ByteString -> ByteString -> ByteString
hmacSHA256 = HMAC.hmac SHA256.hash 64
serviceOf :: AWSService (Sv a) => Request a -> Service (Sv a)
serviceOf = const service