strict aliasing fun

C/C++

No description

Guest

Download Edit

void Blowfish_Encrypt_Buffer_CBC(BLOWFISH_CTX *ctx, void *buffer_,
size_t length, void *iv_) {
uint64_t *buffer = buffer_;
uint64_t *iv = iv_;
uint64_t lastcb = *iv;
size_t i;
for (i = 0; i < length / 8; ++i) {
buffer[i] ^= lastcb;
Blowfish_Encrypt(ctx, (uint32_t *)(buffer+i), (uint32_t *)(buffer+i)+1);
lastcb = buffer[i];
}
*iv = lastcb;
}