I am struggling like mad, I have an existing system using tomlibcrypt to verify a key agreement, and when running key agreement in openSSL the two agree byte for byte on the shared key. However when using BouncyCastle, I absolutely am unable to come up with the same result. I've tried various things, but essentially variations on:

var agree = new ECDHBasicAgreement(); agree.Init(privateKey); return agree.CalculateAgreement(otherPublicKey).ToByteArrayUnsigned();

The keys are being read from raw bytes and converted to BC style keys using prime256v1. (32 bytes private, 64 bytes public)

Any pointers or help here would be massively appreciated, I'm tearing my hair out!

put on hold as off-topic by Maarten Bodewes, Ella Rose, Meir Maor, e-sushi Aug 12 at 13:11

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Programming questions are off-topic even if you are writing or debugging cryptographic code. Unless your question is specifically about how the cryptographic algorithm, protocol or side-channel (mitigation) works, you should look into asking on Stack Overflow instead." – Maarten Bodewes, Ella Rose, Meir Maor, e-sushi
If this question can be reworded to fit the rules in the help center, please edit the question.

  • It sounds like one of Bouncy Castle or OpenSSL/TomLibCrypt aren't following the protocol. – user2768 Aug 10 at 10:48
  • I'm inclined to trust OpenSSL, really can't figure it out. We're now looking into if this is a potential byte order issue or if BC is doing some hashing or KD that OpenSSL isn't by default. – Dan Aug 10 at 12:12
  • 2
    This should be posted on StackOverflow instead, with a minimal code sample for OpenSSL and/or libtomcrypt as well as Bouncy Castle. With the given info we don't know where the three implementations differ. Sample input / output should also be provided. – Maarten Bodewes Aug 11 at 11:30

Browse other questions tagged or ask your own question.