public override int Encode(Asn1BerEncodeBuffer buffer, bool explicitTagging)
        {
            var len = 0;

            if (Ukm.Length != 8)
            {
                throw ExceptionUtility.CryptographicException(Resources.Asn1ConsVioException, nameof(Ukm.Length), Ukm.Length);
            }

            len += Ukm.Encode(buffer, true);

            if (EphemeralPublicKey != null)
            {
                var epkLength = EphemeralPublicKey.Encode(buffer, false);

                len += epkLength;
                len += buffer.EncodeTagAndLength(0x80, 0x20, EocTypeCode, epkLength);
            }

            len += EncryptionParamSet.Encode(buffer, true);

            if (explicitTagging)
            {
                len += buffer.EncodeTagAndLength(Asn1Tag.Sequence, len);
            }

            return(len);
        }
        public override int Encode(Asn1BerEncodeBuffer buffer, bool explicitTagging)
        {
            var len = 0;

            len += EncryptionParamSet.Encode(buffer, true);
            len += Iv.Encode(buffer, true);

            if (explicitTagging)
            {
                len += buffer.EncodeTagAndLength(Asn1Tag.Sequence, len);
            }

            return(len);
        }
Example #3
0
        public override int Encode(Asn1BerEncodeBuffer buffer, bool explicitTagging)
        {
            var len = 0;

            if (Ukm != null)
            {
                if (Ukm.Length != 8)
                {
                    throw ExceptionUtility.CryptographicException(Resources.Asn1ConsVioException, nameof(Ukm.Length), Ukm.Length);
                }

                len += Ukm.Encode(buffer, true);
            }

            len += EncryptionParamSet.Encode(buffer, true);

            if (explicitTagging)
            {
                len += buffer.EncodeTagAndLength(Asn1Tag.Sequence, len);
            }

            return(len);
        }