Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BN#mod_sqrt #553

Merged
merged 3 commits into from
Oct 17, 2022
Merged

Add BN#mod_sqrt #553

merged 3 commits into from
Oct 17, 2022

Conversation

btoews
Copy link
Contributor

@btoews btoews commented Oct 16, 2022

This PR adds support for BN_mod_sqrt as BN#mod_sqrt.

@rhenium
Copy link
Member

rhenium commented Oct 17, 2022

BN_mod_sqrt() has a different function signature. https://github.com/ruby/openssl/actions/runs/3260413057/jobs/5353954966#step:6:88

../../../../ext/openssl/ossl_bn.c: In function ‘ossl_bn_mod_sqrt’:
../../../../ext/openssl/ossl_bn.c:537:47: warning: ordered comparison of pointer with integer zero [-Wextra]
  537 |  if (BN_##func(result, bn1, bn2, ossl_bn_ctx) <= 0) { \
      |                                               ^~
../../../../ext/openssl/ossl_bn.c:585:1: note: in expansion of macro ‘BIGNUM_2c’
  585 | BIGNUM_2c(mod_sqrt)
      | ^~~~~~~~~
../../../../ext/openssl/ossl_bn.c: At top level:
cc1: warning: unrecognized command line option ‘-Wno-self-assign’
cc1: warning: unrecognized command line option ‘-Wno-parentheses-equality’
cc1: warning: unrecognized command line option ‘-Wno-constant-logical-operand’

@btoews
Copy link
Contributor Author

btoews commented Oct 17, 2022

Whoops. Sorry about that. The signature matches BN_mod_inverse, so I defined a new macro for these two methods. I named the macro BIGNUM_2cr (2 BN args, context, returns result). Is that okay, or would you prefer something different?

* bn.mod_sqrt(bn2) => aBN
*/
BIGNUM_2cr(mod_sqrt)

/*
* call-seq:
* bn.mod_inverse(bn2) => aBN
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably need a Document-method: to tell rdoc about this method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in 5befde7

@rhenium
Copy link
Member

rhenium commented Oct 17, 2022

Yes, that makes sense!

@rhenium rhenium merged commit 1ddbf28 into ruby:master Oct 17, 2022
@rhenium
Copy link
Member

rhenium commented Oct 17, 2022

Merged, thanks!

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

Successfully merging this pull request may close these issues.

2 participants