<div dir="ltr">Tested on a separate machine (Ubuntu Jammy Jellyfish) that comes with OpenSSL 3.x installed and things worked as expected.<div><br></div><div>Probably something was screwed with my own build or the machine that has several OpenSSL versions.</div><div><br></div><div>Thanks for the help, and sorry for the inconvenience.</div><div><br></div><div>Cheers,</div><div>Jose</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 30 Nov 2021 at 15:09, Matt Caswell <<a href="mailto:matt@openssl.org">matt@openssl.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"><br>
<br>
On 30/11/2021 13:16, pepone.onrez wrote:<br>
> Getting some problems with OpenSSL 3.0, I have passwordError function, <br>
> to check if the last error was due to an invalid password and allow the <br>
> user to retry.<br>
> <br>
> <br>
> bool<br>
> passwordError()<br>
> {<br>
>      unsigned long error = ERR_peek_error();<br>
>      unsigned long lib = ERR_GET_LIB(error);<br>
>      unsigned long reason = ERR_GET_REASON(error);<br>
>      cerr << "error: " << error << endl;<br>
>      cerr << "lib: " << lib << endl;<br>
>      cerr << "reason: " << reason << endl;<br>
>      ERR_print_errors_fp(stdout);<br>
>      return (reason == PEM_R_BAD_BASE64_DECODE ||<br>
>              reason == PEM_R_BAD_DECRYPT ||<br>
>              reason == PEM_R_BAD_PASSWORD_READ ||<br>
>              reason == PEM_R_PROBLEMS_GETTING_PASSWORD ||<br>
>              reason == PKCS12_R_MAC_VERIFY_FAILURE);<br>
> }<br>
> <br>
> When I test with an invalid password I get<br>
> <br>
> error: 587686001<br>
> lib: 70<br>
> reason: 483441<br>
> error:23076071:PKCS12 routines:PKCS12_parse:mac verify failure<br>
<br>
That is really screwy output. Something is getting corrupted somewhere. <br>
"70" is not a valid error library and a reason code of 483441 is clearly <br>
wrong (reason codes are typically fairly small). Error 587686001 does <br>
correspond to the hex value 23076071 - but this is not an error value I <br>
would expect to see OpenSSL emitting.<br>
<br>
Could there be memory corruption occurring?? Perhaps run this through <br>
valgrind or similar and see if there are any hints.<br>
<br>
Matt<br>
<br>
<br>
<br>
> <br>
> <br>
> the description seems to match PKCS12_R_MAC_VERIFY_FAILURE but the <br>
> reason value doesn't<br>
> <br>
> include/openssl/pkcs12err.h<br>
> 39:# define PKCS12_R_MAC_VERIFY_FAILURE                      113<br>
> <br>
> Any ideas what I might be doing wrong here? this worked fine with 1.1.1 <br>
> before<br>
> <br>
> Cheers,<br>
> Jose<br>
</blockquote></div>