data = contents.Span;
}
- if (reader.HasData)
- {
- throw new CryptographicException(SR.Cryptography_Der_Invalid_Encoding);
- }
+ reader.ThrowIfNotEmpty();
return data.ToArray();
}
// Read using BER because the CMS specification says the encoding is BER.
AsnReader reader = new AsnReader(encodedUtcTime, AsnEncodingRules.BER);
DateTimeOffset value = reader.GetUtcTime();
-
- if (reader.HasData)
- {
- throw new CryptographicException(SR.Cryptography_Der_Invalid_Encoding);
- }
-
+ reader.ThrowIfNotEmpty();
return value.UtcDateTime;
}
// Read using BER because the CMS specification says the encoding is BER.
AsnReader reader = new AsnReader(encodedOid, AsnEncodingRules.BER);
string value = reader.ReadObjectIdentifierAsString();
-
- if (reader.HasData)
- {
- throw new CryptographicException(SR.Cryptography_Der_Invalid_Encoding);
- }
-
+ reader.ThrowIfNotEmpty();
return value;
}
AsnReader reader = new AsnReader(modifiedAttr.AttrValues, AsnEncodingRules.BER);
AsnReader collReader = reader.ReadSetOf();
- if (reader.HasData)
- {
- throw new CryptographicException(SR.Cryptography_Der_Invalid_Encoding);
- }
+ reader.ThrowIfNotEmpty();
// re-add old values
while (collReader.HasData)
AsnReader reader = new AsnReader(attributeAsn.AttrValues, AsnEncodingRules.BER);
AsnReader collReader = reader.ReadSetOf();
- if (reader.HasData)
- {
- throw new CryptographicException(SR.Cryptography_Der_Invalid_Encoding);
- }
+ reader.ThrowIfNotEmpty();
while (collReader.HasData)
{
AsnReader reader = new AsnReader(attributeAsn.AttrValues, AsnEncodingRules.BER);
AsnReader collReader = reader.ReadSetOf();
- if (reader.HasData)
- {
- throw new CryptographicException(SR.Cryptography_Der_Invalid_Encoding);
- }
+ reader.ThrowIfNotEmpty();
int j = 0;
AsnReader reader = new AsnReader(attrSetBytes, AsnEncodingRules.BER);
AsnReader collReader = reader.ReadSetOf();
- if (reader.HasData)
- {
- throw new CryptographicException(SR.Cryptography_Der_Invalid_Encoding);
- }
+ reader.ThrowIfNotEmpty();
AsnEncodedDataCollection valueColl = new AsnEncodedDataCollection();
AsnReader reader = new AsnReader(attributeValues, AsnEncodingRules.BER);
AsnReader collReader = reader.ReadSetOf();
- if (reader.HasData)
- {
- throw new CryptographicException(SR.Cryptography_Der_Invalid_Encoding);
- }
+ reader.ThrowIfNotEmpty();
for (int i = 0; collReader.HasData; i++)
{
AsnReader reader = new AsnReader(modifiedAttr.AttrValues, writer.RuleSet);
AsnReader collReader = reader.ReadSetOf();
- if (reader.HasData)
- {
- throw new CryptographicException(SR.Cryptography_Der_Invalid_Encoding);
- }
+ reader.ThrowIfNotEmpty();
int i = 0;