示例#1
0
        /// <summary>
        /// Wraps the 'Void Reset()' on the 'System.Collections.IEnumerator' type.
        /// </summary>
        public virtual void Reset()
        {
            var type       = WrapperUtilities.GetTypeFromCache("System.Collections.IEnumerator", "mscorlib", TypeCache);
            var methodInfo = WrapperUtilities.GetMethodInfo(type, MethodInfoCache, "Void Reset()");

            WrapperUtilities.InvokeMethodWithoutResult(this, methodInfo, new object[] { });
        }
示例#2
0
        /// <summary>
        /// Wraps the 'Boolean MoveNext()' on the 'System.Collections.IEnumerator' type.
        /// </summary>
        /// <returns>The value returned by the underlying method.</returns>
        public virtual bool MoveNext()
        {
            var type       = WrapperUtilities.GetTypeFromCache("System.Collections.IEnumerator", "mscorlib", TypeCache);
            var methodInfo = WrapperUtilities.GetMethodInfo(type, MethodInfoCache, "Boolean MoveNext()");

            return(WrapperUtilities.InvokeMethodAndCast <bool>(this, methodInfo, new object[] { }));
        }
示例#3
0
 /// <summary>
 /// Gets a value of the 'Item' property on 'System.Collections.ObjectModel.ReadOnlyCollection`1'
 /// </summary>
 /// <param name="index">The value of the 'index' parameter.</param>
 public virtual T this[int index]
 {
     get
     {
         return(WrapperUtilities.InvokeMethodAndWrap <T>(this, WrapperUtilities.GetMethodInfo(WrappedObjectType, MethodInfoCache, "T get_Item(Int32)"), new object[] { index }));
     }
 }
        public override CmsTypedStream GetContentStream(ICipherParameters key)
        {
            CmsTypedStream contentFromSessionKey;

            try
            {
                AlgorithmIdentifier instance         = AlgorithmIdentifier.GetInstance(this.info.KeyEncryptionAlgorithm);
                Asn1Sequence        asn1Sequence     = (Asn1Sequence)instance.Parameters;
                byte[]            octets             = this.info.EncryptedKey.GetOctets();
                string            id                 = DerObjectIdentifier.GetInstance(asn1Sequence[0]).Id;
                string            rfc3211WrapperName = CmsEnvelopedHelper.Instance.GetRfc3211WrapperName(id);
                IWrapper          wrapper            = WrapperUtilities.GetWrapper(rfc3211WrapperName);
                byte[]            octets2            = Asn1OctetString.GetInstance(asn1Sequence[1]).GetOctets();
                ICipherParameters parameters         = ((CmsPbeKey)key).GetEncoded(id);
                parameters = new ParametersWithIV(parameters, octets2);
                wrapper.Init(false, parameters);
                KeyParameter sKey = ParameterUtilities.CreateKeyParameter(base.GetContentAlgorithmName(), wrapper.Unwrap(octets, 0, octets.Length));
                contentFromSessionKey = base.GetContentFromSessionKey(sKey);
            }
            catch (SecurityUtilityException e)
            {
                throw new CmsException("couldn't create cipher.", e);
            }
            catch (InvalidKeyException e2)
            {
                throw new CmsException("key invalid in message.", e2);
            }
            return(contentFromSessionKey);
        }
示例#5
0
        /**
         * decrypt the content and return an input stream.
         */
        public override CmsTypedStream GetContentStream(
            ICipherParameters key)
        {
            try
            {
                byte[]   encryptedKey = info.EncryptedKey.GetOctets();
                IWrapper keyWrapper   = WrapperUtilities.GetWrapper(keyEncAlg.ObjectID.Id);

                keyWrapper.Init(false, key);

                AlgorithmIdentifier aid  = GetActiveAlgID();
                KeyParameter        sKey = ParameterUtilities.CreateKeyParameter(
                    aid.ObjectID, keyWrapper.Unwrap(encryptedKey, 0, encryptedKey.Length));

                return(GetContentFromSessionKey(sKey));
            }
            catch (SecurityUtilityException e)
            {
                throw new CmsException("couldn't create cipher.", e);
            }
            catch (InvalidKeyException e)
            {
                throw new CmsException("key invalid in message.", e);
            }
        }
示例#6
0
        /// <summary>
        /// Wraps the 'System.String ToString()' on the 'System.IO.Stream' type.
        /// </summary>
        /// <returns>The value returned by the underlying method.</returns>
        public override string ToString()
        {
            var type       = WrapperUtilities.GetTypeFromCache("System.Object", "mscorlib", TypeCache);
            var methodInfo = WrapperUtilities.GetMethodInfo(type, MethodInfoCache, "System.String ToString()");

            return(WrapperUtilities.InvokeMethodAndCast <string>(this, methodInfo, new object[] { }));
        }
示例#7
0
        /**
         * decrypt the content and return an input stream.
         */
        public override CmsTypedStream GetContentStream(
            ICipherParameters key)
        {
            try
            {
                AlgorithmIdentifier kekAlg       = AlgorithmIdentifier.GetInstance(info.KeyEncryptionAlgorithm);
                Asn1Sequence        kekAlgParams = (Asn1Sequence)kekAlg.Parameters;
                byte[]   encryptedKey            = info.EncryptedKey.GetOctets();
                string   kekAlgName = DerObjectIdentifier.GetInstance(kekAlgParams[0]).Id;
                string   cName      = CmsEnvelopedHelper.Instance.GetRfc3211WrapperName(kekAlgName);
                IWrapper keyWrapper = WrapperUtilities.GetWrapper(cName);

                byte[] iv = Asn1OctetString.GetInstance(kekAlgParams[1]).GetOctets();

                ICipherParameters parameters = ((CmsPbeKey)key).GetEncoded(kekAlgName);
                parameters = new ParametersWithIV(parameters, iv);

                keyWrapper.Init(false, parameters);

                KeyParameter sKey = ParameterUtilities.CreateKeyParameter(
                    GetContentAlgorithmName(), keyWrapper.Unwrap(encryptedKey, 0, encryptedKey.Length));

                return(GetContentFromSessionKey(sKey));
            }
            catch (SecurityUtilityException e)
            {
                throw new CmsException("couldn't create cipher.", e);
            }
            catch (InvalidKeyException e)
            {
                throw new CmsException("key invalid in message.", e);
            }
        }
示例#8
0
        /// <summary>
        /// Wraps the 'Void Write(Byte[], Int32, Int32)' on the 'System.IO.Stream' type.
        /// </summary>
        /// <param name="buffer">The value of the 'buffer' parameter.</param>
        /// <param name="offset">The value of the 'offset' parameter.</param>
        /// <param name="count">The value of the 'count' parameter.</param>
        public override void Write(byte[] buffer, int offset, int count)
        {
            var type       = WrapperUtilities.GetTypeFromCache("System.IO.Stream", "mscorlib", TypeCache);
            var methodInfo = WrapperUtilities.GetMethodInfo(type, MethodInfoCache, "Void Write(Byte[], Int32, Int32)");

            WrapperUtilities.InvokeMethodWithoutResult(this, methodInfo, new object[] { buffer, offset, count });
        }
示例#9
0
        /// <summary>
        /// Wraps the 'System.Collections.IEnumerator GetEnumerator()' on the 'System.Linq.IQueryable' type.
        /// </summary>
        /// <returns>The value returned by the underlying method.</returns>
        public virtual System.Collections.IEnumerator GetEnumerator()
        {
            var type       = WrapperUtilities.GetTypeFromCache("System.Collections.IEnumerable", "mscorlib", TypeCache);
            var methodInfo = WrapperUtilities.GetMethodInfo(type, MethodInfoCache, "System.Collections.IEnumerator GetEnumerator()");

            return((System.Collections.IEnumerator)ProxyFactory.CreateProxyIfPossible(this.Scope, WrapperUtilities.InvokeMethodAndCast <System.Collections.IEnumerator>(this, methodInfo, new object[] { }), typeof(System.Collections.IEnumerator)));
        }
示例#10
0
        /// <summary>
        /// Wraps the 'System.Linq.IQueryable`1[TElement] CreateQuery[TElement](System.Linq.Expressions.Expression)' on the 'System.Linq.IQueryProvider' type.
        /// </summary>
        /// <typeparam name="TElement">The wrapper type for the 'TElement' generic parameter.</typeparam>
        /// <param name="expression">The value of the 'expression' parameter.</param>
        /// <returns>The value returned by the underlying method.</returns>
        public virtual System.Linq.IQueryable <TElement> CreateQuery <TElement>(System.Linq.Expressions.Expression expression)
        {
            var type       = WrapperUtilities.GetTypeFromCache("System.Linq.IQueryProvider", "System.Core", TypeCache);
            var methodInfo = WrapperUtilities.GetMethodInfo(type, MethodInfoCache, "System.Linq.IQueryable`1[TElement] CreateQuery[TElement](System.Linq.Expressions.Expression)");

            return((System.Linq.IQueryable <TElement>)ProxyFactory.CreateProxyIfPossible(this.Scope, WrapperUtilities.InvokeMethodAndCast <System.Linq.IQueryable <TElement> >(this, methodInfo, new object[] { expression }, new Type[] { typeof(TElement) }), typeof(System.Linq.IQueryable <TElement>)));
        }
示例#11
0
        /// <summary>
        /// Wraps the 'System.IAsyncResult BeginWrite(Byte[], Int32, Int32, System.AsyncCallback, System.Object)' on the 'System.IO.Stream' type.
        /// </summary>
        /// <param name="buffer">The value of the 'buffer' parameter.</param>
        /// <param name="offset">The value of the 'offset' parameter.</param>
        /// <param name="count">The value of the 'count' parameter.</param>
        /// <param name="callback">The value of the 'callback' parameter.</param>
        /// <param name="state">The value of the 'state' parameter.</param>
        /// <returns>The value returned by the underlying method.</returns>
        public override System.IAsyncResult BeginWrite(byte[] buffer, int offset, int count, System.AsyncCallback callback, object state)
        {
            var type       = WrapperUtilities.GetTypeFromCache("System.IO.Stream", "mscorlib", TypeCache);
            var methodInfo = WrapperUtilities.GetMethodInfo(type, MethodInfoCache, "System.IAsyncResult BeginWrite(Byte[], Int32, Int32, System.AsyncCallback, System.Object)");

            return(WrapperUtilities.InvokeMethodAndCast <System.IAsyncResult>(this, methodInfo, new object[] { buffer, offset, count, callback, state }));
        }
        internal KeyParameter UnwrapKey(ICipherParameters key)
        {
            byte[] encryptedKey         = info.EncryptedKey.GetOctets();
            string keyExchangeAlgorithm = GetExchangeEncryptionAlgorithmName(keyEncAlg.Algorithm);

            try
            {
                IWrapper keyWrapper = WrapperUtilities.GetWrapper(keyExchangeAlgorithm);
                keyWrapper.Init(false, key);

                // FIXME Support for MAC algorithm parameters similar to cipher parameters
                return(ParameterUtilities.CreateKeyParameter(
                           GetContentAlgorithmName(), keyWrapper.Unwrap(encryptedKey, 0, encryptedKey.Length)));
            }
            catch (SecurityUtilityException e)
            {
                throw new CmsException("couldn't create cipher.", e);
            }
            catch (InvalidKeyException e)
            {
                throw new CmsException("key invalid in message.", e);
            }
//			catch (IllegalBlockSizeException e)
            catch (DataLengthException e)
            {
                throw new CmsException("illegal blocksize in message.", e);
            }
//			catch (BadPaddingException e)
            catch (InvalidCipherTextException e)
            {
                throw new CmsException("bad padding in message.", e);
            }
        }
示例#13
0
        /// <summary>
        /// Wraps the 'System.Object Execute(System.Linq.Expressions.Expression)' on the 'System.Linq.IQueryProvider' type.
        /// </summary>
        /// <param name="expression">The value of the 'expression' parameter.</param>
        /// <returns>The value returned by the underlying method.</returns>
        public virtual object Execute(System.Linq.Expressions.Expression expression)
        {
            var type       = WrapperUtilities.GetTypeFromCache("System.Linq.IQueryProvider", "System.Core", TypeCache);
            var methodInfo = WrapperUtilities.GetMethodInfo(type, MethodInfoCache, "System.Object Execute(System.Linq.Expressions.Expression)");

            return(WrapperUtilities.InvokeMethodAndCast <object>(this, methodInfo, new object[] { expression }));
        }
示例#14
0
        protected void wrapOidTest(
            string[]        oids,
            string name)
        {
            byte[] data = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };

            for (int i = 0; i != oids.Length; i++)
            {
                IWrapper           c1 = WrapperUtilities.GetWrapper(oids[i]);
                IWrapper           c2 = WrapperUtilities.GetWrapper(name);
                CipherKeyGenerator kg = GeneratorUtilities.GetKeyGenerator(oids[i]);

                KeyParameter k = ParameterUtilities.CreateKeyParameter(oids[i], kg.GenerateKey());

                c1.Init(true, k);
                c2.Init(false, k);

                byte[] wrapped   = c1.Wrap(data, 0, data.Length);
                byte[] wKeyBytes = c2.Unwrap(wrapped, 0, wrapped.Length);

                if (!AreEqual(data, wKeyBytes))
                {
                    Fail("failed wrap OID test");
                }

                if (k.GetKey().Length != (16 + (i * 8)))
                {
                    Fail("failed key length test");
                }
            }
        }
示例#15
0
        /// <summary>
        /// Wraps the 'Void WriteByte(Byte)' on the 'System.IO.Stream' type.
        /// </summary>
        /// <param name="value">The value of the 'value' parameter.</param>
        public override void WriteByte(byte value)
        {
            var type       = WrapperUtilities.GetTypeFromCache("System.IO.Stream", "mscorlib", TypeCache);
            var methodInfo = WrapperUtilities.GetMethodInfo(type, MethodInfoCache, "Void WriteByte(Byte)");

            WrapperUtilities.InvokeMethodWithoutResult(this, methodInfo, new object[] { value });
        }
示例#16
0
        /// <summary>
        /// Wraps the 'Int64 Seek(Int64, System.IO.SeekOrigin)' on the 'System.IO.Stream' type.
        /// </summary>
        /// <param name="offset">The value of the 'offset' parameter.</param>
        /// <param name="origin">The value of the 'origin' parameter.</param>
        /// <returns>The value returned by the underlying method.</returns>
        public override long Seek(long offset, System.IO.SeekOrigin origin)
        {
            var type       = WrapperUtilities.GetTypeFromCache("System.IO.Stream", "mscorlib", TypeCache);
            var methodInfo = WrapperUtilities.GetMethodInfo(type, MethodInfoCache, "Int64 Seek(Int64, System.IO.SeekOrigin)");

            return(WrapperUtilities.InvokeMethodAndCast <long>(this, methodInfo, new object[] { offset, origin }));
        }
示例#17
0
        internal KeyParameter UnwrapKey(ICipherParameters key)
        {
            byte[]       octets = this.info.EncryptedKey.GetOctets();
            string       exchangeEncryptionAlgorithmName = this.GetExchangeEncryptionAlgorithmName(this.keyEncAlg.ObjectID);
            KeyParameter result;

            try
            {
                IWrapper wrapper = WrapperUtilities.GetWrapper(exchangeEncryptionAlgorithmName);
                wrapper.Init(false, key);
                result = ParameterUtilities.CreateKeyParameter(base.GetContentAlgorithmName(), wrapper.Unwrap(octets, 0, octets.Length));
            }
            catch (SecurityUtilityException e)
            {
                throw new CmsException("couldn't create cipher.", e);
            }
            catch (InvalidKeyException e2)
            {
                throw new CmsException("key invalid in message.", e2);
            }
            catch (DataLengthException e3)
            {
                throw new CmsException("illegal blocksize in message.", e3);
            }
            catch (InvalidCipherTextException e4)
            {
                throw new CmsException("bad padding in message.", e4);
            }
            return(result);
        }
示例#18
0
        /// <summary>
        /// Wraps the 'Int32 ReadByte()' on the 'System.IO.Stream' type.
        /// </summary>
        /// <returns>The value returned by the underlying method.</returns>
        public override int ReadByte()
        {
            var type       = WrapperUtilities.GetTypeFromCache("System.IO.Stream", "mscorlib", TypeCache);
            var methodInfo = WrapperUtilities.GetMethodInfo(type, MethodInfoCache, "Int32 ReadByte()");

            return(WrapperUtilities.InvokeMethodAndCast <int>(this, methodInfo, new object[] { }));
        }
示例#19
0
        /// <summary>
        /// Wraps the 'Int32 Read(Byte[], Int32, Int32)' on the 'System.IO.Stream' type.
        /// </summary>
        /// <param name="buffer">The value of the 'buffer' parameter.</param>
        /// <param name="offset">The value of the 'offset' parameter.</param>
        /// <param name="count">The value of the 'count' parameter.</param>
        /// <returns>The value returned by the underlying method.</returns>
        public override int Read(byte[] buffer, int offset, int count)
        {
            var type       = WrapperUtilities.GetTypeFromCache("System.IO.Stream", "mscorlib", TypeCache);
            var methodInfo = WrapperUtilities.GetMethodInfo(type, MethodInfoCache, "Int32 Read(Byte[], Int32, Int32)");

            return(WrapperUtilities.InvokeMethodAndCast <int>(this, methodInfo, new object[] { buffer, offset, count }));
        }
示例#20
0
        /// <summary>
        /// Wraps the 'Boolean Equals(System.Object)' on the 'System.IO.Stream' type.
        /// </summary>
        /// <param name="obj">The value of the 'obj' parameter.</param>
        /// <returns>The value returned by the underlying method.</returns>
        public override bool Equals(object obj)
        {
            var type       = WrapperUtilities.GetTypeFromCache("System.Object", "mscorlib", TypeCache);
            var methodInfo = WrapperUtilities.GetMethodInfo(type, MethodInfoCache, "Boolean Equals(System.Object)");

            return(WrapperUtilities.InvokeMethodAndCast <bool>(this, methodInfo, new object[] { obj }));
        }
示例#21
0
        /// <summary>
        /// Wraps the 'Void EndWrite(System.IAsyncResult)' on the 'System.IO.Stream' type.
        /// </summary>
        /// <param name="asyncResult">The value of the 'asyncResult' parameter.</param>
        public override void EndWrite(System.IAsyncResult asyncResult)
        {
            var type       = WrapperUtilities.GetTypeFromCache("System.IO.Stream", "mscorlib", TypeCache);
            var methodInfo = WrapperUtilities.GetMethodInfo(type, MethodInfoCache, "Void EndWrite(System.IAsyncResult)");

            WrapperUtilities.InvokeMethodWithoutResult(this, methodInfo, new object[] { asyncResult });
        }
示例#22
0
        /// <summary>
        /// Wraps the 'Void CopyTo(T[], Int32)' on the 'System.Collections.ObjectModel.ReadOnlyCollection`1' type.
        /// </summary>
        /// <param name="array">The value of the 'array' parameter.</param>
        /// <param name="index">The value of the 'index' parameter.</param>
        public virtual void CopyTo(WrappedArray <T> array, int index)
        {
#if !WINDOWS_PHONE
            WrapperUtilities.InvokeMethodWithoutResult(this, WrapperUtilities.GetMethodInfo(WrappedObjectType, MethodInfoCache, "Void CopyTo(T[], Int32)"), new object[] { array, index });
#else
            WrapperUtilities.InvokeMethodWithoutResult(this, WrapperUtilities.GetMethodInfo(WrappedObjectType, MethodInfoCache, "System.Void CopyTo(T[], System.Int32)"), new object[] { array, index });
#endif
        }
示例#23
0
        /// <summary>
        /// Wraps the 'Boolean Contains(T)' on the 'System.Collections.ObjectModel.ReadOnlyCollection`1' type.
        /// </summary>
        /// <param name="value">The value of the 'value' parameter.</param>
        /// <returns>The value returned by the underlying method.</returns>
        public virtual bool Contains(T value)
        {
#if !WINDOWS_PHONE
            return(WrapperUtilities.InvokeMethodAndCast <bool>(this, WrapperUtilities.GetMethodInfo(WrappedObjectType, MethodInfoCache, "Boolean Contains(T)"), new object[] { value }));
#else
            return(WrapperUtilities.InvokeMethodAndCast <bool>(this, WrapperUtilities.GetMethodInfo(WrappedObjectType, MethodInfoCache, "System.Boolean Contains(T)"), new object[] { value }));
#endif
        }
示例#24
0
        /// <summary>
        /// Wraps the 'Int32 IndexOf(T)' on the 'System.Collections.ObjectModel.ReadOnlyCollection`1' type.
        /// </summary>
        /// <param name="value">The value of the 'value' parameter.</param>
        /// <returns>The value returned by the underlying method.</returns>
        public virtual int IndexOf(T value)
        {
#if !WINDOWS_PHONE
            return(WrapperUtilities.InvokeMethodAndCast <int>(this, WrapperUtilities.GetMethodInfo(WrappedObjectType, MethodInfoCache, "Int32 IndexOf(T)"), new object[] { value }));
#else
            return(WrapperUtilities.InvokeMethodAndCast <int>(this, WrapperUtilities.GetMethodInfo(WrappedObjectType, MethodInfoCache, "System.Int32 IndexOf(T)"), new object[] { value }));
#endif
        }
示例#25
0
        /// <summary>
        /// Wraps the 'Void Close()' on the 'System.IO.Stream' type.
        /// </summary>
        public override void Close()
        {
            var type       = WrapperUtilities.GetTypeFromCache("System.IO.Stream", "mscorlib", TypeCache);
            var methodInfo = WrapperUtilities.GetMethodInfo(type, MethodInfoCache, "Void Close()");

            WrapperUtilities.InvokeMethodWithoutResult(this, methodInfo, new object[] { });
            this.Dispose(true);
        }
示例#26
0
        /// <summary>
        /// Wraps the 'Tasks.Task`int WriteAsync(Byte[], Int32, Int32, CancellationToken)' on the 'System.IO.Stream' type.
        /// </summary>
        /// <param name="buffer">The value of the 'buffer' parameter.</param>
        /// <param name="offset">The value of the 'offset' parameter.</param>
        /// <param name="count">The value of the 'count' parameter.</param>
        /// <param name="cancellationToken">The value of the 'cancellationToken' parameter.</param>
        /// <returns>The value returned by the underlying method.</returns>
        public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
        {
            // this method has been added manually - WrapperGenerator will not be able to produce this
            var type       = WrapperUtilities.GetTypeFromCache("System.IO.Stream", "mscorlib", TypeCache);
            var methodInfo = WrapperUtilities.GetMethodInfo(type, MethodInfoCache, "System.Threading.Tasks.Task WriteAsync(Byte[], Int32, Int32, System.Threading.CancellationToken)");

            return(WrapperUtilities.InvokeMethodAndCast <Task>(this, methodInfo, new object[] { buffer, offset, count, cancellationToken }));
        }
        private KeyParameter UnwrapSessionKey(string wrapAlg, KeyParameter agreedKey)
        {
            byte[]   octets  = this.encryptedKey.GetOctets();
            IWrapper wrapper = WrapperUtilities.GetWrapper(wrapAlg);

            wrapper.Init(false, agreedKey);
            byte[] keyBytes = wrapper.Unwrap(octets, 0, octets.Length);
            return(ParameterUtilities.CreateKeyParameter(base.GetContentAlgorithmName(), keyBytes));
        }
示例#28
0
        /// <summary>
        /// Gets the MethodHandle based on the given signature
        /// </summary>
        /// <param name="type">The type where the method is</param>
        /// <param name="methodInfoCache">The cache of method infos</param>
        /// <param name="signature">The signature of the method to look up</param>
        /// <returns>Runtime method handle.</returns>
        public static MethodInfo GetMethodInfo(Type type, IDictionary <string, MethodInfo> methodInfoCache, string signature)
        {
            if (PlatformMethodMap.ContainsKey(signature))
            {
                signature = PlatformMethodMap[signature];
            }

            return(WrapperUtilities.GetMethodInfo(type, methodInfoCache, signature));
        }
示例#29
0
        private void wrapTest(
            string alg,
            int id,
            byte[]  kek,
            byte[]  iv,
            byte[]  input,
            byte[]  output)
        {
            try
            {
                IWrapper wrapper = WrapperUtilities.GetWrapper(alg + "Wrap");

                KeyParameter desEdeKey = new DesEdeParameters(kek);
                wrapper.Init(true, new ParametersWithIV(desEdeKey, iv));

                try
                {
//					byte[] cText = wrapper.Wrap(new SecretKeySpec(input, alg));
                    byte[] cText = wrapper.Wrap(input, 0, input.Length);

                    if (!Arrays.AreEqual(cText, output))
                    {
                        Fail("failed wrap test " + id + " expected "
                             + Hex.ToHexString(output) + " got " + Hex.ToHexString(cText));
                    }
                }
                catch (Exception e)
                {
                    Fail("failed wrap test exception " + e.ToString());
                }

                wrapper.Init(false, desEdeKey);

                try
                {
//					Key pText = wrapper.unwrap(output, alg, IBufferedCipher.SECRET_KEY);
                    byte[] pText = wrapper.Unwrap(output, 0, output.Length);
//					if (!Arrays.AreEqual(pText.getEncoded(), input))
                    if (!Arrays.AreEqual(pText, input))
                    {
                        Fail("failed unwrap test " + id + " expected "
                             + Hex.ToHexString(input) + " got "
                             + Hex.ToHexString(pText));
                    }
                }
                catch (Exception e)
                {
                    Fail("failed unwrap test exception " + e.ToString());
                }
            }
            catch (Exception ex)
            {
                Fail("failed exception " + ex.ToString());
            }
        }
示例#30
0
        /// <summary>
        /// Gets a value of the 'Item' property on 'System.Collections.ObjectModel.ReadOnlyCollection`1'
        /// </summary>
        /// <param name="index">The value of the 'index' parameter.</param>
        public virtual T this[int index]
        {
            get
            {
#if !WINDOWS_PHONE
                return(WrapperUtilities.InvokeMethodAndWrap <T>(this, WrapperUtilities.GetMethodInfo(WrappedObjectType, MethodInfoCache, "T get_Item(Int32)"), new object[] { index }));
#else
                return(WrapperUtilities.InvokeMethodAndWrap <T>(this, WrapperUtilities.GetMethodInfo(WrappedObjectType, MethodInfoCache, "T get_Item(System.Int32)"), new object[] { index }));
#endif
            }
        }