public KilePdu GssWrap(KileConnection kileConnection, bool isEncrypted, SGN_ALG signAlgorithm, byte[] message)
 {
     context = GetServerContextByKileConnection(kileConnection);
     return GssWrap(isEncrypted, signAlgorithm, message);
 }
 /// <summary>
 /// Decode and verify a Gss_GetMic token.
 /// </summary>
 /// <param name="kileConnection">Maintain a connection with a target client</param>
 /// <param name="token">The token got from an application message. 
 /// If this argument is null, null will be returned.</param>
 /// <param name="message">The message to be computed signature. 
 /// If this argument is null, null will be returned.</param>
 /// <param name="pdu">The decoded Gss_GetMic token.</param>
 /// <returns>If verifying mic token is successful.</returns>
 /// <exception cref="System.NotSupportedException">Thrown when the encryption is not supported.</exception>
 public bool GssVerifyMic(KileConnection kileConnection, byte[] token, byte[] message, out KilePdu pdu)
 {
     context = GetServerContextByKileConnection(kileConnection);
     return GssVerifyMic(token, message, out pdu);
 }
 public KilePdu GssGetMic(KileConnection kileConnection, SGN_ALG signAlgorithm, byte[] message)
 {
     context = GetServerContextByKileConnection(kileConnection);
     return GssGetMic(signAlgorithm, message);
 }
 /// <summary>
 /// Decode a Gss_Wrap token.
 /// </summary>
 /// <param name="kileConnection">Maintain a connection with a target client</param>
 /// <param name="token">The token got from an application message. 
 /// If this argument is null, null will be returned.</param>
 /// <returns>The decoded Gss_Wrap token.</returns>
 /// <exception cref="System.NotSupportedException">Thrown when the encryption is not supported.</exception>
 public KilePdu GssUnWrap(KileConnection kileConnection, byte[] token)
 {
     context = GetServerContextByKileConnection(kileConnection);
     return GssUnWrap(token);
 }
        public KileApResponse CreateApResponse(KileConnection kileConnection, EncryptionKey subkey)
        {
            context = GetServerContextByKileConnection(kileConnection);
            KileApResponse apResponse = CreateApResponse(subkey);

            // Set a random sequence number
            Random randomNumber = new Random();
            apResponse.ApEncPart.seq_number = new UInt32(randomNumber.Next());
            context.currentLocalSequenceNumber = (ulong)apResponse.ApEncPart.seq_number.mValue;

            return apResponse;
        }