I am using Java's Cipher class for decryption.
Couple of questions:
My code is (briefly) as follows:
desCipher = Cipher.getInstance("DES/OFB56/NoPadding");
desCipher.init(Cipher.DECRYPT_MODE, secretKey, ivParameter);
for (i=0;i<subframeCount;i++){
// perform the skip iteration here
if (firstFrame){
byte[] dummy = new byte[7];
dummy[0] = 1;dummy[1] = 12;dummy[2] = 12;dummy[3] = 15;dummy[4] = 26;dummy[5] = 12;dummy[6] = 12;
desCipher.update(dummy);
}
if (not_last_frame){
decryptedVCW = desCipher.update(vcwShift_E);
}
else{
decryptedVCW = desCipher.doFinal(vcwShift_E);
}
}
I am not sure if it is indeed skipping the XORing in the update(dummy) operation and then using the keystream for the next block cipher.
Thanks Shiv
Yes, that's how OFB works: the output from the encryption (the keystream) is fed directly as input to the next block, so the XOR-ing part is independent from the encryption engine, just like a stream cipher.
Another way of getting the keystream than XOR-ing with the plaintext, is to XOR (or invoke update()/doFinal()
) with only zeroes, you will get the actual keystream. Just in case you want to see what the keystream looks like. But your way will obviously work as well, I am just adding this for sake of completeness.
I found out that the first iteration is indeed skipping the XORing stage.
The keystream can be found by XORing the plain text with the decryptedVCW (which should have been obvious to me)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.