private void GetAttributesBytes(byte[] bytes, ref int startIndex, string password, byte[] key2, CreditalsType creditalsType, byte paddingByte) { int messageStartIndex = startIndex - HeaderLength; foreach (var attribute in allAttributes) { if (attribute != null && attribute.Ignore == false) { if (attribute is MessageIntegrity) { switch (creditalsType) { case CreditalsType.ShortTerm: (attribute as MessageIntegrity).Value = ComputeShortTermMessageIntegrity(bytes, startIndex, password); break; case CreditalsType.LongTerm: (attribute as MessageIntegrity).Value = ComputeLongTermMessageIntegrity(bytes, startIndex, password); break; case CreditalsType.MsAvedgea: (attribute as MessageIntegrity).Value = ComputeMsAvedgeaMessageIntegrity(bytes, messageStartIndex, startIndex, key2, Realm.Value, MsUsername.Value); break; } } if (attribute is Fingerprint) { (attribute as Fingerprint).Value = ComputeFingerprint(bytes, startIndex); } if (attribute is XorMappedAddress) { (attribute as XorMappedAddress).GetBytes(bytes, ref startIndex, TransactionId); } else { attribute.GetBytes(bytes, ref startIndex); } if (IsAttributePaddingEnabled()) { if (startIndex % 4 > 0) { if (paddingByte != 0) { PadAttribute(paddingByte, bytes, startIndex); } startIndex += 4 - startIndex % 4; } } } } }
private byte[] GetBytes(byte[] bytes, int startIndex, string password, byte[] key2, CreditalsType creditalsType, byte paddingByte) { if (bytes == null) { ComputeMessageLength(); bytes = new byte[MessageLength + HeaderLength]; } GetHeaderBytes(bytes, ref startIndex); GetAttributesBytes(bytes, ref startIndex, password, key2, creditalsType, paddingByte); return bytes; }
private byte[] GetBytes(byte[] bytes, int startIndex, string password, byte[] key2, CreditalsType creditalsType, byte paddingByte) { if (bytes == null) { ComputeMessageLength(); bytes = new byte[MessageLength + HeaderLength]; } GetHeaderBytes(bytes, ref startIndex); GetAttributesBytes(bytes, ref startIndex, password, key2, creditalsType, paddingByte); return(bytes); }
private void GetAttributesBytes(byte[] bytes, ref int startIndex, string password, byte[] key2, CreditalsType creditalsType, byte paddingByte) { int messageStartIndex = startIndex - HeaderLength; foreach (var attribute in allAttributes) { if (attribute != null && attribute.Ignore == false) { if (attribute is MessageIntegrity) { switch (creditalsType) { case CreditalsType.ShortTerm: (attribute as MessageIntegrity).Value = ComputeShortTermMessageIntegrity(bytes, startIndex, password); break; case CreditalsType.LongTerm: (attribute as MessageIntegrity).Value = ComputeLongTermMessageIntegrity(bytes, startIndex, password); break; case CreditalsType.MsAvedgea: (attribute as MessageIntegrity).Value = ComputeMsAvedgeaMessageIntegrity(bytes, messageStartIndex, startIndex, key2, Realm.Value, MsUsername.Value); break; } } if (attribute is Fingerprint) (attribute as Fingerprint).Value = ComputeFingerprint(bytes, startIndex); if (attribute is XorMappedAddress) (attribute as XorMappedAddress).GetBytes(bytes, ref startIndex, TransactionId); else attribute.GetBytes(bytes, ref startIndex); if (IsAttributePaddingEnabled()) { if (startIndex % 4 > 0) { if (paddingByte != 0) PadAttribute(paddingByte, bytes, startIndex); startIndex += 4 - startIndex % 4; } } } } }