Bonjour,
Je suis actuellement entrain de tenter de sérialiser le paquet 4, pour ce faire, j'appelle donc la fonction generateCredentials et ensuite encrypt credentials qui sont dans l'ordre:
Cliquez pour révéler
Cliquez pour masquer
QList<int> RsaManager::generateCredentials(const QString &salt, const QString &username, const QString &password)
{
MessageWriter temp;
temp.writeUTFBytes(salt.toStdString().c_str());
temp.writeByte(username.size());
temp.writeUTFBytes(username.toStdString().c_str());
temp.writeUTFBytes(password.toStdString().c_str());
QByteArray credentials(temp.getBuffer(),temp.getSize());
credentials = loginPublicKeyEncrypt(credentials);
MessageReader reader(credentials.data());
m_credentials.clear();
for(int i = 0; i < credentials.size(); i++)
{
char data = reader.readByte();
m_credentials = data;
}
foreach (int number, m_credentials)
qDebug()<<number;
return m_credentials;
}
et
Cliquez pour révéler
Cliquez pour masquer
QByteArray RsaManager::loginPublicKeyEncrypt(const QByteArray &credentials) {
char * loginPublicKeyByte = (char *) malloc(m_loginPublicKey.size());
strcpy(loginPublicKeyByte, m_loginPublicKey.toStdString().c_str());
BIO *bp_login = BIO_new_mem_buf(loginPublicKeyByte, -1);
RSA *my_second_rsa = PEM_read_bio_RSA_PUBKEY(bp_login, NULL, NULL, NULL);
byte *pinputCredentials, *poutputCredentials;
pinputCredentials = (byte*) malloc(5000);
poutputCredentials = (byte*) malloc(5000);
pinputCredentials = (byte*)credentials.data();
int buflen = RSA_public_encrypt(credentials.size(), pinputCredentials, poutputCredentials, my_second_rsa, RSA_PKCS1_PADDING);
m_outputCredentialsVector = QByteArray((const char*)poutputCredentials, buflen);
sauf que arrivé a la ligne
int buflen = RSA_public_encrypt(credentials.size(), pinputCredentials, poutputCredentials, my_second_rsa, RSA_PKCS1_PADDING);
le prog plante sans raison!
Si vous pouviez m'aider merci d'avance!