title: Aes cmac calculation in Pkcs11Interop with HSM
body: <p>I am trying to generate Aes Cmac based on a stored key on HSM with support of Pkcs11Interop, here is my logic</p>
  <pre><code>    public byte[] GenerateCmac(byte[] data, byte[] iv)
      {
          // Helper to get the session, works fine
          var session = pKCS11Connector.GetSession(SessionType.ReadWrite);
          // Helper function to get existing Aes key, works fine
          IObjectHandle obj = GetObj(session, &quot;AesKey3&quot;);
          var mechanism = session.Factories.MechanismFactory.Create(CKM.CKM_AES_CMAC, iv);
          return session.Sign(mechanism, obj, data);
      }
  </code></pre>
  <p>But I always get exception: Net.Pkcs11Interop.Common.Pkcs11Exception Method C_SignInit returned CKR_MECHANISM_PARAM_INVALID</p>
  <p>Any idea or example to follow on how to generation CMAC</p>