I'm trying to implement a diffie-hellman key exchange. The server side is written in Java and it is already in production. The C++ version gets its public keys rejected by the Java side. I've noticed that all the Java base64 public keys start with "MII", while in C++ do not. Maybe, the "raw" c++ public key should be converted into any format previously. How to make a SecByteBlock Cryptopp object in base64 compatible with the Java version?
Java:
PublicKey pubKey = keyPair.getPublic();
String pubKeyBase64 = Base64.getEncoder().encodeToString(pubKey.getEncoded());
C++:
SecByteBlock pubKey(dh.PublicKeyLength());
string base64Key;
Base64Encoder b(new StringSink(base64Key));
b.Put(pubKey.data(), pubKey.size());
b.MessageEnd();
Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire