private string Decrypt(string cypherText) { var inStr = new StringBuilder(cypherText); var num = NSSBase64_DecodeBuffer(IntPtr.Zero, IntPtr.Zero, inStr, inStr.Length); var result = new TSECItem(); var structure = (TSECItem)Marshal.PtrToStructure(new IntPtr(num), typeof(TSECItem)); if ((uint)PK11SDR_Decrypt(ref structure, ref result, 0) > 0U || result.SECItemLen == 0) { return(null); } var numArray = new byte[result.SECItemLen]; Marshal.Copy(new IntPtr(result.SECItemData), numArray, 0, result.SECItemLen); return(Encoding.UTF8.GetString(numArray)); }
private int PK11SDR_Decrypt(ref TSECItem data, ref TSECItem result, int cx) { return(((PK11SDR_DecryptPtr)Marshal.GetDelegateForFunctionPointer( GetProcAddress(_nssModule, nameof(PK11SDR_Decrypt)), typeof(PK11SDR_DecryptPtr)))(ref data, ref result, cx)); }