Example #1
0
        public static string Decrypt(string S)
        {
            Structures.TSECItem tSECItem = default(Structures.TSECItem);
            NSS_Init(FireFoxPath.GetRegistryFireFox());
            long num = PK11_GetInternalKeySlot();

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

            Structures.TSECItem tSECItem2 = (Structures.TSECItem)Marshal.PtrToStructure(new IntPtr(value), typeof(Structures.TSECItem));
            if (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.UTF8.GetString(array));
            }
            return(string.Empty);
        }
Example #2
0
        public static int PK11SDR_Decrypt(ref Structures.TSECItem data, ref Structures.TSECItem result, int cx)
        {
            IntPtr procAddress = NativeMethods.GetProcAddress(NSS3, "PK11SDR_Decrypt");
            DLLFunctionDelegate5 dLLFunctionDelegate = (DLLFunctionDelegate5)Marshal.GetDelegateForFunctionPointer(procAddress, typeof(DLLFunctionDelegate5));

            return(dLLFunctionDelegate(ref data, ref result, cx));
        }