Exemple #1
0
 /// <summary>
 /// This constructor sets all elements to references to the
 /// given objects
 /// </summary>
 public Gost28147_89_BlobParameters(
     Gost28147_89_ParamSet encryptionParamSet_
     )
     : base()
 {
     encryptionParamSet = encryptionParamSet_;
 }
        public override void Decode(Asn1BerDecodeBuffer buffer, bool explicitTagging, int implicitLength)
        {
            var elemLength = explicitTagging ? MatchTag(buffer, Asn1Tag.Sequence) : implicitLength;

            Init();

            var context   = new Asn1BerDecodeContext(buffer, elemLength);
            var parsedLen = new IntHolder();

            if (!context.MatchElemTag(0, 0, ObjectIdentifierTypeCode, parsedLen, false))
            {
                throw new Exception("Asn1MissingRequiredException");
            }

            PublicKeyParamSet = new Asn1ObjectIdentifier();
            PublicKeyParamSet.Decode(buffer, true, parsedLen.Value);

            if (!context.MatchElemTag(0, 0, ObjectIdentifierTypeCode, parsedLen, false))
            {
                throw new Exception("Asn1MissingRequiredException");
            }

            DigestParamSet = new Asn1ObjectIdentifier();
            DigestParamSet.Decode(buffer, true, parsedLen.Value);

            if (context.MatchElemTag(0, 0, ObjectIdentifierTypeCode, parsedLen, false))
            {
                EncryptionParamSet = new Gost28147_89_ParamSet();
                EncryptionParamSet.Decode(buffer, true, parsedLen.Value);
            }
        }
Exemple #3
0
 /// <summary>
 /// This constructor is for required elements only.  It allows
 /// primitive data to be passed for all primitive elements.
 /// It will create new object wrappers for the primitive data
 /// and set other elements to references to the given objects.
 /// </summary>
 public Gost28147_89_KeyWrapParameters(
     int[] encryptionParamSet_
     )
     : base()
 {
     encryptionParamSet = new Gost28147_89_ParamSet(encryptionParamSet_);
 }
Exemple #4
0
 /// <summary>
 /// This constructor allows primitive data to be passed for all
 /// primitive elements.  It will create new object wrappers for
 /// the primitive data and set other elements to references to
 /// the given objects
 /// </summary>
 public Gost28147_89_KeyWrapParameters(int[] encryptionParamSet_,
                                       byte[] ukm_
                                       )
     : base()
 {
     encryptionParamSet = new Gost28147_89_ParamSet(encryptionParamSet_);
     ukm = new Asn1OctetString(ukm_);
 }
 /// <summary>
 /// This constructor allows primitive data to be passed for all
 /// primitive elements.  It will create new object wrappers for
 /// the primitive data and set other elements to references to
 /// the given objects
 /// </summary>
 public Gost28147_89_Parameters(byte[] iv_,
                                int[] encryptionParamSet_
                                )
     : base()
 {
     iv = new Gost28147_89_IV(iv_);
     encryptionParamSet = new Gost28147_89_ParamSet(encryptionParamSet_);
 }
 /// <summary>
 /// This constructor is for required elements only.  It sets
 /// all elements to references to the given objects
 /// </summary>
 public GostR3410_TransportParameters(
     Gost28147_89_ParamSet encryptionParamSet_,
     Asn1OctetString ukm_
     )
     : base()
 {
     encryptionParamSet = encryptionParamSet_;
     ukm = ukm_;
 }
 /// <summary>
 /// This constructor sets all elements to references to the
 /// given objects
 /// </summary>
 public Gost28147_89_Parameters(
     Gost28147_89_IV iv_,
     Gost28147_89_ParamSet encryptionParamSet_
     )
     : base()
 {
     iv = iv_;
     encryptionParamSet = encryptionParamSet_;
 }
Exemple #8
0
 /// <summary>
 /// This constructor sets all elements to references to the
 /// given objects
 /// </summary>
 public Gost28147_89_KeyWrapParameters(
     Gost28147_89_ParamSet encryptionParamSet_,
     Asn1OctetString ukm_
     )
     : base()
 {
     encryptionParamSet = encryptionParamSet_;
     ukm = ukm_;
 }
 /// <summary>
 /// This constructor allows primitive data to be passed for all
 /// primitive elements.  It will create new object wrappers for
 /// the primitive data and set other elements to references to
 /// the given objects
 /// </summary>
 public GostR3410_TransportParameters(int[] encryptionParamSet_,
                                      SubjectPublicKeyInfo ephemeralPublicKey_,
                                      byte[] ukm_
                                      )
     : base()
 {
     encryptionParamSet = new Gost28147_89_ParamSet(encryptionParamSet_);
     ephemeralPublicKey = ephemeralPublicKey_;
     ukm = new Asn1OctetString(ukm_);
 }
 /// <summary>
 /// This constructor allows primitive data to be passed for all
 /// primitive elements.  It will create new object wrappers for
 /// the primitive data and set other elements to references to
 /// the given objects
 /// </summary>
 public GostR3410_94_PublicKeyParameters(int[] publicKeyParamSet_,
                                         int[] digestParamSet_,
                                         int[] encryptionParamSet_
                                         )
     : base()
 {
     publicKeyParamSet  = new Asn1ObjectIdentifier(publicKeyParamSet_);
     digestParamSet     = new Asn1ObjectIdentifier(digestParamSet_);
     encryptionParamSet = new Gost28147_89_ParamSet(encryptionParamSet_);
 }
 /// <summary>
 /// This constructor sets all elements to references to the
 /// given objects
 /// </summary>
 public GostR3410_TransportParameters(
     Gost28147_89_ParamSet encryptionParamSet_,
     SubjectPublicKeyInfo ephemeralPublicKey_,
     Asn1OctetString ukm_
     )
     : base()
 {
     encryptionParamSet = encryptionParamSet_;
     ephemeralPublicKey = ephemeralPublicKey_;
     ukm = ukm_;
 }
 /// <summary>
 /// This constructor sets all elements to references to the
 /// given objects
 /// </summary>
 public GostR3410_94_PublicKeyParameters(
     Asn1ObjectIdentifier publicKeyParamSet_,
     Asn1ObjectIdentifier digestParamSet_,
     Gost28147_89_ParamSet encryptionParamSet_
     )
     : base()
 {
     publicKeyParamSet  = publicKeyParamSet_;
     digestParamSet     = digestParamSet_;
     encryptionParamSet = encryptionParamSet_;
 }
        public override void Decode
            (Asn1BerDecodeBuffer buffer, bool explicitTagging, int implicitLength)
        {
            int llen = (explicitTagging) ?
                       MatchTag(buffer, Asn1Tag.Sequence) : implicitLength;

            Init();

            // decode SEQUENCE

            Asn1BerDecodeContext context =
                new Asn1BerDecodeContext(buffer, llen);

            IntHolder elemLen = new IntHolder();

            // decode encryptionParamSet

            if (context.MatchElemTag(Asn1Tag.Universal, Asn1Tag.PRIM, 6, elemLen, false))
            {
                encryptionParamSet = new Gost28147_89_ParamSet();
                encryptionParamSet.Decode(buffer, true, elemLen.Value);
            }
            else
            {
                throw new Exception("Asn1MissingRequiredException (buffer)");
            }

            // decode ephemeralPublicKey

            if (context.MatchElemTag(Asn1Tag.CTXT, Asn1Tag.CONS, 0, elemLen, true))
            {
                ephemeralPublicKey = new SubjectPublicKeyInfo();
                ephemeralPublicKey.Decode(buffer, false, elemLen.Value);
            }

            // decode ukm

            if (context.MatchElemTag(Asn1Tag.Universal, Asn1Tag.PRIM, 4, elemLen, false))
            {
                ukm = new Asn1OctetString();
                ukm.Decode(buffer, true, elemLen.Value);
                if (!(ukm.Length == 8))
                {
                    throw new Exception("Asn1ConsVioException (ukm.Length, ukm.Length)");
                }
            }
            else
            {
                throw new Exception("Asn1MissingRequiredException (buffer)");
            }
        }
Exemple #14
0
        public override void Decode
            (Asn1BerDecodeBuffer buffer, bool explicitTagging, int implicitLength)
        {
            int llen = (explicitTagging) ?
                       MatchTag(buffer, Asn1Tag.Sequence) : implicitLength;

            Init();

            // decode SEQUENCE

            Asn1BerDecodeContext context =
                new Asn1BerDecodeContext(buffer, llen);

            IntHolder elemLen = new IntHolder();

            // decode encryptionParamSet

            if (context.MatchElemTag(Asn1Tag.Universal, Asn1Tag.PRIM, 6, elemLen, false))
            {
                encryptionParamSet = new Gost28147_89_ParamSet();
                encryptionParamSet.Decode(buffer, true, elemLen.Value);
            }
            else
            {
                throw new Exception("Asn1MissingRequiredException");
            }

            // decode extElem1

            if (!context.Expired())
            {
                Asn1Tag _tag = buffer.PeekTag();
                if (_tag.Equals(Asn1Tag.Universal, Asn1Tag.PRIM, 6))
                {
                    throw new Exception("Asn1SeqOrderException");
                }
                else
                {
                    extElem1 = new Asn1OpenExt();
                    while (!context.Expired())
                    {
                        extElem1.DecodeComponent(buffer);
                    }
                }
            }
            else
            {
                extElem1 = null;
            }
        }
        public override void Decode
            (Asn1BerDecodeBuffer buffer, bool explicitTagging, int implicitLength)
        {
            int llen = (explicitTagging) ?
                       MatchTag(buffer, Asn1Tag.Sequence) : implicitLength;

            Init();

            // decode SEQUENCE

            Asn1BerDecodeContext context =
                new Asn1BerDecodeContext(buffer, llen);

            IntHolder elemLen = new IntHolder();

            // decode publicKeyParamSet

            if (context.MatchElemTag(Asn1Tag.Universal, Asn1Tag.PRIM, 6, elemLen, false))
            {
                publicKeyParamSet = new Asn1ObjectIdentifier();
                publicKeyParamSet.Decode(buffer, true, elemLen.Value);
            }
            else
            {
                throw new Exception("Asn1MissingRequiredException (buffer)");
            }

            // decode digestParamSet

            if (context.MatchElemTag(Asn1Tag.Universal, Asn1Tag.PRIM, 6, elemLen, false))
            {
                digestParamSet = new Asn1ObjectIdentifier();
                digestParamSet.Decode(buffer, true, elemLen.Value);
            }
            else
            {
                throw new Exception("Asn1MissingRequiredException (buffer)");
            }

            // decode encryptionParamSet

            if (context.MatchElemTag(Asn1Tag.Universal, Asn1Tag.PRIM, 6, elemLen, false))
            {
                encryptionParamSet = new Gost28147_89_ParamSet();
                encryptionParamSet.Decode(buffer, true, elemLen.Value);
            }
        }
 private void Init()
 {
     DigestParamSet     = null;
     PublicKeyParamSet  = null;
     EncryptionParamSet = null;
 }
Exemple #17
0
 public void Init()
 {
     encryptionParamSet = null;
     ukm = null;
 }
 public void Init()
 {
     iv = null;
     encryptionParamSet = null;
 }
Exemple #19
0
 public void Init()
 {
     encryptionParamSet = null;
     extElem1           = null;
 }
 public void Init()
 {
     publicKeyParamSet  = null;
     digestParamSet     = null;
     encryptionParamSet = null;
 }
 public void Init()
 {
     encryptionParamSet = null;
     ephemeralPublicKey = null;
     ukm = null;
 }