public int StartAuth(Device device, Key parentKey, TPM2_Alg algMode) { int rc; /* Algorithm modes: With parameter encryption use CFB or XOR. * For HMAC only (no parameter encryption) use NULL. */ if (algMode != TPM2_Alg.NULL && algMode != TPM2_Alg.CFB && algMode != TPM2_Alg.XOR) { return((int)Status.BAD_FUNC_ARG); } /* Start an authenticated session (salted / unbound) with * parameter encryption */ rc = device.StartSession(this, parentKey, IntPtr.Zero, (byte)SE.HMAC, (int)algMode); if (rc == (int)Status.TPM_RC_SUCCESS) { /* Set session for authorization of the primary key */ rc = device.SetAuthSession(this, this.sessionIdx, (byte)(SESSION_mask.decrypt | SESSION_mask.encrypt | SESSION_mask.continueSession)); } if (rc != (int)Status.TPM_RC_SUCCESS) { throw new WolfTpm2Exception("StartAuth", rc); } return(rc); }
public int GetKeyTemplate_ECC(ulong objectAttributes, TPM2_ECC curve, TPM2_Alg sigScheme) { int rc = wolfTPM2_GetKeyTemplate_ECC(template, objectAttributes, (uint)curve, (uint)sigScheme); if (rc != (int)Status.TPM_RC_SUCCESS) { throw new WolfTpm2Exception( "wolfTPM2_GetKeyTemplate_ECC", rc); } return(rc); }
public int GetKeyTemplate_Symmetric(int keyBits, TPM2_Alg algMode, bool isSign, bool isDecrypt) { int rc = wolfTPM2_GetKeyTemplate_Symmetric(template, keyBits, (uint)algMode, isSign ? 1 : 0, isDecrypt ? 1 : 0); if (rc != (int)Status.TPM_RC_SUCCESS) { throw new WolfTpm2Exception( "wolfTPM2_GetKeyTemplate_Symmetric", rc); } return(rc); }