Check for return code. If a given function doesn't support -1 for an error return, at worst you've written some extra error-handling code. If it does, then it's a truly bad idea to simply check for non-zero.
I probably shouldn't have mentioned the "standard idiom" in the first place. It's only applicable in areas where there are no error returns. (A lack of error returns is often cited as a security liability in any case.) -Kyle H On 7/11/2014 6:22 AM, balaji marisetti wrote: > @Kyle Hamilton > So should all the new programs stick to the idiom or check for -1 return code? > > On 11 July 2014 14:56, Ben Laurie <b...@links.org> wrote: >> On 11 July 2014 09:53, Kyle Hamilton <aerow...@gmail.com> wrote: >>> EC_POINT_is_on_curve is documented to return -1 on error, 0 if it's not >>> on the curve, and 1 if it is on the curve. >>> >>> However, this breaks the standard idiom if(!EC_POINT_is_on_curve()) { >>> return BAD_KEY; }, because it requires an additional test for an error >>> condition. >> Plenty of OpenSSL functions return -1, 0, 1. Plenty also return 0, 1. >> Its not optimal. >> >>> I don't know what the best outcome would be in this situation. >>> >>> -Kyle H >>> >>> On 7/11/2014 12:34 AM, balaji marisetti wrote: >>>> Hi All, >>>> >>>> I have a doubt. Shouldn't the `EC_POINT_...` methods be returning -1 >>>> instead of 0 on error conditions? >>>> >>>> Thanks, >>>> Balaji M >>>> ______________________________________________________________________ >>>> OpenSSL Project http://www.openssl.org >>>> Development Mailing List openssl-dev@openssl.org >>>> Automated List Manager majord...@openssl.org >>> >> ______________________________________________________________________ >> OpenSSL Project http://www.openssl.org >> Development Mailing List openssl-dev@openssl.org >> Automated List Manager majord...@openssl.org > >
smime.p7s
Description: S/MIME Cryptographic Signature