|
|
@ -61,27 +61,27 @@ void DESEncryptor::DESExec(const TQString &str, int mode)
|
|
|
|
memcpy(in.data(), string.data(), in.size());
|
|
|
|
memcpy(in.data(), string.data(), in.size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Read 8 chars at a time and encrypt/decrypt them
|
|
|
|
// Read sizeof(DES_cblock) chars at a time and encrypt/decrypt them
|
|
|
|
unsigned int i = 0;
|
|
|
|
unsigned int i = 0;
|
|
|
|
char *o_message = (char*) malloc(8);
|
|
|
|
DES_cblock *o_message = (DES_cblock*) malloc(sizeof(DES_cblock));
|
|
|
|
char *o_output = (char*) malloc(8);
|
|
|
|
DES_cblock *o_output = (DES_cblock*) malloc(sizeof(DES_cblock));
|
|
|
|
|
|
|
|
|
|
|
|
memset(o_message, 0, 9);
|
|
|
|
memset(o_message, 0, sizeof(DES_cblock));
|
|
|
|
memset(o_output, 0, 9);
|
|
|
|
memset(o_output, 0, sizeof(DES_cblock));
|
|
|
|
//out.resize(in.size() * 2);
|
|
|
|
//out.resize(in.size() * 2);
|
|
|
|
|
|
|
|
|
|
|
|
while (i < in.size()) {
|
|
|
|
while (i < in.size()) {
|
|
|
|
out.resize(out.size() + 8);
|
|
|
|
out.resize(out.size() + sizeof(DES_cblock));
|
|
|
|
memcpy(o_message, in.data() + i, 8);
|
|
|
|
memcpy(o_message, in.data() + i, sizeof(DES_cblock));
|
|
|
|
DES_ecb_encrypt((DES_cblock *) o_message, (DES_cblock*) o_output, &m_schedule, mode);
|
|
|
|
DES_ecb_encrypt(o_message, o_output, &m_schedule, mode);
|
|
|
|
memcpy(out.data() + i, o_output, 8);
|
|
|
|
memcpy(out.data() + i, o_output, sizeof(DES_cblock));
|
|
|
|
|
|
|
|
|
|
|
|
// Next 8 bytes
|
|
|
|
// Next sizeof(DES_cblock) bytes
|
|
|
|
i += 8;
|
|
|
|
i += sizeof(DES_cblock);
|
|
|
|
|
|
|
|
|
|
|
|
// Clear everything
|
|
|
|
// Clear everything
|
|
|
|
memset(o_message, 0, 9);
|
|
|
|
memset(o_message, 0, sizeof(DES_cblock));
|
|
|
|
memset(o_output, 0, 9);
|
|
|
|
memset(o_output, 0, sizeof(DES_cblock));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
free(o_message);
|
|
|
|
free(o_message);
|
|
|
|