internal void Encode(AsnWriter writer, Asn1Tag tag) { writer.PushSequence(tag); try { writer.WriteObjectIdentifier(ExtnId); } catch (ArgumentException e) { throw new CryptographicException(SR.Cryptography_Der_Invalid_Encoding, e); } // DEFAULT value handler for Critical. { AsnWriter tmp = new AsnWriter(AsnEncodingRules.DER); tmp.WriteBoolean(Critical); if (!tmp.EncodedValueEquals(DefaultCritical)) { tmp.CopyTo(writer); } } writer.WriteOctetString(ExtnValue.Span); writer.PopSequence(tag); }
internal void Encode(AsnWriter writer, Asn1Tag tag) { writer.PushSequence(tag); Salt.Encode(writer); writer.WriteInteger(IterationCount); if (KeyLength.HasValue) { writer.WriteInteger(KeyLength.Value); } // DEFAULT value handler for Prf. { AsnWriter tmp = new AsnWriter(AsnEncodingRules.DER); Prf.Encode(tmp); if (!tmp.EncodedValueEquals(DefaultPrf)) { tmp.CopyTo(writer); } } writer.PopSequence(tag); }
internal void Encode(AsnWriter writer, Asn1Tag tag) { writer.PushSequence(tag); // DEFAULT value handler for HashFunc. { AsnWriter tmp = new AsnWriter(AsnEncodingRules.DER); HashFunc.Encode(tmp); if (!tmp.EncodedValueEquals(DefaultHashFunc)) { writer.PushSequence(new Asn1Tag(TagClass.ContextSpecific, 0)); tmp.CopyTo(writer); writer.PopSequence(new Asn1Tag(TagClass.ContextSpecific, 0)); } } // DEFAULT value handler for MaskGenFunc. { AsnWriter tmp = new AsnWriter(AsnEncodingRules.DER); MaskGenFunc.Encode(tmp); if (!tmp.EncodedValueEquals(DefaultMaskGenFunc)) { writer.PushSequence(new Asn1Tag(TagClass.ContextSpecific, 1)); tmp.CopyTo(writer); writer.PopSequence(new Asn1Tag(TagClass.ContextSpecific, 1)); } } // DEFAULT value handler for PSourceFunc. { AsnWriter tmp = new AsnWriter(AsnEncodingRules.DER); PSourceFunc.Encode(tmp); if (!tmp.EncodedValueEquals(DefaultPSourceFunc)) { writer.PushSequence(new Asn1Tag(TagClass.ContextSpecific, 2)); tmp.CopyTo(writer); writer.PopSequence(new Asn1Tag(TagClass.ContextSpecific, 2)); } } writer.PopSequence(tag); }
internal void Encode(AsnWriter writer, Asn1Tag tag) { writer.PushSequence(tag); // DEFAULT value handler for HashAlgorithm. { AsnWriter tmp = new AsnWriter(AsnEncodingRules.DER); HashAlgorithm.Encode(tmp); if (!tmp.EncodedValueEquals(DefaultHashAlgorithm)) { writer.PushSequence(new Asn1Tag(TagClass.ContextSpecific, 0)); tmp.CopyTo(writer); writer.PopSequence(new Asn1Tag(TagClass.ContextSpecific, 0)); } } // DEFAULT value handler for MaskGenAlgorithm. { AsnWriter tmp = new AsnWriter(AsnEncodingRules.DER); MaskGenAlgorithm.Encode(tmp); if (!tmp.EncodedValueEquals(DefaultMaskGenAlgorithm)) { writer.PushSequence(new Asn1Tag(TagClass.ContextSpecific, 1)); tmp.CopyTo(writer); writer.PopSequence(new Asn1Tag(TagClass.ContextSpecific, 1)); } } // DEFAULT value handler for SaltLength. { AsnWriter tmp = new AsnWriter(AsnEncodingRules.DER); tmp.WriteInteger(SaltLength); if (!tmp.EncodedValueEquals(DefaultSaltLength)) { writer.PushSequence(new Asn1Tag(TagClass.ContextSpecific, 2)); tmp.CopyTo(writer); writer.PopSequence(new Asn1Tag(TagClass.ContextSpecific, 2)); } } // DEFAULT value handler for TrailerField. { AsnWriter tmp = new AsnWriter(AsnEncodingRules.DER); tmp.WriteInteger(TrailerField); if (!tmp.EncodedValueEquals(DefaultTrailerField)) { writer.PushSequence(new Asn1Tag(TagClass.ContextSpecific, 3)); tmp.CopyTo(writer); writer.PopSequence(new Asn1Tag(TagClass.ContextSpecific, 3)); } } writer.PopSequence(tag); }