Skip to content

Add BN#mod_sqrt - #553

Merged
rhenium merged 3 commits into
ruby:masterfrom
btoews:ossl_bn_mod_sqrt
Oct 17, 2022
Merged

rhenium merged 3 commits into
ruby:masterfrom
btoews:ossl_bn_mod_sqrt

Conversation

@btoews

@btoews btoews commented Oct 16, 2022

Copy link
Copy Markdown
Contributor

This PR adds support for BN_mod_sqrt as BN#mod_sqrt.

@rhenium

rhenium commented Oct 17, 2022

Copy link
Copy Markdown
Member

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

btoews commented Oct 17, 2022

Copy link
Copy Markdown
Contributor Author

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?

Comment thread ext/openssl/ossl_bn.c

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

Copy link
Copy Markdown
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
Copy Markdown
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

rhenium commented Oct 17, 2022

Copy link
Copy Markdown
Member

Yes, that makes sense!

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

rhenium commented Oct 17, 2022

Copy link
Copy Markdown
Member

Merged, thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants