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

Resolving name clashes with OpenSSL and others #30

Merged
merged 1 commit into from
Sep 27, 2016

Conversation

sruesch
Copy link
Contributor

@sruesch sruesch commented Apr 16, 2016

As stated in issue #16, there are some name clashes between Relic and OpenSSL, especially regarding BN_BITS, BN_BYTES and rsa_st, which are resolved here.

@tfar
Copy link
Contributor

tfar commented May 3, 2016

From my experience a project name prefix is more common than adding the project name as a suffix to public symbols. Would it be much work to change this? Other than that the change looks okay. Will try to fix our travis later and test this PR.

@dfaranha
Copy link
Contributor

dfaranha commented May 3, 2016

I would prefer a prefix, but inserting RELIC_ before everything would require rethinking some symbols. It's simply too long and verbose.

@tfar
Copy link
Contributor

tfar commented May 3, 2016

@dfaranha It is verbose, but the only way to avoid symbol conflicts. Is this mainly a usability concern of yours about the RELIC_? nacl for example uses a crypto_ prefix which is even longer.

@dfaranha
Copy link
Contributor

dfaranha commented May 3, 2016

We could try RLC_ and shorten some other symbols to reduce impact. Configuration is still a problem, RLC_NONE makes no sense.

@tfar
Copy link
Contributor

tfar commented May 3, 2016

Fine with that as long as we document it in our README that this is the library prefix of RELIC. It might not be obvious.

@conradoplg
Copy link
Contributor

IMHO verbosity is a sad requirement of coding in C. It seems to me that the readability of RELIC is better than 2 characters saved by RLC...
And it would be even better to prefix the configuration by their names, e.g. RELIC_ARCH_NONE

@dfaranha
Copy link
Contributor

dfaranha commented May 3, 2016

Thanks, Conrado! That makes more sense. This library needs a major refactoring any way to stay relevant, so this is the right time to make such decisions.

Should we also consider prefixing library functions or is the current situation good enough?

@tfar
Copy link
Contributor

tfar commented May 3, 2016

Well, consistency would be nice. So I'd suggest prefixing all symbols that are part of the public API. This does not mean it all has to happen at once.

@dfaranha
Copy link
Contributor

dfaranha commented May 3, 2016

I am asking because we already support prefixes fox functions with the LABEL config variable.

@conradoplg
Copy link
Contributor

Yes, I think prefixing everything would be better (or the "public API", but the problem is that almost everything is public...). The problem with LABEL is that the un-prefixed symbols are still defined as macros and could still clash with other stuff.
Maybe if in this refactoring we add support for multiple curves in the same compilation, then we won't need LABEL anymore... :D

@tfar
Copy link
Contributor

tfar commented May 4, 2016

Maybe if in this refactoring we add support for multiple curves in the same compilation, then we won't need LABEL anymore... :D

This would be quite some work, right? Especially with potential pre-computation tables, etc.

@dfaranha
Copy link
Contributor

dfaranha commented May 5, 2016

Yes. It will become slightly easier after we remove the memory allocators and some other slow functions.

@dschuermann
Copy link

So what's the requirement to get this merged into the current git master, omitting the idea to refactor other things like supported curves?
Prefix all names with "RELIC_" ?

@tfar
Copy link
Contributor

tfar commented May 5, 2016

I think so yes. For starters it should be enough to prefix just the conflicting symbols with RELIC_ and then merge this PR.

@sruesch
Copy link
Contributor Author

sruesch commented May 10, 2016

I have changed the suffix to a prefix, so now it's RELIC_ instead of _RELIC. Is it acceptable like this?

@@ -153,13 +153,13 @@ static void util(void) {
}

static void arith(void) {
eb_t p, q, r, t[EB_TABLE_MAX];
eb_t p, q, r, t[EB_RELIC_TABLE_MAX];
Copy link
Contributor

@tfar tfar May 10, 2016

Choose a reason for hiding this comment

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

Why was RELIC_ added in between instead of at the beginning, i.e. RELIC_EB_TABLE_MAX?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted to have RELIC_ with the context of TABLE, but if it's better as a proper prefix I can change it again?

Copy link
Contributor

Choose a reason for hiding this comment

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

It would seem more consistent I think. Just less to think about, if all RELIC symbols start with RELIC_. RELIC_EB_TABLE_MAX looks sensible to me. With that adjustment and the squashing mentioned by @dschuermann , this PR should be ready to merge. :)

@dschuermann
Copy link

@sruesch Better squash all commits to have only one commit, see http://blog.ona.io/general/2016/02/02/squashing-with-git-interactive-rebase.html

@sruesch
Copy link
Contributor Author

sruesch commented May 11, 2016

@dschuermann Thanks, I'll do that!

@sruesch
Copy link
Contributor Author

sruesch commented May 15, 2016

I have now changed all conflicting symbols so that they have the prefix RELIC_ as suggested and squashed the commits to only one commit. Is it acceptable like this?

@tfar
Copy link
Contributor

tfar commented May 16, 2016

From the changes made it sounds good. However, I'm seeing errors trying to build the default configuration (i.e. mkdir build && cd build && cmake .. && make):

Scanning dependencies of target test_fbx
[ 88%] Building C object test/CMakeFiles/test_fbx.dir/test_fbx.c.o
[ 88%] Linking C executable ../bin/test_fbx
[ 88%] Built target test_fbx
Scanning dependencies of target test_pc
[ 88%] Building C object test/CMakeFiles/test_pc.dir/test_pc.c.o
/Users/tobias/Development/rep/relic-toolkit/test/test_pc.c:371:9: error: use of undeclared identifier 'EP_RELIC_TABLE_MAX'
        g1_t t[RELIC_G1_TABLE];
               ^
/Users/tobias/Development/rep/relic-toolkit/include/relic_pc.h:85:26: note: expanded from macro 'RELIC_G1_TABLE'
#define RELIC_G1_TABLE                  CAT(G1_UPPER, _RELIC_TABLE_MAX)
                                        ^
/Users/tobias/Development/rep/relic-toolkit/include/relic_util.h:129:21: note: expanded from macro 'CAT'
#define CAT(A, B)                       _CAT(A, B)
                                        ^
/Users/tobias/Development/rep/relic-toolkit/include/relic_util.h:130:22: note: expanded from macro '_CAT'
#define _CAT(A, B)                      A ## B
                                        ^
<scratch space>:105:1: note: expanded from here
EP_RELIC_TABLE_MAX
^
…and more

@sruesch
Copy link
Contributor Author

sruesch commented May 17, 2016

@tfar Oh! Sorry, I'll take another look!

@dfaranha
Copy link
Contributor

This should be simple to address using the CAT macros to build RELIC_EP_TABLE_MAX.

@tfar
Copy link
Contributor

tfar commented Jun 14, 2016

@sruesch Any news on this PR?

@sruesch
Copy link
Contributor Author

sruesch commented Jul 1, 2016

@tfar Sorry for my late reponse! I'm currently working on another project, but as soon as I have some free time I'll fix the errors. I hope to get to this during this weekend.

@sruesch
Copy link
Contributor Author

sruesch commented Jul 27, 2016

@tfar I'm terribly sorry that it took me so long to come back to this! I have, as proposed, used the CAT macros to build RELIC_EP_TABLE_MAX. The current changed version compiles for me, please check again if this works for you, too, or if there are any more errors that I didn't catch. :)

@tfar
Copy link
Contributor

tfar commented Aug 30, 2016

Looks good to me, other than test_mdfailing https://travis-ci.org/relic-toolkit/relic/jobs/147748126 . But this could be unrelated to your change and probably was broken before (we should fix our CI script to report this as error on GitHub).
A local run on OS X 10.11 shows also two tests failing:

The following tests FAILED:
      5 - test_fpx (Failed)
     15 - test_md (Failed)

From my side I'm okay with merging this and fixing the broken unit tests later. What do you think @dfaranha ?

@tfar tfar merged commit 58e0956 into relic-toolkit:master Sep 27, 2016
@tfar
Copy link
Contributor

tfar commented Sep 27, 2016

Merged it. Will try to debug the unrelated failing unit tests this or next week.

@sruesch Thanks again for this PR.

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.

5 participants