using NFC.Crypto; using System; namespace NFC.NXP_MIFARE_DESFire { public class CMAC { #region Contructors public CMAC(CipherType cipher) { switch(cipher) { case(CipherType.TDES): _Cipher = new TDES(); break; case(CipherType.TDES_2K): _Cipher = new TDES_2K(); break; case(CipherType.TDES_3K): _Cipher = new TDES_3K(); break; case (CipherType.AES): _Cipher = new AES(); break; default: throw new ArgumentException("Unkown Cipher Type."); } } public CMAC(ICipher cipher) { _Cipher = cipher ?? throw new ArgumentNullException(); } #endregion #region Properties private ICipher _Cipher; #endregion #region Methods /// <summary> /// Generate Key with all Zeros, in KeySize /// </summary> public byte[] GenerateEmpytKey() { byte[] key = new byte[_Cipher.KeySize]; for (int i = 0; i < _Cipher.KeySize; i++) { key[i] = 0; } return key; } /// <summary> /// Generate IV with all Zeros, in KeySize /// </summary> public byte[] GenerateEmpytIV() { byte[] key = new byte[_Cipher.BlockSize]; for (int i = 0; i < _Cipher.BlockSize; i++) { key[i] = 0; } return key; } /// <summary> /// Encrypt Data /// </summary> public byte[] Encrypt(byte[] data) { throw new NotImplementedException(); } /// <summary> /// Decrypt Data /// </summary> public byte[] Decrypt(byte[] data) { throw new NotImplementedException(); } /// <summary> /// /// </summary> /// <returns>Two Keys</returns> public byte[][] GenerateSubKey() { throw new NotImplementedException(); } /// <summary> /// /// </summary> /// <param name="data"></param> /// <returns></returns> public byte[] Digest(byte[] data) { throw new NotImplementedException(); } #endregion } }