X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fsec%2Fcipher.c;fp=bertos%2Fsec%2Fcipher.c;h=7977cc4632b83460dbc1cb59da77e5c22dc50773;hb=20491f5ce0cb9b92b33e52d1d1015930618b00e8;hp=22bebe605de4a736cb409b4d1976b8464cdb7a23;hpb=4512274f1561597d312d5f6b6bc72284f65854ca;p=bertos.git diff --git a/bertos/sec/cipher.c b/bertos/sec/cipher.c index 22bebe60..7977cc46 100644 --- a/bertos/sec/cipher.c +++ b/bertos/sec/cipher.c @@ -64,16 +64,21 @@ static void ctr_increment(void *buf, size_t len) return; } +void cipher_ctr_step(BlockCipher *c, void *block) +{ + memcpy(block, c->buf, c->block_len); + c->enc_block(c, block); + ctr_increment(c->buf, c->block_len); +} + void cipher_ctr_encrypt(BlockCipher *c, void *block) { uint8_t temp[c->block_len]; - memcpy(temp, c->buf, c->block_len); - c->enc_block(c, temp); + cipher_ctr_step(c, temp); xor_block(block, block, temp, c->block_len); PURGE(temp); - ctr_increment(c->buf, c->block_len); } void cipher_ctr_decrypt(BlockCipher *c, void *block)