-- |
-- Module      : Crypto.Cipher.Camellia
-- License     : BSD-style
-- Maintainer  : Vincent Hanquez <vincent@snarc.org>
-- Stability   : experimental
-- Portability : Good
--
-- Camellia support. only 128 bit variant available for now.

module Crypto.Cipher.Camellia
    ( Camellia128
    ) where

import Crypto.Cipher.Camellia.Primitive
import Crypto.Cipher.Types

-- | Camellia block cipher with 128 bit key
newtype Camellia128 = Camellia128 Camellia

instance Cipher Camellia128 where
    cipherName :: Camellia128 -> String
cipherName    Camellia128
_ = String
"Camellia128"
    cipherKeySize :: Camellia128 -> KeySizeSpecifier
cipherKeySize Camellia128
_ = Int -> KeySizeSpecifier
KeySizeFixed Int
16
    cipherInit :: forall key. ByteArray key => key -> CryptoFailable Camellia128
cipherInit key
k    = Camellia -> Camellia128
Camellia128 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` forall key. ByteArray key => key -> CryptoFailable Camellia
initCamellia key
k

instance BlockCipher Camellia128 where
    blockSize :: Camellia128 -> Int
blockSize Camellia128
_ = Int
16
    ecbEncrypt :: forall ba. ByteArray ba => Camellia128 -> ba -> ba
ecbEncrypt (Camellia128 Camellia
key) = forall ba. ByteArray ba => Camellia -> ba -> ba
encrypt Camellia
key
    ecbDecrypt :: forall ba. ByteArray ba => Camellia128 -> ba -> ba
ecbDecrypt (Camellia128 Camellia
key) = forall ba. ByteArray ba => Camellia -> ba -> ba
decrypt Camellia
key