From: Andrey Rys Date: Sun, 28 Aug 2022 10:32:18 +0000 (+0200) Subject: Sync with tfcipher X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=427cccc02bf41be626fb70408e172d41fb1176b4;p=tfcrypt.git Sync with tfcipher --- diff --git a/VERSION b/VERSION index 900731f..1479e19 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -64 +65 diff --git a/tfdef.h b/tfdef.h index 2eac9f8..0facb02 100644 --- a/tfdef.h +++ b/tfdef.h @@ -92,6 +92,18 @@ static inline void data_to_words(void *p, size_t l) #endif } +static inline void xor_block(void *dst, const void *src, size_t sz) +{ + const size_t *sx = (const size_t *)src; + const TF_BYTE_TYPE *usx = (const TF_BYTE_TYPE *)src; + size_t *dx = (size_t *)dst; + TF_BYTE_TYPE *udx = (TF_BYTE_TYPE *)dst; + size_t sl = sz; + + for (sl = 0; sl < (sz / sizeof(size_t)); sl++) dx[sl] ^= sx[sl]; + if (sz - (sl * sizeof(size_t))) for (sl *= sizeof(size_t); sl < sz; sl++) udx[sl] ^= usx[sl]; +} + static inline void ctr_inc(TF_UNIT_TYPE *x, size_t xl) { size_t z; diff --git a/tfstream.c b/tfstream.c index 014b5c1..6f52a32 100644 --- a/tfstream.c +++ b/tfstream.c @@ -2,18 +2,6 @@ #include "tfdef.h" #include "tfe.h" -static inline void xor_block(void *dst, const void *src, size_t sz) -{ - const size_t *sx = (const size_t *)src; - const TF_BYTE_TYPE *usx = (const TF_BYTE_TYPE *)src; - size_t *dx = (size_t *)dst; - TF_BYTE_TYPE *udx = (TF_BYTE_TYPE *)dst; - size_t sl = sz; - - for (sl = 0; sl < (sz / sizeof(size_t)); sl++) dx[sl] ^= sx[sl]; - if (sz - (sl * sizeof(size_t))) for (sl *= sizeof(size_t); sl < sz; sl++) udx[sl] ^= usx[sl]; -} - void tf_stream_crypt(struct tfe_stream *tfe, void *out, const void *in, size_t sz) { tfe_emit(out, sz, tfe);