private void Init() { EncryptedKey = null; MacKey = null; _maskKey = null; }
public override void Decode(Asn1BerDecodeBuffer buffer, bool explicitTagging, int implicitLength) { var elemLength = explicitTagging ? MatchTag(buffer, Asn1Tag.Sequence) : implicitLength; Init(); var context = new Asn1BerDecodeContext(buffer, elemLength); var parsedLen = new IntHolder(); if (!context.MatchElemTag(0, 0, OctetStringTypeCode, parsedLen, false)) { throw ExceptionUtility.CryptographicException(Resources.Asn1MissingRequiredException, buffer.ByteCount); } EncryptedKey = new Gost2814789Key(); EncryptedKey.Decode(buffer, true, parsedLen.Value); if (context.MatchElemTag(0x80, 0, EocTypeCode, parsedLen, true)) { _maskKey = new Gost2814789Key(); _maskKey.Decode(buffer, false, parsedLen.Value); } if (!context.MatchElemTag(0, 0, OctetStringTypeCode, parsedLen, false)) { throw ExceptionUtility.CryptographicException(Resources.Asn1MissingRequiredException, buffer.ByteCount); } MacKey = new Gost2814789Mac(); MacKey.Decode(buffer, true, parsedLen.Value); if (MacKey.Length != 4) { throw ExceptionUtility.CryptographicException(Resources.Asn1ConsVioException, "MacKey.Length", MacKey.Length); } }