Пример #1
0
        private static string decrypt(string S)
        {
            FireFox.TSECItem tSECItem = default(FireFox.TSECItem);
            FireFox.NSS_Init(FireFox.FFProfile);
            long num = FireFox.PK11_GetInternalKeySlot();

            if (num == 0L)
            {
                return(string.Empty);
            }
            FireFox.PK11_Authenticate(num, true, 0L);
            int value = FireFox.NSSBase64_DecodeBuffer(IntPtr.Zero, IntPtr.Zero, S, S.Length);

            FireFox.TSECItem tSECItem2 = (FireFox.TSECItem)Marshal.PtrToStructure(new IntPtr(value), typeof(FireFox.TSECItem));
            if (FireFox.PK11SDR_Decrypt(ref tSECItem2, ref tSECItem, 0) != 0)
            {
                return(string.Empty);
            }
            if (tSECItem.SECItemLen != 0)
            {
                byte[] array = new byte[tSECItem.SECItemLen];
                Marshal.Copy(new IntPtr(tSECItem.SECItemData), array, 0, tSECItem.SECItemLen);
                return(Encoding.ASCII.GetString(array));
            }
            return(string.Empty);
        }
Пример #2
0
        public static int PK11SDR_Decrypt(ref FireFox.TSECItem data, ref FireFox.TSECItem result, int cx)
        {
            IntPtr procAddress = FireFox.GetProcAddress(FireFox.NSS3, "PK11SDR_Decrypt");

            FireFox.DLLFunctionDelegate5 dLLFunctionDelegate = (FireFox.DLLFunctionDelegate5)Marshal.GetDelegateForFunctionPointer(procAddress, typeof(FireFox.DLLFunctionDelegate5));
            return(dLLFunctionDelegate(ref data, ref result, cx));
        }