<div dir="ltr"><div dir="ltr"><div dir="ltr"><div></div><div>The code was using gpgme_io_write to write the passphrase followed by a null byte: <a href="https://github.com/wget/gpgme-sharp/blob/master/gpgme-sharp/Context.cs#L353-L354">https://github.com/wget/gpgme-sharp/blob/master/gpgme-sharp/Context.cs#L353-L354</a>. I changed it to gpgme_io_writen and newline. That code was written by someone else way back in 2013 so I wonder if it's been broken this entire time. Here's the changes I've made so far: <a href="https://github.com/wget/gpgme-sharp/compare/master...Daniel15:pinentry">https://github.com/wget/gpgme-sharp/compare/master...Daniel15:pinentry</a><br></div><div><br></div><div>Now I'm getting closer, but there's still some odd behaviour. The first time I run my test app, I get an access violation. However, it does spawn gpg-agent correctly, and the second time I run it, it works fine! I guess gpg-agent is properly receiving/caching the passphrase.<br></div><div><br></div><div><div><div dir="ltr" class="gmail_signature"><div dir="ltr"><span style="font-size:12.8px">--</span><br style="font-size:12.8px"><span style="font-size:12.8px">Regards,</span><br style="font-size:12.8px"><span style="font-size:12.8px">Daniel Lo Nigro</span><br style="font-size:12.8px"><a href="https://d.sb/" style="font-size:12.8px" target="_blank">https://d.sb/</a><span style="font-size:12.8px"> | </span><a href="http://twitter.com/Daniel15" style="font-size:12.8px" target="_blank">Twitter</a><span style="font-size:12.8px"> | </span><a href="http://www.facebook.com/daaniel" style="font-size:12.8px" target="_blank">Facebook</a><br></div></div></div><br></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Feb 5, 2019 at 10:32 AM Andre Heinecke <<a href="mailto:aheinecke@gnupg.org">aheinecke@gnupg.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
On Tuesday, February 5, 2019 6:21:45 PM GMT Daniel Lo Nigro wrote:<br>
> I'm using gpgme_set_pinentry_mode to set the pinentry mode to "loopback",<br>
> and the access violation is being encountered after my pinentry callback<br>
> returns. It works fine if I don't use loopback, and instead use the<br>
> system's pinentry mechanism.<br>
<br>
This sounds like your passphrase callback returns invalid data. I would have <br>
to look how the PassphraseResult is mapped in the C# bindings but from the C <br>
API:<br>
<br>
The user must write the passphrase, followed by a newline character,<br>
to the file descriptor @var{fd}. The function @code{gpgme_io_writen}<br>
should be used for the write operation. Note that if the user returns<br>
0 to indicate success, the user must at least write a newline<br>
character before returning from the callback.<br>
<br>
<br>
I do not think that you need to post your full code, but I would be interested <br>
in seeing your Passphrase callback.<br>
(Sorry If I'm the only one answering here but in the GnuPG Team I'm the Guy <br>
for "all things windows" ;-) )<br>
<br>
<br>
Regards,<br>
Andre<br>
<br>
-- <br>
GnuPG e.V., Rochusstr. 44, D-40479 Düsseldorf. VR 11482 Düsseldorf<br>
Vorstand: W.Koch, M.Gollowitzer, A.Heinecke. Mail: <a href="mailto:board@gnupg.org" target="_blank">board@gnupg.org</a><br>
Finanzamt D-Altstadt, St-Nr: 103/5923/1779. Tel: +49-2104-4938799</blockquote></div>