예제 #1
0
        internal static void Decode(AsnReader reader, Asn1Tag expectedTag, out RSAPrivateKeyAsn decoded)
        {
            if (reader == null)
            {
                throw new ArgumentNullException(nameof(reader));
            }

            decoded = default;
            AsnReader sequenceReader = reader.ReadSequence(expectedTag);


            if (!sequenceReader.TryReadUInt8(out decoded.Version))
            {
                sequenceReader.ThrowIfNotEmpty();
            }

            decoded.Modulus         = sequenceReader.ReadInteger();
            decoded.PublicExponent  = sequenceReader.ReadInteger();
            decoded.PrivateExponent = sequenceReader.ReadInteger();
            decoded.Prime1          = sequenceReader.ReadInteger();
            decoded.Prime2          = sequenceReader.ReadInteger();
            decoded.Exponent1       = sequenceReader.ReadInteger();
            decoded.Exponent2       = sequenceReader.ReadInteger();
            decoded.Coefficient     = sequenceReader.ReadInteger();

            sequenceReader.ThrowIfNotEmpty();
        }
예제 #2
0
        internal static void Decode(AsnReader reader, out RSAPrivateKeyAsn decoded)
        {
            if (reader == null)
                throw new ArgumentNullException(nameof(reader));

            Decode(reader, Asn1Tag.Sequence, out decoded);
        }
예제 #3
0
        internal static void Decode(ref AsnValueReader reader, Asn1Tag expectedTag, ReadOnlyMemory <byte> rebind, out RSAPrivateKeyAsn decoded)
        {
            decoded = default;
            AsnValueReader sequenceReader = reader.ReadSequence(expectedTag);


            if (!sequenceReader.TryReadUInt8(out decoded.Version))
            {
                sequenceReader.ThrowIfNotEmpty();
            }

            decoded.Modulus         = sequenceReader.ReadInteger();
            decoded.PublicExponent  = sequenceReader.ReadInteger();
            decoded.PrivateExponent = sequenceReader.ReadInteger();
            decoded.Prime1          = sequenceReader.ReadInteger();
            decoded.Prime2          = sequenceReader.ReadInteger();
            decoded.Exponent1       = sequenceReader.ReadInteger();
            decoded.Exponent2       = sequenceReader.ReadInteger();
            decoded.Coefficient     = sequenceReader.ReadInteger();

            sequenceReader.ThrowIfNotEmpty();
        }
예제 #4
0
 internal static void Decode(ref AsnValueReader reader, ReadOnlyMemory <byte> rebind, out RSAPrivateKeyAsn decoded)
 {
     Decode(ref reader, Asn1Tag.Sequence, rebind, out decoded);
 }
 internal static void Decode(ref AsnValueReader reader, Asn1Tag expectedTag, ReadOnlyMemory <byte> rebind, out RSAPrivateKeyAsn decoded)
 {
     try
     {
         DecodeCore(ref reader, expectedTag, rebind, out decoded);
     }
     catch (AsnContentException e)
     {
         throw new CryptographicException(SR.Cryptography_Der_Invalid_Encoding, e);
     }
 }