MalwareSourceCode/MSIL/Virus/Win32/E/Virus.Win32.Expiro.w-67b630ead60119692b9abbdfd8717c96904ef041127c2cae033c86b718eaa61e/Microsoft/InfoCards/SymmetricCryptoSession.cs
2022-08-18 06:28:56 -05:00

84 lines
2.8 KiB
C#

// Decompiled with JetBrains decompiler
// Type: Microsoft.InfoCards.SymmetricCryptoSession
// Assembly: infocard, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// MVID: ADE0A079-11DB-4A46-8BDE-D2A592CA8DEA
// Assembly location: C:\Users\Administrateur\Downloads\Virusshare-00000-msil\Virus.Win32.Expiro.w-67b630ead60119692b9abbdfd8717c96904ef041127c2cae033c86b718eaa61e.exe
using Microsoft.InfoCards.Diagnostics;
using System;
using System.Diagnostics;
using System.IO;
using System.Security.Cryptography;
using System.Security.Principal;
namespace Microsoft.InfoCards
{
internal class SymmetricCryptoSession : CryptoSession
{
private SymmetricAlgorithm m_alg;
public SymmetricCryptoSession(
Process process,
DateTime expiration,
WindowsIdentity identity,
byte[] key)
: base(process, expiration, identity, (object) key, CryptoSession.SessionType.Symmetric)
{
this.m_alg = (SymmetricAlgorithm) new RijndaelManaged();
this.m_alg.Key = key;
}
protected override void OnDispose()
{
this.m_alg.Clear();
this.m_alg.Dispose();
this.m_alg = (SymmetricAlgorithm) null;
}
protected override void OnWrite(BinaryWriter bwriter)
{
bwriter.Write(this.m_alg.KeySize);
bwriter.Write(this.m_alg.BlockSize);
bwriter.Write(this.m_alg.FeedbackSize);
}
public byte[] GenerateDerivedKey(
string algorithmUri,
byte[] label,
byte[] nonce,
int derivedKeyLength,
int offset)
{
if (algorithmUri == "http://schemas.xmlsoap.org/ws/2005/02/sc/dk/p_sha1" || algorithmUri == "http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512/dk/p_sha1")
return new Psha1DerivedKeyGenerator(this.m_alg.Key).GenerateDerivedKey(label, nonce, derivedKeyLength, offset);
throw InfoCardTrace.ThrowHelperWarning((Exception) new InfoCardArgumentException(SR.GetString("ServiceUnsupportedKeyDerivationAlgorithm", (object) algorithmUri)));
}
public TransformCryptoSession GetCryptoTransform(
CipherMode mode,
PaddingMode padding,
int feedbackSize,
SymmetricCryptoSession.Direction direction,
byte[] iv)
{
this.m_alg.Mode = mode;
this.m_alg.Padding = padding;
this.m_alg.IV = iv;
return new TransformCryptoSession(this.ProcessObj, this.Expiration, this.Identity, SymmetricCryptoSession.Direction.Encrypt != direction ? this.m_alg.CreateDecryptor() : this.m_alg.CreateEncryptor());
}
public HashCryptoSession GetKeyedHash()
{
KeyedHashAlgorithm hash = (KeyedHashAlgorithm) new HMACSHA1(this.m_alg.Key);
hash.Initialize();
return new HashCryptoSession(this.ProcessObj, this.Expiration, this.Identity, hash);
}
public enum Direction
{
Encrypt = 1,
Decrypt = 2,
}
}
}