# define ARG6 STKARG(2)
# define ARG7 STKARG(3)
# define ARG8 STKARG(4)
-# define STKARG_OFFSET 40
+# define STKARG_OFFSET 224
#endif
#define STKARG(i) [rsp + STKARG_OFFSET + 8*(i)]
mov rbx, r8
movdqu xmm8, [r9]
movdqu xmm10, [rax]
- mov r8, STKARG(1)
+ mov r8d, STKARG(1)
mov r9, STKARG(2)
mov r10, rdx
mov r11, rcx
.ifeqs "\mode", "mont"
mov rbx, rcx
movdqu xmm8, [r8]
- mov r8, r9
+ mov r8d, r9d
mov r9, STKARG(0)
mov r10, rdx
mov rcx, rsi
mov rbx, r9
movdqu xmm8, [r10]
movdqu xmm10, [r11]
- mov r8, STKARG(2)
- mov r9, STKARG(3)
mov r11, r8
+ mov r8d, STKARG(2)
+ mov r9, STKARG(3)
.endif
.ifeqs "\mode", "smul"
mov rdi, rcx
mov rcx, rdx
mov rbx, r8
movdqu xmm10, [r9]
- mov r8, STKARG(0)
+ mov r8d, STKARG(0)
mov r9, STKARG(1)
.endif
.ifeqs "\mode", "mmul"
mov rbx, STKARG(0)
movdqu xmm8, [r10]
movdqu xmm10, [r11]
- mov r8, STKARG(3)
- mov r9, STKARG(4)
mov r10, r8
mov r11, r9
+ mov r8d, STKARG(3)
+ mov r9, STKARG(4)
.endif
.ifeqs "\mode", "mont"
mov r10, STKARG(0)
mov rcx, rdx
mov rbx, r9
movdqu xmm8, [r10]
- mov r8, STKARG(1)
- mov r9, STKARG(2)
mov r10, r8
+ mov r8d, STKARG(1)
+ mov r9, STKARG(2)
.endif
#endif
halg, t.buf);
}
- dstr_reset(&d);
- if ((q = key_getattr(0, k, "kdf")) == 0) {
- dstr_putf(&d, "%s-mgf", kk->hc->name);
- q = d.buf;
- }
- if ((kk->cxc = gcipher_byname(q)) == 0) {
- die(EXIT_FAILURE, "encryption scheme (KDF) `%s' not found in key `%s'",
- q, t.buf);
- }
-
if (!balg)
bt = bulktab;
else {
*bc = bo->init(k, balg, kk->hc->name);
(*bc)->ops = bo;
+ dstr_reset(&d);
+ if ((q = key_getattr(0, k, "kdf")) == 0) {
+ dstr_putf(&d, "%s-mgf", kk->hc->name);
+ q = d.buf;
+ }
+ if ((kk->cxc = gcipher_byname(q)) == 0) {
+ die(EXIT_FAILURE, "encryption scheme (KDF) `%s' not found in key `%s'",
+ q, t.buf);
+ }
+
/* --- Tidy up --- */
dstr_destroy(&d);
#include "config.h"
+#include <unistd.h>
+
#include "cc.h"
#ifndef PATHSEP
int fprogress_init(fprogress *f, const char *name, FILE *fp)
{
const char *p;
+ struct stat st;
off_t o, sz = -1;
size_t n;
/* --- Set up the offset --- */
- if ((o = ftello(fp)) >= 0 &&
- fseeko(fp, 0, SEEK_END) >= 0 &&
- (sz = ftello(fp),
- fseeko(fp, o, SEEK_SET) < 0))
- return (-1);
+ o = lseek(fileno(fp), 0, SEEK_CUR);
+ if (fstat(fileno(fp), &st)) return (-1);
+ sz = (S_ISREG(st.st_mode)) ? st.st_size : -1;
if (o != -1 && sz != -1) sz -= o;
f->o = f->olast = 0; f->sz = sz;
octet *_p = (octet *)(p); \
const cookie *_c = (c); \
STORE32(_p + 0, _c->k); \
- STORE32(_p + 4, ((_c->exp & ~MASK32) >> 16) >> 16); \
+ STORE32(_p + 4, ((_c->exp & ~(unsigned long)MASK32) >> 16) >> 16); \
STORE32(_p + 8, _c->exp); \
} while (0)
cookie *_c = (c); \
const octet *_p = (const octet *)(p); \
_c->k = LOAD32(_p + 0); \
- _c->exp = ((time_t)(((LOAD32(_p + 4) << 16) << 16) & ~MASK32) | \
+ _c->exp = ((time_t)(((LOAD32(_p + 4) << 16) << 16) & \
+ ~(unsigned long)MASK32) | \
(time_t)LOAD32(_p + 8)); \
} while (0)
octet buf[8];
if (fread(buf, sizeof(buf), 1, fp) < 1)
return (E_EOF);
- b->t = ((time_t)(((LOAD32(buf + 0) << 16) << 16) & ~MASK32) |
+ b->t = ((time_t)(((LOAD32(buf + 0) << 16) << 16) &
+ ~(unsigned long)MASK32) |
(time_t)LOAD32(buf + 4));
} else {
if (getstring(fp, &b->d, GSF_FILE))
STORE32(d->buf + d->len, 0xffffffff);
STORE32(d->buf + d->len + 4, 0xffffffff);
} else {
- STORE32(d->buf + d->len, ((b->t & ~MASK32) >> 16) >> 16);
+ STORE32(d->buf + d->len,
+ ((b->t & ~(unsigned long)MASK32) >> 16) >> 16);
STORE32(d->buf + d->len + 4, b->t);
}
d->len += 8;
unsigned _i; BLKC_W(w); unsigned long _x = x; \
for (_i = 0; _i < PRE##_BLKSZ / 4; _i++) { \
*_w++ = U32(_x); \
- _x = ((_x & ~MASK32) >> 16) >> 16; \
+ _x = ((_x & ~(unsigned long)MASK32) >> 16) >> 16; \
} \
} while (0)
unsigned _i; BLKC_W(w); unsigned long _x = x; _w += PRE##_BLKSZ / 4; \
for (_i = 0; _i < PRE##_BLKSZ / 4; _i++) { \
*--_w = U32(_x); \
- _x = ((_x & ~MASK32) >> 16) >> 16; \
+ _x = ((_x & ~(unsigned long)MASK32) >> 16) >> 16; \
} \
} while (0)
* Use: Initializes a DESX key buffer. The key buffer contains, in
* order, a single-DES key (either 7 or 8 bytes), an optional
* 8-byte pre-whitening key, and an optional 8-byte
- * port-whitening key. If no whitening keys are specified, the
+ * post-whitening key. If no whitening keys are specified, the
* algorithm becomes the same as single-DES.
*/
* Returns: ---
*
* Use: Initializes a DESX key buffer. The key buffer contains, in
- * order, an optional 8-byte pre-whitening key, a single-DES key
- * (either 7 or 8 bytes), and an optional 8-byte port-whitening
- * key. If no whitening keys are specified, the algorithm
- * becomes the same as single-DES.
+ * order, a single-DES key (either 7 or 8 bytes), an optional
+ * 8-byte pre-whitening key, and an optional 8-byte
+ * post-whitening key. If no whitening keys are specified, the
+ * algorithm becomes the same as single-DES.
*/
extern void desx_init(desx_ctx */*k*/, const void */*buf*/, size_t /*sz*/);
ctx->e = LOAD32_L(p + 16);
ctx->off = 0;
ctx->nl = U32(count);
- ctx->nh = U32(((count & ~MASK32) >> 16) >> 16);
+ ctx->nh = U32(((count & ~(unsigned long)MASK32) >> 16) >> 16);
}
/* --- @has160_hash@ --- *
\
{ \
uint32 _l = U32(_bsz); \
- uint32 _h = ((_bsz & ~MASK32) >> 16) >> 16; \
+ uint32 _h = ((_bsz & ~(size_t)MASK32) >> 16) >> 16; \
_bctx->nh += _h; \
_bctx->nl += _l; \
- if (_bctx->nl < _l || _bctx->nl & ~MASK32) \
+ if (_bctx->nl < _l || _bctx->nl & ~(uint32)MASK32) \
_bctx->nh++; \
} \
\
{
uint32 _l = ((uint32) ((_bsz) & MASK32));
- uint32 _h = ((_bsz & ~MASK32) >> 16) >> 16;
+ uint32 _h = ((_bsz & ~(size_t)MASK32) >> 16) >> 16;
_bctx->nh += _h;
_bctx->nl += _l;
- if (_bctx->nl < _l || _bctx->nl & ~MASK32)
+ if (_bctx->nl < _l || _bctx->nl & ~(uint32)MASK32)
_bctx->nh++;
}
if (_bctx->off + _bsz < SHA_BUFSZ) {
ctx->d = LOAD32_L(p + 12);
ctx->off = 0;
ctx->nl = U32(count);
- ctx->nh = U32(((count & ~MASK32) >> 16) >> 16);
+ ctx->nh = U32(((count & ~(unsigned long)MASK32) >> 16) >> 16);
}
/* --- @md4_hash@ --- *
ctx->d = LOAD32_L(p + 12);
ctx->off = 0;
ctx->nl = U32(count);
- ctx->nh = U32(((count & ~MASK32) >> 16) >> 16);
+ ctx->nh = U32(((count & ~(unsigned long)MASK32) >> 16) >> 16);
}
/* --- @md5_hash@ --- *
ctx->d = LOAD32_L(p + 12);
ctx->off = 0;
ctx->nl = U32(count);
- ctx->nh = U32(((count & ~MASK32) >> 16) >> 16);
+ ctx->nh = U32(((count & ~(unsigned long)MASK32) >> 16) >> 16);
}
/* --- @rmd128_hash@ --- *
ctx->e = LOAD32_L(p + 16);
ctx->off = 0;
ctx->nl = U32(count);
- ctx->nh = U32(((count & ~MASK32) >> 16) >> 16);
+ ctx->nh = U32(((count & ~(unsigned long)MASK32) >> 16) >> 16);
}
/* --- @rmd160_hash@ --- *
ctx->D = LOAD32_L(p + 28);
ctx->off = 0;
ctx->nl = U32(count);
- ctx->nh = U32(((count & ~MASK32) >> 16) >> 16);
+ ctx->nh = U32(((count & ~(unsigned long)MASK32) >> 16) >> 16);
}
/* --- @rmd256_hash@ --- *
ctx->E = LOAD32_L(p + 36);
ctx->off = 0;
ctx->nl = U32(count);
- ctx->nh = U32(((count & ~MASK32) >> 16) >> 16);
+ ctx->nh = U32(((count & ~(unsigned long)MASK32) >> 16) >> 16);
}
/* --- @rmd320_hash@ --- *
#endif
#if CPUFAM_AMD64 && ABI_WIN
rstrxmm xmm6, 0
- rsrrxmm xmm7, 16
+ rstrxmm xmm7, 16
stfree 64 + 8
#endif
ctx->e = LOAD32(p + 16);
ctx->off = 0;
ctx->nl = U32(count);
- ctx->nh = U32(((count & ~MASK32) >> 16) >> 16);
+ ctx->nh = U32(((count & ~(unsigned long)MASK32) >> 16) >> 16);
}
/* --- @sha_hash@ --- *
ctx->h = LOAD32(p + 28);
ctx->off = 0;
ctx->nl = U32(count);
- ctx->nh = U32(((count & ~MASK32) >> 16) >> 16);
+ ctx->nh = U32(((count & ~(unsigned long)MASK32) >> 16) >> 16);
}
/* --- @sha256_hash@, @sha224_hash@ --- *
octet b[9];
unsigned i;
- SET64(t, ((n&~MASK32) >> 16) >> 16, n&MASK32);
+ SET64(t, ((n&~(size_t)MASK32) >> 16) >> 16, n&MASK32);
STORE64_B_(b + 1, t);
for (i = 1; i < 8 && !b[i]; i++);
i--; b[i] = 8 - i;
octet b[9];
unsigned i;
- SET64(t, ((n&~MASK32) >> 16) >> 16, n&MASK32);
+ SET64(t, ((n&~(size_t)MASK32) >> 16) >> 16, n&MASK32);
STORE64_B_(b, t);
for (i = 0; i < 7 && !b[i]; i++);
b[8] = 8 - i;
LOAD64_(ctx->h, p + 56);
ctx->off = 0;
ctx->nl = U32(count);
- ctx->nh = U32(((count & ~MASK32) >> 16) >> 16);
+ ctx->nh = U32(((count & ~(unsigned long)MASK32) >> 16) >> 16);
}
/* --- @sha512_hash@, @sha384_hash@ --- *
92128b45f2af927df41f3b200a872673a744956e2c58b0099f243b7911c50436
ce408d59a184170a267df8713a787464af6d75f5f46b8b64ddac88daabb50ecd;
}
+
+rijndael256 {
+ ## Some tests for tiny keys.
+ e93a6283
+ 511ad33d714994b1c61aa279fc973a9d859713ec6473f023401a88e3e8640e9d
+ ef36dccd7636fb28253fb591b5bacbf7e31f37f5f239a756d3bf848c559d92c6;
+ 717267580d3a01d9
+ 0d6aa90050de49fabdd53aba1f6a903f32c6815810b7b2ce72aa3dc2246cdfdf
+ 84c75fa0db1a864eac23ae6b9c50024dda11d35cb4736ae7950961c61b35454a;
+ d3c9931798b0abc3b15129ae
+ 1188d6578860ceb90a80228c344c3d9e72e775cae5d41b0fd9ff9c60d0898fd0
+ ec81f1cda5409281c7b4d5f698b6ca5d0ec79598571237a08a60a4a0724b739a;
+}
LOAD64_L_(ctx->c, p + 16);
ctx->off = 0;
ctx->nl = U32(count);
- ctx->nh = U32(((count & ~MASK32) >> 16) >> 16);
+ ctx->nh = U32(((count & ~(unsigned long)MASK32) >> 16) >> 16);
}
/* --- @tiger_hash@ --- *
}
ctx->off = 0;
ctx->nl = U32(count);
- ctx->nh = U32(((count & ~MASK32) >> 16) >> 16);
+ ctx->nh = U32(((count & ~(unsigned long)MASK32) >> 16) >> 16);
}
/* --- @whirlpool_hash@, @whirlpool256_hash@ --- *