Ejemplo n.º 1
0
        public static bool TryDecode(
            ReadOnlyMemory <byte> encodedBytes,
            out Rfc3161TimestampRequest request,
            out int bytesConsumed)
        {
            try
            {
                // RFC 3161 doesn't have a concise statement that TimeStampReq will
                // be DER encoded, but under the email protocol (3.1), file protocol (3.2),
                // socket protocol (3.3) and HTTP protocol (3.4) they all say DER for the
                // transmission.
                //
                // Since nothing says BER, assume DER only.
                const AsnEncodingRules RuleSet = AsnEncodingRules.DER;

                AsnReader             reader       = new AsnReader(encodedBytes, RuleSet);
                ReadOnlyMemory <byte> firstElement = reader.PeekEncodedValue();

                var req = AsnSerializer.Deserialize <Rfc3161TimeStampReq>(firstElement, RuleSet);

                request = new Rfc3161TimestampRequest
                {
                    _parsedData   = req,
                    _encodedBytes = firstElement.ToArray(),
                };

                bytesConsumed = firstElement.Length;
                return(true);
            }
            catch (CryptographicException)
            {
            }

            request       = null;
            bytesConsumed = 0;
            return(false);
        }
 public static bool TryDecode(ReadOnlyMemory <byte> encodedBytes, out Rfc3161TimestampRequest request, out int bytesConsumed) => throw null;
Ejemplo n.º 3
0
 /// <param name="encodedBytes" />
 /// <param name="request" />
 /// <param name="bytesConsumed" />
 public static bool TryDecode(ReadOnlyMemory <byte> encodedBytes, out Rfc3161TimestampRequest request, out int bytesConsumed)
 {
     throw new PlatformNotSupportedException();
 }