summaryrefslogtreecommitdiff
path: root/src/crypto/reflibs/Crypto/MAC/Poly1305.hs
blob: 5e8938fa4ae0abd4533e4cdd2b6066a530a00b19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module Crypto.MAC.Poly1305 (
    Auth(..),
    authTag,
) where

import Crypto.Error

import Data.ByteArray as BA
import Data.ByteString (ByteString)


newtype Auth = Auth ByteString
    deriving (Eq, ByteArrayAccess)

authTag :: ByteArrayAccess b => b -> CryptoFailable Auth
authTag ba
    | BA.length bs /= 16 = CryptoFailed CryptoError
    | otherwise = CryptoPassed (Auth bs)
  where
    bs = convert ba