public virtual byte[] ProcessBlock(byte[] inBytes, int inOff, int length)
        {
            //IL_000d: Unknown result type (might be due to invalid IL or missing references)
            if (key == null)
            {
                throw new InvalidOperationException("NaccacheStern engine not initialised");
            }
            if (length > GetInputBlockSize() + 1)
            {
                throw new DataLengthException("input too large for Naccache-Stern cipher.\n");
            }
            if (!forEncryption && length < GetInputBlockSize())
            {
                throw new InvalidCipherTextException("BlockLength does not match modulus for Naccache-Stern cipher.\n");
            }
            BigInteger bigInteger = new BigInteger(1, inBytes, inOff, length);

            if (forEncryption)
            {
                return(Encrypt(bigInteger));
            }
            global::System.Collections.IList  list = Platform.CreateArrayList();
            NaccacheSternPrivateKeyParameters naccacheSternPrivateKeyParameters = (NaccacheSternPrivateKeyParameters)key;

            global::System.Collections.IList smallPrimesList = naccacheSternPrivateKeyParameters.SmallPrimesList;
            for (int i = 0; i < ((global::System.Collections.ICollection)smallPrimesList).get_Count(); i++)
            {
                BigInteger bigInteger2 = bigInteger.ModPow(naccacheSternPrivateKeyParameters.PhiN.Divide((BigInteger)smallPrimesList.get_Item(i)), naccacheSternPrivateKeyParameters.Modulus);
                global::System.Collections.IList list2 = lookup[i];
                if (((global::System.Collections.ICollection)lookup[i]).get_Count() != ((BigInteger)smallPrimesList.get_Item(i)).IntValue)
                {
                    throw new InvalidCipherTextException(string.Concat(new object[6]
                    {
                        "Error in lookup Array for ",
                        ((BigInteger)smallPrimesList.get_Item(i)).IntValue,
                        ": Size mismatch. Expected ArrayList with length ",
                        ((BigInteger)smallPrimesList.get_Item(i)).IntValue,
                        " but found ArrayList of length ",
                        ((global::System.Collections.ICollection)lookup[i]).get_Count()
                    }));
                }
                int num = list2.IndexOf((object)bigInteger2);
                if (num == -1)
                {
                    throw new InvalidCipherTextException("Lookup failed");
                }
                list.Add((object)BigInteger.ValueOf(num));
            }
            BigInteger bigInteger3 = chineseRemainder(list, smallPrimesList);

            return(bigInteger3.ToByteArray());
        }
Beispiel #2
0
        private static int IndexOf7(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle value)
        {
            // (Lsystem/Object;)I
            // (LSystem/Object;)I
            global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp);
            int @__return = default(int);

            try {
                global::System.Collections.IList @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C <global::System.Collections.IList>(@__env, @__obj);
                @__return = ((int)(@__real.IndexOf(global::net.sf.jni4net.utils.Convertor.FullJ2C <object>(@__env, value))));
            }catch (global::System.Exception __ex) { @__env.ThrowExisting(__ex); }
            return(@__return);
        }
Beispiel #3
0
        public static PgpPublicKey RemoveCertification(PgpPublicKey key, PgpSignature certification)
        {
            PgpPublicKey pgpPublicKey = new PgpPublicKey(key);

            global::System.Collections.IList list = ((pgpPublicKey.subSigs != null) ? pgpPublicKey.subSigs : pgpPublicKey.keySigs);
            int  num  = list.IndexOf((object)certification);
            bool flag = num >= 0;

            if (flag)
            {
                list.RemoveAt(num);
            }
            else
            {
                {
                    global::System.Collections.IEnumerator enumerator = key.GetUserIds().GetEnumerator();
                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            string id = (string)enumerator.get_Current();
                            {
                                global::System.Collections.IEnumerator enumerator2 = key.GetSignaturesForId(id).GetEnumerator();
                                try
                                {
                                    while (enumerator2.MoveNext())
                                    {
                                        object current = enumerator2.get_Current();
                                        if (certification == current)
                                        {
                                            flag         = true;
                                            pgpPublicKey = RemoveCertification(pgpPublicKey, id, certification);
                                        }
                                    }
                                }
                                finally
                                {
                                    global::System.IDisposable disposable2 = enumerator2 as global::System.IDisposable;
                                    if (disposable2 != null)
                                    {
                                        disposable2.Dispose();
                                    }
                                }
                            }
                        }
                    }
                    finally
                    {
                        global::System.IDisposable disposable = enumerator as global::System.IDisposable;
                        if (disposable != null)
                        {
                            disposable.Dispose();
                        }
                    }
                }
                if (!flag)
                {
                    global::System.Collections.IEnumerator enumerator = key.GetUserAttributes().GetEnumerator();
                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            PgpUserAttributeSubpacketVector userAttributes = (PgpUserAttributeSubpacketVector)enumerator.get_Current();
                            {
                                global::System.Collections.IEnumerator enumerator2 = key.GetSignaturesForUserAttribute(userAttributes).GetEnumerator();
                                try
                                {
                                    while (enumerator2.MoveNext())
                                    {
                                        object current2 = enumerator2.get_Current();
                                        if (certification == current2)
                                        {
                                            flag         = true;
                                            pgpPublicKey = RemoveCertification(pgpPublicKey, userAttributes, certification);
                                        }
                                    }
                                }
                                finally
                                {
                                    global::System.IDisposable disposable4 = enumerator2 as global::System.IDisposable;
                                    if (disposable4 != null)
                                    {
                                        disposable4.Dispose();
                                    }
                                }
                            }
                        }
                        return(pgpPublicKey);
                    }
                    finally
                    {
                        global::System.IDisposable disposable3 = enumerator as global::System.IDisposable;
                        if (disposable3 != null)
                        {
                            disposable3.Dispose();
                        }
                    }
                }
            }
            return(pgpPublicKey);
        }
 public override int IndexOf(object o)
 {
     return(l.IndexOf(o));
 }