public override void Decode(Asn1BerDecodeBuffer buffer, bool explicitTagging, int implicitLength) { var elemLength = explicitTagging ? MatchTag(buffer, Asn1Tag.Sequence) : implicitLength; DigestParamSet = null; PublicKeyParamSet = null; EncryptionParamSet = null; var context = new Asn1BerDecodeContext(buffer, elemLength); var parsedLen = new IntHolder(); if (!context.MatchElemTag(0, 0, ObjectIdentifierTypeCode, parsedLen, false)) { throw ExceptionUtility.CryptographicException(Resources.Asn1MissingRequiredException, buffer.ByteCount); } PublicKeyParamSet = new Asn1ObjectIdentifier(); PublicKeyParamSet.Decode(buffer, true, parsedLen.Value); if (!context.MatchElemTag(0, 0, ObjectIdentifierTypeCode, parsedLen, false)) { throw ExceptionUtility.CryptographicException(Resources.Asn1MissingRequiredException, buffer.ByteCount); } DigestParamSet = new Asn1ObjectIdentifier(); DigestParamSet.Decode(buffer, true, parsedLen.Value); if (context.MatchElemTag(0, 0, ObjectIdentifierTypeCode, parsedLen, false)) { EncryptionParamSet = new Gost_28147_89_ParamSet(); EncryptionParamSet.Decode(buffer, true, parsedLen.Value); } }
public override void Decode(Asn1BerDecodeBuffer buffer, bool explicitTagging, int implicitLength) { var elemLength = explicitTagging ? MatchTag(buffer, Asn1Tag.Sequence) : implicitLength; EncryptionParamSet = null; EphemeralPublicKey = null; Ukm = null; var context = new Asn1BerDecodeContext(buffer, elemLength); var parsedLen = new IntHolder(); if (!context.MatchElemTag(0, 0, ObjectIdentifierTypeCode, parsedLen, false)) { throw ExceptionUtility.CryptographicException(Resources.Asn1MissingRequiredException, buffer.ByteCount); } EncryptionParamSet = new Gost_28147_89_ParamSet(); EncryptionParamSet.Decode(buffer, true, parsedLen.Value); if (context.MatchElemTag(0x80, 0x20, EocTypeCode, parsedLen, true)) { EphemeralPublicKey = new SubjectPublicKeyInfo(); EphemeralPublicKey.Decode(buffer, false, parsedLen.Value); } if (!context.MatchElemTag(0, 0, OctetStringTypeCode, parsedLen, false)) { throw ExceptionUtility.CryptographicException(Resources.Asn1MissingRequiredException, buffer.ByteCount); } Ukm = new Asn1OctetString(); Ukm.Decode(buffer, true, parsedLen.Value); if (Ukm.Length != 8) { throw ExceptionUtility.CryptographicException(Resources.Asn1ConsVioException, nameof(Ukm.Length), Ukm.Length); } }