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

            // encode ukm

            if (!(ukm.Length == 8))
            {
                throw new Exception("Asn1ConsVioException (ukm.Length, ukm.Length)");
            }

            len   = ukm.Encode(buffer, true);
            _aal += len;

            // encode ephemeralPublicKey

            if (ephemeralPublicKey != null)
            {
                len   = ephemeralPublicKey.Encode(buffer, false);
                _aal += len;
                _aal += buffer.EncodeTagAndLength(Asn1Tag.CTXT, Asn1Tag.CONS, 0, len);
            }

            // encode encryptionParamSet

            len   = encryptionParamSet.Encode(buffer, true);
            _aal += len;

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

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

            // encode encryptionParamSet

            if (encryptionParamSet != null)
            {
                len   = encryptionParamSet.Encode(buffer, true);
                _aal += len;
            }

            // encode digestParamSet

            len   = digestParamSet.Encode(buffer, true);
            _aal += len;

            // encode publicKeyParamSet

            len   = publicKeyParamSet.Encode(buffer, true);
            _aal += len;

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

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

            // encode ukm

            if (ukm != null)
            {
                if (!(ukm.Length == 8))
                {
                    throw new Exception("Asn1ConsVioException");
                }

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

            // encode encryptionParamSet

            len   = encryptionParamSet.Encode(buffer, true);
            _aal += len;

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

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

            if (EncryptionParamSet != null)
            {
                len += EncryptionParamSet.Encode(buffer, true);
            }

            len += DigestParamSet.Encode(buffer, true);
            len += PublicKeyParamSet.Encode(buffer, true);

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

            return(len);
        }
示例#5
0
        public override int Encode(Asn1BerEncodeBuffer buffer, bool explicitTagging)
        {
            int _aal = 0, len;

            // encode encryptionParamSet

            len   = encryptionParamSet.Encode(buffer, true);
            _aal += len;

            // encode iv

            len   = iv.Encode(buffer, true);
            _aal += len;

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

            return(_aal);
        }