Hello. I am working on a Kerberos 5 preauth password recovery tool. Part of an algorithm optimization involves checking the decrypted timestamp to make sure that it equals the year that the packet was recovered before continuing to compute a checksum. If the timestamp does not equal the year the packet was recovered, the checksum computation can be skipped for that candidate password.

However, I am still currently decrypting 18 bytes of the RC4-encrypted timestamp when I only need to decrypt 8 or maybe even 4.

the encrypted timestamp is 36 bytes long. starting at byte 15 is the actual timestamp in the format YYYYMMDDHHMMSSZ. I only need the to decrypt the year, really. But currently I only know how to decrypt the year by decrypting everything before it as such:

RC4(&data_key,18,enc_data,clear_data);

I have to decrypt 14 bytes I don't use at all. I was wondering if there was a way I could jump to byte 15 and only decrypt bytes 15-18, and then if the timestamp checks, go back and decrypt the entire timestamp. I am using the OpenSSL libraries. Speed is essential, which is why I am doing this in the first place. Thanks ahead of time!

When you say bytes 15-18, is that the plain text or the cipher text?

I only want to decrypt bytes 15-18 of the cipher text (enc_data) and check to see that they equal the year the packet was recovered.

currently I am decrypting 18 bytes of cipher text (bytes 0-18), I only need to decrypt 4 bytes (bytes 15-18), but I don't know how to skip ahead and start decrypting at byte 15.

You can call the function and skip those first 15 bytes. That's easy:

RC4(&data_key,3,enc_data+15,clear_data);

I don't know if it will work though. It depends on how the encryption works.

That didn't work :( I got junk data in clear_data. Any other suggestions? I tried to make a four-element array of pointers to the four elements of enc_data that I want to decrypt, and then decrypt the array of pointers, but that didn't work because RC4 function tries to make pointers to the pointers. I tried to copy bytes 15-18 of enc_data to a new array and then decrypt that array, and the copy was successful, but I got junk data again. Don't know what else to try.

Do you actually know how RC4 works?

Not really. Sort of a script-kiddy, I guess - pretty new to OpenSSL. Is there a simple way to advance the key? Would this be done using the RC4_set_key() function? Right now I have:

typedef unsigned char uint8_t;
uint8_t clear_data[64];
uint8_t K3[16];
RC4_KEY data_key;

hmac_md5(ts_checksum,16,K1,16,K3);
RC4_set_key(&data_key,16,K3);
RC4(&data_key,18,enc_data,clear_data);

which decrypts the first 18 bytes of enc_data successfully. If there is a simple way to advance the key and start decryption at byte 15, that would be great. If not, you may be right in saying it's not worth it. I only saved ~1% processing time by eliminating the RC4 decryption of the last 18 of the total 36 bytes of enc_data, so by eliminating 14 bytes more, I only expect to save ~.78% processing time. It seems the RC4 decryption does not constitute a significant portion of the entire Kerberos 5 protocol (~2%?). This seems to check, since I heard that RC4 is extremely fast.
What do you suggest?

Does anybody know a simple way to reset the key appropriately?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.