Tpm2Lib.AuthSession.CanEncrypt C# (CSharp) Method

CanEncrypt() private method

Checks whether the given session can be used for parameter encryption.
private CanEncrypt ( ) : bool
return bool
        internal bool CanEncrypt()
        {
            return Symmetric != null && Symmetric.Algorithm != TpmAlgId.Null;
        }

Usage Example

Example #1
0
        private void CheckParamEncSessCandidate(AuthSession candidate, SessionAttr directionFlag)
        {
            if (!candidate.Attrs.HasFlag(directionFlag))
            {
                return;
            }

            bool decrypt = directionFlag == SessionAttr.Decrypt;

            if (!_Behavior.Passthrough)
            {
                if (!candidate.CanEncrypt())
                {
                    throw new Exception(string.Format("{0} session is missing symmetric algorithm",
                                                      decrypt ? "Decryption" : "Encryption"));
                }
                if ((decrypt ? DecSession : EncSession) != null)
                {
                    throw new Exception(string.Format("Multiple {0} sessions",
                                                      decrypt ? "decryption" : "encryption"));
                }
            }
            if (decrypt)
            {
                DecSession = candidate;
            }
            else
            {
                EncSession = candidate;
            }
        }