mirror of
https://github.com/vxunderground/MalwareSourceCode.git
synced 2024-12-22 19:36:11 +00:00
f2ac1ece55
add
84 lines
2.8 KiB
C#
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: 1D4D5564-A025-490C-AF1D-DF4FBB709D1F
|
|
// Assembly location: C:\Users\Administrateur\Downloads\Virusshare-00001-msil\Virus.Win32.Expiro.w-f8f9f26e940480624825f6bddbea86e70fc4aa746c4dd8efa7d98dcb477000ed.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,
|
|
}
|
|
}
|
|
}
|