{-# LANGUAGE FlexibleInstances          #-}
{-# LANGUAGE MultiParamTypeClasses      #-}
{-# LANGUAGE DataKinds                  #-}
-- |
--
-- Module      : Raaz.Primitive.AEAD.Internal
-- Description : Generic interface to authenticated encryption.
-- Copyright   : (c) Piyush P Kurur, 2019
-- License     : Apache-2.0 OR BSD-3-Clause
-- Maintainer  : Piyush P Kurur <ppk@iitpkd.ac.in>
-- Stability   : experimental

module Raaz.Primitive.AEAD.Internal
       ( AEAD(..), unsafeAEAD
       ) where


import           Data.ByteString
import           Raaz.Core

-- | An authenticated encrypted packet containing a payload of type
-- @plain@ and additional authenticated data of type @aad@.
data AEAD c t = AEAD
     { forall c t. AEAD c t -> Nounce c
unsafeToNounce      :: Nounce c
                           -- ^ The nounce use to compute this packet.

     , forall c t. AEAD c t -> ByteString
unsafeToCipherText  :: ByteString
                           -- ^ The associated cipher text.

     , forall c t. AEAD c t -> t
unsafeToAuthTag     :: t
                           -- ^ The associated authentication tag.

     }

-- | Create an AEAD packet from the underlying authentication tag and
-- cipher text.
unsafeAEAD :: Nounce c
           -> ByteString
           -> t             -- ^ the authentication tag
           -> AEAD c t
unsafeAEAD :: forall c t. Nounce c -> ByteString -> t -> AEAD c t
unsafeAEAD = Nounce c -> ByteString -> t -> AEAD c t
forall c t. Nounce c -> ByteString -> t -> AEAD c t
AEAD