Skip to content

Instantly share code, notes, and snippets.

@kaworu
Created July 18, 2018 08:16
Show Gist options
  • Save kaworu/4f5e11de81798002096f694ed4861f74 to your computer and use it in GitHub Desktop.
Save kaworu/4f5e11de81798002096f694ed4861f74 to your computer and use it in GitHub Desktop.
#include <openssl/bn.h>
int
main(void)
{
BIGNUM *z, *mz;
z = BN_new();
if (BN_zero(z) == 0)
return (1);
mz = BN_new();
if (BN_dec2bn(&mz, "-0") == 0)
return (1);
printf("BN_is_zero(BN_zero()): %s\n", BN_is_zero(z) ? "yes" : "no");
printf("BN_is_zero(BN_dec2bn(\"-0\")): %s\n", BN_is_zero(mz) ? "yes" : "no");
printf("BN_cmp(BN_zero(), BN_dec2bn(\"-0\")): %d\n", BN_cmp(z, mz));
return (0);
}
@kaworu
Copy link
Author

kaworu commented Jul 18, 2018

cc BN_zero.c -lcrypto && ./a.out

Output:

BN_is_zero(BN_zero()): yes
BN_is_zero(BN_dec2bn("-0")): yes
BN_cmp(BN_zero(), BN_dec2bn("-0")): 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment