Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

internal / underlying blake2 symbols aren't mangled or private #109

Open
cartazio opened this issue Nov 3, 2016 · 19 comments
Open

internal / underlying blake2 symbols aren't mangled or private #109

cartazio opened this issue Nov 3, 2016 · 19 comments
Assignees

Comments

@cartazio
Copy link

cartazio commented Nov 3, 2016

I'm helping some folks with some crypto heavy code and this change would make our lives much easier. If I helped get this sorted, would it be possible to turn around a release with that hange pretty fast ?

@cartazio
Copy link
Author

cartazio commented Nov 3, 2016

as a bit of context haskell-hvr/argon2#10 and


duplicate symbol _blake2b_init_key in:
    /Users/carter/.cabal/store/ghc-8.0.1/cryptonite-0.20-0af5802ff1a1deb4cb611283f80d9b336faa42a9e6e78f7dbab10d01ae0d2eeb/lib/libHScryptonite-0.20-0af5802ff1a1deb4cb611283f80d9b336faa42a9e6e78f7dbab10d01ae0d2eeb.a(blake2b.o)
    /Users/carter/.cabal/store/ghc-8.0.1/argon2-1.2.0-b9f6a4cdf7fc9c099739f9e37ad85d14069af01351740db465356c55afa097c1/lib/libHSargon2-1.2.0-b9f6a4cdf7fc9c099739f9e37ad85d14069af01351740db465356c55afa097c1.a(blake2b.o)
duplicate symbol _blake2b_init in:
    /Users/carter/.cabal/store/ghc-8.0.1/cryptonite-0.20-0af5802ff1a1deb4cb611283f80d9b336faa42a9e6e78f7dbab10d01ae0d2eeb/lib/libHScryptonite-0.20-0af5802ff1a1deb4cb611283f80d9b336faa42a9e6e78f7dbab10d01ae0d2eeb.a(blake2b.o)
    /Users/carter/.cabal/store/ghc-8.0.1/argon2-1.2.0-b9f6a4cdf7fc9c099739f9e37ad85d14069af01351740db465356c55afa097c1/lib/libHSargon2-1.2.0-b9f6a4cdf7fc9c099739f9e37ad85d14069af01351740db465356c55afa097c1.a(blake2b.o)
duplicate symbol _blake2b_init_param in:
    /Users/carter/.cabal/store/ghc-8.0.1/cryptonite-0.20-0af5802ff1a1deb4cb611283f80d9b336faa42a9e6e78f7dbab10d01ae0d2eeb/lib/libHScryptonite-0.20-0af5802ff1a1deb4cb611283f80d9b336faa42a9e6e78f7dbab10d01ae0d2eeb.a(blake2b.o)
    /Users/carter/.cabal/store/ghc-8.0.1/argon2-1.2.0-b9f6a4cdf7fc9c099739f9e37ad85d14069af01351740db465356c55afa097c1/lib/libHSargon2-1.2.0-b9f6a4cdf7fc9c099739f9e37ad85d14069af01351740db465356c55afa097c1.a(blake2b.o)
duplicate symbol _blake2b_final in:
    /Users/carter/.cabal/store/ghc-8.0.1/cryptonite-0.20-0af5802ff1a1deb4cb611283f80d9b336faa42a9e6e78f7dbab10d01ae0d2eeb/lib/libHScryptonite-0.20-0af5802ff1a1deb4cb611283f80d9b336faa42a9e6e78f7dbab10d01ae0d2eeb.a(blake2b.o)
    /Users/carter/.cabal/store/ghc-8.0.1/argon2-1.2.0-b9f6a4cdf7fc9c099739f9e37ad85d14069af01351740db465356c55afa097c1/lib/libHSargon2-1.2.0-b9f6a4cdf7fc9c099739f9e37ad85d14069af01351740db465356c55afa097c1.a(blake2b.o)
duplicate symbol _blake2b_update in:
    /Users/carter/.cabal/store/ghc-8.0.1/cryptonite-0.20-0af5802ff1a1deb4cb611283f80d9b336faa42a9e6e78f7dbab10d01ae0d2eeb/lib/libHScryptonite-0.20-0af5802ff1a1deb4cb611283f80d9b336faa42a9e6e78f7dbab10d01ae0d2eeb.a(blake2b.o)
    /Users/carter/.cabal/store/ghc-8.0.1/argon2-1.2.0-b9f6a4cdf7fc9c099739f9e37ad85d14069af01351740db465356c55afa097c1/lib/libHSargon2-1.2.0-b9f6a4cdf7fc9c099739f9e37ad85d14069af01351740db465356c55afa097c1.a(blake2b.o)
duplicate symbol _blake2b in:
    /Users/carter/.cabal/store/ghc-8.0.1/cryptonite-0.20-0af5802ff1a1deb4cb611283f80d9b336faa42a9e6e78f7dbab10d01ae0d2eeb/lib/libHScryptonite-0.20-0af5802ff1a1deb4cb611283f80d9b336faa42a9e6e78f7dbab10d01ae0d2eeb.a(blake2b.o)
    /Users/carter/.cabal/store/ghc-8.0.1/argon2-1.2.0-b9f6a4cdf7fc9c099739f9e37ad85d14069af01351740db465356c55afa097c1/lib/libHSargon2-1.2.0-b9f6a4cdf7fc9c099739f9e37ad85d14069af01351740db465356c55afa097c1.a(blake2b.o)
ld: 6 duplicate symbols for architecture x86_64
clang-3.8: error: linker command failed with exit code 1 (use -v to see invocation)
`clang' failed in phase `Linker'. (Exit code: 1)

@cartazio
Copy link
Author

cartazio commented Nov 3, 2016

cc @vincenthz @glguy @yogsototh

@cartazio cartazio changed the title Add cryptonite_ prefix to all nonstatic / exported c symbols internal / underlying blake2 symbols aren't mangled or private Nov 3, 2016
@cartazio
Copy link
Author

cartazio commented Nov 3, 2016

cryptonite/cryptonite.cabal

Lines 266 to 277 in 3c087f0

if arch(x86_64) || flag(support_blake2_sse)
C-sources: cbits/blake2/sse/blake2s.c
, cbits/blake2/sse/blake2sp.c
, cbits/blake2/sse/blake2b.c
, cbits/blake2/sse/blake2bp.c
include-dirs: cbits/blake2/sse
else
C-sources: cbits/blake2/ref/blake2s-ref.c
, cbits/blake2/ref/blake2sp-ref.c
, cbits/blake2/ref/blake2b-ref.c
, cbits/blake2/ref/blake2bp-ref.c
include-dirs: cbits/blake2/ref

seems to be the offending bit,

and those implementations dont have the name mangling and they're not static function impls

@centromere centromere self-assigned this Nov 3, 2016
@centromere
Copy link
Member

@cartazio What is the output of:

readelf -s dist/build/libHScryptonite-0.20-....so | grep blake2b_init_key

@cartazio
Copy link
Author

cartazio commented Nov 3, 2016

i'm on mac osx....

On Thu, Nov 3, 2016 at 2:06 PM, John Galt [email protected] wrote:

@cartazio
Copy link
Author

cartazio commented Nov 3, 2016

what would the appropriate command analogue there?

On Thu, Nov 3, 2016 at 2:35 PM, Carter Schonwald <[email protected]

wrote:

i'm on mac osx....

On Thu, Nov 3, 2016 at 2:06 PM, John Galt [email protected]
wrote:

@centromere
Copy link
Member

I don't use OSX so I don't know. This could be helpful though: http://stackoverflow.com/questions/3286675/readelf-like-tool-for-mac-os-x

@vincenthz
Copy link
Member

might be much faster to port the tiny argon library (specially considering that blake is already in) to cryptonite than muck around the blake C files; Obviously would be nice to solve the exports list problem too, but need much more careful thoughts.

@cartazio
Copy link
Author

cartazio commented Nov 3, 2016

Port?

I do know that if Argon2 is set to dyload the libargon that the collision
doesn't happen.

But yeah, I'll get yah yer info

On Thursday, November 3, 2016, Vincent Hanquez [email protected]
wrote:

might be much faster to port the tiny argon library (specially considering
that blake is already in) to cryptonite than muck around the blake C files;
Obviously would be nice to solve the exports list problem too, but need
much more careful thoughts.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#109 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAAQwmETMaiLsAMGLN5Z4CA-VolOvbfPks5q6ljdgaJpZM4KoaO-
.

@cartazio
Copy link
Author

cartazio commented Nov 3, 2016

That said, I'm not sure if OS X supports the hidden symbol attribute on
static libs, so it might be worth adding name mangling to hidden but not
static symbols ...

On Thursday, November 3, 2016, Carter Schonwald [email protected]
wrote:

Port?

I do know that if Argon2 is set to dyload the libargon that the collision
doesn't happen.

But yeah, I'll get yah yer info

On Thursday, November 3, 2016, Vincent Hanquez <[email protected]
javascript:_e(%7B%7D,'cvml','[email protected]');> wrote:

might be much faster to port the tiny argon library (specially
considering that blake is already in) to cryptonite than muck around the
blake C files; Obviously would be nice to solve the exports list problem
too, but need much more careful thoughts.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#109 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAAQwmETMaiLsAMGLN5Z4CA-VolOvbfPks5q6ljdgaJpZM4KoaO-
.

@vincenthz
Copy link
Member

port = adding argon2 in cryptonite.

@centromere
Copy link
Member

@cartazio Is this still an issue for you?

@cartazio
Copy link
Author

cartazio commented Dec 20, 2016 via email

@centromere
Copy link
Member

I think the proper solution is to ensure that the symbols are hidden properly. Is there really no way to do this with static libraries on OSX?

@cartazio
Copy link
Author

cartazio commented Dec 20, 2016 via email

@centromere
Copy link
Member

For the blake2 source files in cryptonite, everywhere you see __attribute__ ((visibility ("hidden"))), could you replace it with __attribute__((weak)) and attempt to recompile?

@cartazio
Copy link
Author

cartazio commented Dec 21, 2016 via email

@vincenthz
Copy link
Member

argon2 is now in cryptonite

@cartazio
Copy link
Author

cartazio commented Feb 24, 2017 via email

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

No branches or pull requests

3 participants