本文整理汇总了C#中IMac类的典型用法代码示例。如果您正苦于以下问题:C# IMac类的具体用法?C# IMac怎么用?C# IMac使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IMac类属于命名空间,在下文中一共展示了IMac类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoFinal
public static byte[] DoFinal(
IMac mac)
{
byte[] b = new byte[mac.GetMacSize()];
mac.DoFinal(b, 0);
return b;
}
示例2: IesEngine
/**
* set up for use with stream mode, where the key derivation function
* is used to provide a stream of bytes to xor with the message.
*
* @param agree the key agreement used as the basis for the encryption
* @param kdf the key derivation function used for byte generation
* @param mac the message authentication code generator for the message
*/
public IesEngine(IBasicAgreement agree, IDerivationFunction kdf, IMac mac)
{
_agree = agree;
_kdf = kdf;
_mac = mac;
_macBuf = new byte[mac.GetMacSize()];
// this.cipher = null;
}
示例3: MacStream
public MacStream(
Stream stream,
IMac readMac,
IMac writeMac)
{
this.stream = stream;
this.inMac = readMac;
this.outMac = writeMac;
}
示例4: NetworkLayer
public NetworkLayer(IMac mac)
{
_mac = mac;
_mgmt = new NetworkMgmt(this);
_route = new Routing(this, mac, this);
#if USE_FRAG
int mtu, head, tail;
_route.GetMtuSize(out mtu, out head, out tail);
_frag = new Fragmentation.Fragmentation(10, _route.DataRequest, mtu, head, tail);
#endif
_mac.BeaconNotifyIndication = MacBeaconNotifyIndication;
_mac.ResetRequest(true, null);
}
示例5: HMacSP800Drbg
/**
* Construct a SP800-90A Hash DRBG.
* <p>
* Minimum entropy requirement is the security strength requested.
* </p>
* @param hMac Hash MAC to base the DRBG on.
* @param securityStrength security strength required (in bits)
* @param entropySource source of entropy to use for seeding/reseeding.
* @param personalizationString personalization string to distinguish this DRBG (may be null).
* @param nonce nonce to further distinguish this DRBG (may be null).
*/
public HMacSP800Drbg(IMac hMac, int securityStrength, IEntropySource entropySource, byte[] personalizationString, byte[] nonce)
{
if (securityStrength > DrbgUtilities.GetMaxSecurityStrength(hMac))
throw new ArgumentException("Requested security strength is not supported by the derivation function");
if (entropySource.EntropySize < securityStrength)
throw new ArgumentException("Not enough entropy for security strength required");
mHMac = hMac;
mSecurityStrength = securityStrength;
mEntropySource = entropySource;
byte[] entropy = GetEntropy();
byte[] seedMaterial = Arrays.ConcatenateAll(entropy, nonce, personalizationString);
mK = new byte[hMac.GetMacSize()];
mV = new byte[mK.Length];
Arrays.Fill(mV, (byte)1);
hmac_DRBG_Update(seedMaterial);
mReseedCounter = 1;
}
示例6: testSingleByte
private void testSingleByte(IMac mac, TestCase testCase)
{
byte[] ad = testCase.getAd();
for (int i = 0; i < ad.Length; i++)
{
mac.Update(ad[i]);
}
checkMac(mac, testCase);
}
示例7: checkMac
private void checkMac(IMac mac, TestCase testCase)
{
byte[] generatedMac = new byte[mac.GetMacSize()];
mac.DoFinal(generatedMac, 0);
if (!AreEqual(testCase.getTag(), generatedMac))
{
Fail("Failed " + testCase.getName() + " - expected " + Hex.ToHexString(testCase.getTag()) + " got "
+ Hex.ToHexString(generatedMac));
}
}
示例8: testMultibyte
private void testMultibyte(IMac mac, TestCase testCase)
{
mac.BlockUpdate(testCase.getAd(), 0, testCase.getAd().Length);
checkMac(mac, testCase);
}
示例9: HMacDrbgProvider
public HMacDrbgProvider(IMac hMac, byte[] nonce, byte[] personalizationString, int securityStrength)
{
this.mHMac = hMac;
this.mNonce = nonce;
this.mPersonalizationString = personalizationString;
this.mSecurityStrength = securityStrength;
}
示例10: Routing
private AutoResetEvent _getAddressEvent; // event raised when we got an address
public Routing(INetworkLayer net, IMac mac, IDataCallbacks data)
{
_net = net;
_mac = mac;
_data = data;
_mac.GetMtuSize(out _macMtu, out _macHeader, out _macTailer);
// calculate the header sizes for 6LoWPAN
// private encapsulation requires one byte (Message.Data.cLength) additional header space
int myHeader = Messages6LoWPAN.MeshHeader.cLengthMax + Messages6LoWPAN.BroadcastHeader.cLength;
_netHeader6Low = _macHeader + myHeader;
_netMtu6Low = _macMtu - myHeader;
_netTailer6Low = _macTailer;
_neighbourTable = new NeighborTable(this, _macHeader, _macTailer);
_routingTable = new RoutingTable(this);
_messageContext = new MessageContext();
_seqNoDYMO = 0;
_seqNoBroadcast = 0;
_panId = 0;
_addrShort = cInvalidShortAddr;
_addrExt = 0; // to be set at start
_isRunning = false;
_getAddressEvent = new AutoResetEvent(false);
}
示例11: UpdateMac
private static void UpdateMac(IMac mac, byte[] bytes)
{
mac.BlockUpdate(bytes, 0, bytes.Length);
Arrays.Fill(bytes, (byte)0);
}
示例12: MacOutputStream
internal MacOutputStream(IMac mac)
{
this.mac = mac;
}
示例13: DoFinal
public static byte[] DoFinal(IMac mac, byte[] input)
{
mac.BlockUpdate(input, 0, input.Length);
return DoFinal(mac);
}
示例14: EaxBlockCipher
/**
* Constructor that accepts an instance of a block cipher engine.
*
* @param cipher the engine to use
*/
public EaxBlockCipher(
IBlockCipher cipher)
{
blockSize = cipher.GetBlockSize();
mac = new CMac(cipher);
macBlock = new byte[blockSize];
associatedTextMac = new byte[mac.GetMacSize()];
nonceMac = new byte[mac.GetMacSize()];
this.cipher = new SicBlockCipher(cipher);
}
示例15: TlsMac
/**
* Generate a new instance of an TlsMac.
*
* @param context the TLS client context
* @param digest The digest to use.
* @param key A byte-array where the key for this MAC is located.
* @param keyOff The number of bytes to skip, before the key starts in the buffer.
* @param keyLen The length of the key.
*/
public TlsMac(TlsContext context, IDigest digest, byte[] key, int keyOff, int keyLen)
{
this.context = context;
KeyParameter keyParameter = new KeyParameter(key, keyOff, keyLen);
this.secret = Arrays.Clone(keyParameter.GetKey());
// TODO This should check the actual algorithm, not rely on the engine type
if (digest is LongDigest)
{
this.digestBlockSize = 128;
this.digestOverhead = 16;
}
else
{
this.digestBlockSize = 64;
this.digestOverhead = 8;
}
if (TlsUtilities.IsSsl(context))
{
this.mac = new Ssl3Mac(digest);
// TODO This should check the actual algorithm, not assume based on the digest size
if (digest.GetDigestSize() == 20)
{
/*
* NOTE: When SHA-1 is used with the SSL 3.0 MAC, the secret + input pad is not
* digest block-aligned.
*/
this.digestOverhead = 4;
}
}
else
{
this.mac = new HMac(digest);
// NOTE: The input pad for HMAC is always a full digest block
}
this.mac.Init(keyParameter);
this.macLength = mac.GetMacSize();
if (context.SecurityParameters.truncatedHMac)
{
this.macLength = System.Math.Min(this.macLength, 10);
}
}