Ejemplo n.º 1
0
        /// <summary>
        /// This method must not be called directly: the static <see cref="Write(ICKBinaryWriter, KeyBase, KeyOperations?)"/> must be used.
        /// </summary>
        /// <param name="w">The target writer.</param>
        /// <param name="restrictedOperations">Optional replacement for <see cref="Operations"/>.</param>
        protected virtual void Write(ICKBinaryWriter w, KeyOperations?restrictedOperations)
        {
            KeyOperations o = Operations;

            if (restrictedOperations.HasValue)
            {
                if (!Operations.Supports(restrictedOperations.Value))
                {
                    throw new ArgumentException($"'{Operations}' must support '{restrictedOperations}'.", nameof(restrictedOperations));
                }
                o = restrictedOperations.Value;
            }
            w.Write((byte)0);
            w.WriteEnum(Kty);
            w.Write(Kid.ToString());
            w.WriteEnum(o);
            w.Write(CreationDate);
            w.Write(BestBefore);
            w.Write(MaxUseCount);
            w.Write(_oUseCount);
        }