Exemplo n.º 1
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_EncryptedKey(
     byte[] encryptedKey_,
     byte[] macKey_
     )
     : base()
 {
     encryptedKey = new Gost28147_89_Key(encryptedKey_);
     macKey       = new Gost28147_89_MAC(macKey_);
 }
Exemplo n.º 2
0
 /// <summary>
 /// This constructor is for required elements only.  It sets
 /// all elements to references to the given objects
 /// </summary>
 public Gost28147_89_EncryptedKey(
     Gost28147_89_Key encryptedKey_,
     Gost28147_89_MAC macKey_
     )
     : base()
 {
     encryptedKey = encryptedKey_;
     macKey       = macKey_;
 }
Exemplo n.º 3
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 encryptedKey

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

            // decode maskKey

            if (context.MatchElemTag(Asn1Tag.CTXT, Asn1Tag.PRIM, 0, elemLen, true))
            {
                maskKey = new Gost28147_89_Key();
                maskKey.Decode(buffer, false, elemLen.Value);
            }

            // decode macKey

            if (context.MatchElemTag(Asn1Tag.Universal, Asn1Tag.PRIM, 4, elemLen, false))
            {
                macKey = new Gost28147_89_MAC();
                macKey.Decode(buffer, true, elemLen.Value);
                if (!(macKey.Length == 4))
                {
                    throw new Exception("Asn1ConsVioException");
                }
            }
            else
            {
                throw new Exception("Asn1MissingRequiredException");
            }
        }
Exemplo n.º 4
0
 public void Init()
 {
     encryptedKey = null;
     maskKey      = null;
     macKey       = null;
 }