// important notes on this: // input buf unused bytes needs to be set to zero // input buf need to be in algorithm native byte order (md5 = LE, sha1 = BE, etc) // input buf need to be 64 byte aligned when usin md5_update() typedef struct md4_ctx { u32 h[4]; u32 w0[4]; u32 w1[4]; u32 w2[4]; u32 w3[4]; int len; } md4_ctx_t; void md4_transform (const u32 w0[4], const u32 w1[4], const u32 w2[4], const u32 w3[4], u32 digest[4]) { u32 a = digest[0]; u32 b = digest[1]; u32 c = digest[2]; u32 d = digest[3]; MD4_STEP_S (MD4_Fo, a, b, c, d, w0[0], MD4C00, MD4S00); MD4_STEP_S (MD4_Fo, d, a, b, c, w0[1], MD4C00, MD4S01); MD4_STEP_S (MD4_Fo, c, d, a, b, w0[2], MD4C00, MD4S02); MD4_STEP_S (MD4_Fo, b, c, d, a, w0[3], MD4C00, MD4S03); MD4_STEP_S (MD4_Fo, a, b, c, d, w1[0], MD4C00, MD4S00); MD4_STEP_S (MD4_Fo, d, a, b, c, w1[1], MD4C00, MD4S01); MD4_STEP_S (MD4_Fo, c, d, a, b, w1[2], MD4C00, MD4S02); MD4_STEP_S (MD4_Fo, b, c, d, a, w1[3], MD4C00, MD4S03); MD4_STEP_S (MD4_Fo, a, b, c, d, w2[0], MD4C00, MD4S00); MD4_STEP_S (MD4_Fo, d, a, b, c, w2[1], MD4C00, MD4S01); MD4_STEP_S (MD4_Fo, c, d, a, b, w2[2], MD4C00, MD4S02); MD4_STEP_S (MD4_Fo, b, c, d, a, w2[3], MD4C00, MD4S03); MD4_STEP_S (MD4_Fo, a, b, c, d, w3[0], MD4C00, MD4S00); MD4_STEP_S (MD4_Fo, d, a, b, c, w3[1], MD4C00, MD4S01); MD4_STEP_S (MD4_Fo, c, d, a, b, w3[2], MD4C00, MD4S02); MD4_STEP_S (MD4_Fo, b, c, d, a, w3[3], MD4C00, MD4S03); MD4_STEP_S (MD4_Go, a, b, c, d, w0[0], MD4C01, MD4S10); MD4_STEP_S (MD4_Go, d, a, b, c, w1[0], MD4C01, MD4S11); MD4_STEP_S (MD4_Go, c, d, a, b, w2[0], MD4C01, MD4S12); MD4_STEP_S (MD4_Go, b, c, d, a, w3[0], MD4C01, MD4S13); MD4_STEP_S (MD4_Go, a, b, c, d, w0[1], MD4C01, MD4S10); MD4_STEP_S (MD4_Go, d, a, b, c, w1[1], MD4C01, MD4S11); MD4_STEP_S (MD4_Go, c, d, a, b, w2[1], MD4C01, MD4S12); MD4_STEP_S (MD4_Go, b, c, d, a, w3[1], MD4C01, MD4S13); MD4_STEP_S (MD4_Go, a, b, c, d, w0[2], MD4C01, MD4S10); MD4_STEP_S (MD4_Go, d, a, b, c, w1[2], MD4C01, MD4S11); MD4_STEP_S (MD4_Go, c, d, a, b, w2[2], MD4C01, MD4S12); MD4_STEP_S (MD4_Go, b, c, d, a, w3[2], MD4C01, MD4S13); MD4_STEP_S (MD4_Go, a, b, c, d, w0[3], MD4C01, MD4S10); MD4_STEP_S (MD4_Go, d, a, b, c, w1[3], MD4C01, MD4S11); MD4_STEP_S (MD4_Go, c, d, a, b, w2[3], MD4C01, MD4S12); MD4_STEP_S (MD4_Go, b, c, d, a, w3[3], MD4C01, MD4S13); MD4_STEP_S (MD4_H , a, b, c, d, w0[0], MD4C02, MD4S20); MD4_STEP_S (MD4_H , d, a, b, c, w2[0], MD4C02, MD4S21); MD4_STEP_S (MD4_H , c, d, a, b, w1[0], MD4C02, MD4S22); MD4_STEP_S (MD4_H , b, c, d, a, w3[0], MD4C02, MD4S23); MD4_STEP_S (MD4_H , a, b, c, d, w0[2], MD4C02, MD4S20); MD4_STEP_S (MD4_H , d, a, b, c, w2[2], MD4C02, MD4S21); MD4_STEP_S (MD4_H , c, d, a, b, w1[2], MD4C02, MD4S22); MD4_STEP_S (MD4_H , b, c, d, a, w3[2], MD4C02, MD4S23); MD4_STEP_S (MD4_H , a, b, c, d, w0[1], MD4C02, MD4S20); MD4_STEP_S (MD4_H , d, a, b, c, w2[1], MD4C02, MD4S21); MD4_STEP_S (MD4_H , c, d, a, b, w1[1], MD4C02, MD4S22); MD4_STEP_S (MD4_H , b, c, d, a, w3[1], MD4C02, MD4S23); MD4_STEP_S (MD4_H , a, b, c, d, w0[3], MD4C02, MD4S20); MD4_STEP_S (MD4_H , d, a, b, c, w2[3], MD4C02, MD4S21); MD4_STEP_S (MD4_H , c, d, a, b, w1[3], MD4C02, MD4S22); MD4_STEP_S (MD4_H , b, c, d, a, w3[3], MD4C02, MD4S23); digest[0] += a; digest[1] += b; digest[2] += c; digest[3] += d; } void md4_init (md4_ctx_t *ctx) { ctx->h[0] = MD4M_A; ctx->h[1] = MD4M_B; ctx->h[2] = MD4M_C; ctx->h[3] = MD4M_D; ctx->w0[0] = 0; ctx->w0[1] = 0; ctx->w0[2] = 0; ctx->w0[3] = 0; ctx->w1[0] = 0; ctx->w1[1] = 0; ctx->w1[2] = 0; ctx->w1[3] = 0; ctx->w2[0] = 0; ctx->w2[1] = 0; ctx->w2[2] = 0; ctx->w2[3] = 0; ctx->w3[0] = 0; ctx->w3[1] = 0; ctx->w3[2] = 0; ctx->w3[3] = 0; ctx->len = 0; } void md4_update_64 (md4_ctx_t *ctx, u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const int len) { const int pos = ctx->len & 63; ctx->len += len; if ((pos + len) < 64) { switch_buffer_by_offset_le_S (w0, w1, w2, w3, pos); ctx->w0[0] |= w0[0]; ctx->w0[1] |= w0[1]; ctx->w0[2] |= w0[2]; ctx->w0[3] |= w0[3]; ctx->w1[0] |= w1[0]; ctx->w1[1] |= w1[1]; ctx->w1[2] |= w1[2]; ctx->w1[3] |= w1[3]; ctx->w2[0] |= w2[0]; ctx->w2[1] |= w2[1]; ctx->w2[2] |= w2[2]; ctx->w2[3] |= w2[3]; ctx->w3[0] |= w3[0]; ctx->w3[1] |= w3[1]; ctx->w3[2] |= w3[2]; ctx->w3[3] |= w3[3]; } else { u32 c0[4] = { 0 }; u32 c1[4] = { 0 }; u32 c2[4] = { 0 }; u32 c3[4] = { 0 }; switch_buffer_by_offset_carry_le_S (w0, w1, w2, w3, c0, c1, c2, c3, pos); ctx->w0[0] |= w0[0]; ctx->w0[1] |= w0[1]; ctx->w0[2] |= w0[2]; ctx->w0[3] |= w0[3]; ctx->w1[0] |= w1[0]; ctx->w1[1] |= w1[1]; ctx->w1[2] |= w1[2]; ctx->w1[3] |= w1[3]; ctx->w2[0] |= w2[0]; ctx->w2[1] |= w2[1]; ctx->w2[2] |= w2[2]; ctx->w2[3] |= w2[3]; ctx->w3[0] |= w3[0]; ctx->w3[1] |= w3[1]; ctx->w3[2] |= w3[2]; ctx->w3[3] |= w3[3]; md4_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h); ctx->w0[0] = c0[0]; ctx->w0[1] = c0[1]; ctx->w0[2] = c0[2]; ctx->w0[3] = c0[3]; ctx->w1[0] = c1[0]; ctx->w1[1] = c1[1]; ctx->w1[2] = c1[2]; ctx->w1[3] = c1[3]; ctx->w2[0] = c2[0]; ctx->w2[1] = c2[1]; ctx->w2[2] = c2[2]; ctx->w2[3] = c2[3]; ctx->w3[0] = c3[0]; ctx->w3[1] = c3[1]; ctx->w3[2] = c3[2]; ctx->w3[3] = c3[3]; } } void md4_update (md4_ctx_t *ctx, const u32 *w, const int len) { u32 w0[4]; u32 w1[4]; u32 w2[4]; u32 w3[4]; int pos1; int pos4; for (pos1 = 0, pos4 = 0; pos1 < len - 64; pos1 += 64, pos4 += 16) { w0[0] = w[pos4 + 0]; w0[1] = w[pos4 + 1]; w0[2] = w[pos4 + 2]; w0[3] = w[pos4 + 3]; w1[0] = w[pos4 + 4]; w1[1] = w[pos4 + 5]; w1[2] = w[pos4 + 6]; w1[3] = w[pos4 + 7]; w2[0] = w[pos4 + 8]; w2[1] = w[pos4 + 9]; w2[2] = w[pos4 + 10]; w2[3] = w[pos4 + 11]; w3[0] = w[pos4 + 12]; w3[1] = w[pos4 + 13]; w3[2] = w[pos4 + 14]; w3[3] = w[pos4 + 15]; md4_update_64 (ctx, w0, w1, w2, w3, 64); } w0[0] = w[pos4 + 0]; w0[1] = w[pos4 + 1]; w0[2] = w[pos4 + 2]; w0[3] = w[pos4 + 3]; w1[0] = w[pos4 + 4]; w1[1] = w[pos4 + 5]; w1[2] = w[pos4 + 6]; w1[3] = w[pos4 + 7]; w2[0] = w[pos4 + 8]; w2[1] = w[pos4 + 9]; w2[2] = w[pos4 + 10]; w2[3] = w[pos4 + 11]; w3[0] = w[pos4 + 12]; w3[1] = w[pos4 + 13]; w3[2] = w[pos4 + 14]; w3[3] = w[pos4 + 15]; md4_update_64 (ctx, w0, w1, w2, w3, len - pos1); } void md4_update_global (md4_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; u32 w1[4]; u32 w2[4]; u32 w3[4]; int pos1; int pos4; for (pos1 = 0, pos4 = 0; pos1 < len - 64; pos1 += 64, pos4 += 16) { w0[0] = w[pos4 + 0]; w0[1] = w[pos4 + 1]; w0[2] = w[pos4 + 2]; w0[3] = w[pos4 + 3]; w1[0] = w[pos4 + 4]; w1[1] = w[pos4 + 5]; w1[2] = w[pos4 + 6]; w1[3] = w[pos4 + 7]; w2[0] = w[pos4 + 8]; w2[1] = w[pos4 + 9]; w2[2] = w[pos4 + 10]; w2[3] = w[pos4 + 11]; w3[0] = w[pos4 + 12]; w3[1] = w[pos4 + 13]; w3[2] = w[pos4 + 14]; w3[3] = w[pos4 + 15]; md4_update_64 (ctx, w0, w1, w2, w3, 64); } w0[0] = w[pos4 + 0]; w0[1] = w[pos4 + 1]; w0[2] = w[pos4 + 2]; w0[3] = w[pos4 + 3]; w1[0] = w[pos4 + 4]; w1[1] = w[pos4 + 5]; w1[2] = w[pos4 + 6]; w1[3] = w[pos4 + 7]; w2[0] = w[pos4 + 8]; w2[1] = w[pos4 + 9]; w2[2] = w[pos4 + 10]; w2[3] = w[pos4 + 11]; w3[0] = w[pos4 + 12]; w3[1] = w[pos4 + 13]; w3[2] = w[pos4 + 14]; w3[3] = w[pos4 + 15]; md4_update_64 (ctx, w0, w1, w2, w3, len - pos1); } void md4_update_global_utf16le (md4_ctx_t *ctx, const __global u32 *w, const int len) { u32 w0[4]; u32 w1[4]; u32 w2[4]; u32 w3[4]; int pos1; int pos4; for (pos1 = 0, pos4 = 0; pos1 < len - 32; pos1 += 32, pos4 += 8) { w0[0] = w[pos4 + 0]; w0[1] = w[pos4 + 1]; w0[2] = w[pos4 + 2]; w0[3] = w[pos4 + 3]; w1[0] = w[pos4 + 4]; w1[1] = w[pos4 + 5]; w1[2] = w[pos4 + 6]; w1[3] = w[pos4 + 7]; make_utf16le_S (w1, w2, w3); make_utf16le_S (w0, w0, w1); md4_update_64 (ctx, w0, w1, w2, w3, 32 * 2); } w0[0] = w[pos4 + 0]; w0[1] = w[pos4 + 1]; w0[2] = w[pos4 + 2]; w0[3] = w[pos4 + 3]; w1[0] = w[pos4 + 4]; w1[1] = w[pos4 + 5]; w1[2] = w[pos4 + 6]; w1[3] = w[pos4 + 7]; make_utf16le_S (w1, w2, w3); make_utf16le_S (w0, w0, w1); md4_update_64 (ctx, w0, w1, w2, w3, (len - pos1) * 2); } void md4_final (md4_ctx_t *ctx) { const int pos = ctx->len & 63; append_0x80_4x4_S (ctx->w0, ctx->w1, ctx->w2, ctx->w3, pos); if (pos >= 56) { md4_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h); ctx->w0[0] = 0; ctx->w0[1] = 0; ctx->w0[2] = 0; ctx->w0[3] = 0; ctx->w1[0] = 0; ctx->w1[1] = 0; ctx->w1[2] = 0; ctx->w1[3] = 0; ctx->w2[0] = 0; ctx->w2[1] = 0; ctx->w2[2] = 0; ctx->w2[3] = 0; ctx->w3[0] = 0; ctx->w3[1] = 0; ctx->w3[2] = 0; ctx->w3[3] = 0; } ctx->w3[2] = ctx->len * 8; ctx->w3[3] = 0; md4_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h); } // while input buf can be a vector datatype, the length of the different elements can not typedef struct md4_ctx_vector { u32x h[4]; u32x w0[4]; u32x w1[4]; u32x w2[4]; u32x w3[4]; int len; } md4_ctx_vector_t; void md4_transform_vector (const u32x w0[4], const u32x w1[4], const u32x w2[4], const u32x w3[4], u32x digest[4]) { u32x a = digest[0]; u32x b = digest[1]; u32x c = digest[2]; u32x d = digest[3]; MD4_STEP (MD4_Fo, a, b, c, d, w0[0], MD4C00, MD4S00); MD4_STEP (MD4_Fo, d, a, b, c, w0[1], MD4C00, MD4S01); MD4_STEP (MD4_Fo, c, d, a, b, w0[2], MD4C00, MD4S02); MD4_STEP (MD4_Fo, b, c, d, a, w0[3], MD4C00, MD4S03); MD4_STEP (MD4_Fo, a, b, c, d, w1[0], MD4C00, MD4S00); MD4_STEP (MD4_Fo, d, a, b, c, w1[1], MD4C00, MD4S01); MD4_STEP (MD4_Fo, c, d, a, b, w1[2], MD4C00, MD4S02); MD4_STEP (MD4_Fo, b, c, d, a, w1[3], MD4C00, MD4S03); MD4_STEP (MD4_Fo, a, b, c, d, w2[0], MD4C00, MD4S00); MD4_STEP (MD4_Fo, d, a, b, c, w2[1], MD4C00, MD4S01); MD4_STEP (MD4_Fo, c, d, a, b, w2[2], MD4C00, MD4S02); MD4_STEP (MD4_Fo, b, c, d, a, w2[3], MD4C00, MD4S03); MD4_STEP (MD4_Fo, a, b, c, d, w3[0], MD4C00, MD4S00); MD4_STEP (MD4_Fo, d, a, b, c, w3[1], MD4C00, MD4S01); MD4_STEP (MD4_Fo, c, d, a, b, w3[2], MD4C00, MD4S02); MD4_STEP (MD4_Fo, b, c, d, a, w3[3], MD4C00, MD4S03); MD4_STEP (MD4_Go, a, b, c, d, w0[0], MD4C01, MD4S10); MD4_STEP (MD4_Go, d, a, b, c, w1[0], MD4C01, MD4S11); MD4_STEP (MD4_Go, c, d, a, b, w2[0], MD4C01, MD4S12); MD4_STEP (MD4_Go, b, c, d, a, w3[0], MD4C01, MD4S13); MD4_STEP (MD4_Go, a, b, c, d, w0[1], MD4C01, MD4S10); MD4_STEP (MD4_Go, d, a, b, c, w1[1], MD4C01, MD4S11); MD4_STEP (MD4_Go, c, d, a, b, w2[1], MD4C01, MD4S12); MD4_STEP (MD4_Go, b, c, d, a, w3[1], MD4C01, MD4S13); MD4_STEP (MD4_Go, a, b, c, d, w0[2], MD4C01, MD4S10); MD4_STEP (MD4_Go, d, a, b, c, w1[2], MD4C01, MD4S11); MD4_STEP (MD4_Go, c, d, a, b, w2[2], MD4C01, MD4S12); MD4_STEP (MD4_Go, b, c, d, a, w3[2], MD4C01, MD4S13); MD4_STEP (MD4_Go, a, b, c, d, w0[3], MD4C01, MD4S10); MD4_STEP (MD4_Go, d, a, b, c, w1[3], MD4C01, MD4S11); MD4_STEP (MD4_Go, c, d, a, b, w2[3], MD4C01, MD4S12); MD4_STEP (MD4_Go, b, c, d, a, w3[3], MD4C01, MD4S13); MD4_STEP (MD4_H , a, b, c, d, w0[0], MD4C02, MD4S20); MD4_STEP (MD4_H , d, a, b, c, w2[0], MD4C02, MD4S21); MD4_STEP (MD4_H , c, d, a, b, w1[0], MD4C02, MD4S22); MD4_STEP (MD4_H , b, c, d, a, w3[0], MD4C02, MD4S23); MD4_STEP (MD4_H , a, b, c, d, w0[2], MD4C02, MD4S20); MD4_STEP (MD4_H , d, a, b, c, w2[2], MD4C02, MD4S21); MD4_STEP (MD4_H , c, d, a, b, w1[2], MD4C02, MD4S22); MD4_STEP (MD4_H , b, c, d, a, w3[2], MD4C02, MD4S23); MD4_STEP (MD4_H , a, b, c, d, w0[1], MD4C02, MD4S20); MD4_STEP (MD4_H , d, a, b, c, w2[1], MD4C02, MD4S21); MD4_STEP (MD4_H , c, d, a, b, w1[1], MD4C02, MD4S22); MD4_STEP (MD4_H , b, c, d, a, w3[1], MD4C02, MD4S23); MD4_STEP (MD4_H , a, b, c, d, w0[3], MD4C02, MD4S20); MD4_STEP (MD4_H , d, a, b, c, w2[3], MD4C02, MD4S21); MD4_STEP (MD4_H , c, d, a, b, w1[3], MD4C02, MD4S22); MD4_STEP (MD4_H , b, c, d, a, w3[3], MD4C02, MD4S23); digest[0] += a; digest[1] += b; digest[2] += c; digest[3] += d; } void md4_init_vector (md4_ctx_vector_t *ctx) { ctx->h[0] = MD4M_A; ctx->h[1] = MD4M_B; ctx->h[2] = MD4M_C; ctx->h[3] = MD4M_D; ctx->w0[0] = 0; ctx->w0[1] = 0; ctx->w0[2] = 0; ctx->w0[3] = 0; ctx->w1[0] = 0; ctx->w1[1] = 0; ctx->w1[2] = 0; ctx->w1[3] = 0; ctx->w2[0] = 0; ctx->w2[1] = 0; ctx->w2[2] = 0; ctx->w2[3] = 0; ctx->w3[0] = 0; ctx->w3[1] = 0; ctx->w3[2] = 0; ctx->w3[3] = 0; ctx->len = 0; } void md4_update_vector_64 (md4_ctx_vector_t *ctx, u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], const int len) { const int pos = ctx->len & 63; ctx->len += len; if ((pos + len) < 64) { switch_buffer_by_offset_le (w0, w1, w2, w3, pos); ctx->w0[0] |= w0[0]; ctx->w0[1] |= w0[1]; ctx->w0[2] |= w0[2]; ctx->w0[3] |= w0[3]; ctx->w1[0] |= w1[0]; ctx->w1[1] |= w1[1]; ctx->w1[2] |= w1[2]; ctx->w1[3] |= w1[3]; ctx->w2[0] |= w2[0]; ctx->w2[1] |= w2[1]; ctx->w2[2] |= w2[2]; ctx->w2[3] |= w2[3]; ctx->w3[0] |= w3[0]; ctx->w3[1] |= w3[1]; ctx->w3[2] |= w3[2]; ctx->w3[3] |= w3[3]; } else { u32x c0[4] = { 0 }; u32x c1[4] = { 0 }; u32x c2[4] = { 0 }; u32x c3[4] = { 0 }; switch_buffer_by_offset_carry_le (w0, w1, w2, w3, c0, c1, c2, c3, pos); ctx->w0[0] |= w0[0]; ctx->w0[1] |= w0[1]; ctx->w0[2] |= w0[2]; ctx->w0[3] |= w0[3]; ctx->w1[0] |= w1[0]; ctx->w1[1] |= w1[1]; ctx->w1[2] |= w1[2]; ctx->w1[3] |= w1[3]; ctx->w2[0] |= w2[0]; ctx->w2[1] |= w2[1]; ctx->w2[2] |= w2[2]; ctx->w2[3] |= w2[3]; ctx->w3[0] |= w3[0]; ctx->w3[1] |= w3[1]; ctx->w3[2] |= w3[2]; ctx->w3[3] |= w3[3]; md4_transform_vector (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h); ctx->w0[0] = c0[0]; ctx->w0[1] = c0[1]; ctx->w0[2] = c0[2]; ctx->w0[3] = c0[3]; ctx->w1[0] = c1[0]; ctx->w1[1] = c1[1]; ctx->w1[2] = c1[2]; ctx->w1[3] = c1[3]; ctx->w2[0] = c2[0]; ctx->w2[1] = c2[1]; ctx->w2[2] = c2[2]; ctx->w2[3] = c2[3]; ctx->w3[0] = c3[0]; ctx->w3[1] = c3[1]; ctx->w3[2] = c3[2]; ctx->w3[3] = c3[3]; } } void md4_update_vector (md4_ctx_vector_t *ctx, const u32x *w, const int len) { u32x w0[4]; u32x w1[4]; u32x w2[4]; u32x w3[4]; int pos1; int pos4; for (pos1 = 0, pos4 = 0; pos1 < len - 64; pos1 += 64, pos4 += 16) { w0[0] = w[pos4 + 0]; w0[1] = w[pos4 + 1]; w0[2] = w[pos4 + 2]; w0[3] = w[pos4 + 3]; w1[0] = w[pos4 + 4]; w1[1] = w[pos4 + 5]; w1[2] = w[pos4 + 6]; w1[3] = w[pos4 + 7]; w2[0] = w[pos4 + 8]; w2[1] = w[pos4 + 9]; w2[2] = w[pos4 + 10]; w2[3] = w[pos4 + 11]; w3[0] = w[pos4 + 12]; w3[1] = w[pos4 + 13]; w3[2] = w[pos4 + 14]; w3[3] = w[pos4 + 15]; md4_update_vector_64 (ctx, w0, w1, w2, w3, 64); } w0[0] = w[pos4 + 0]; w0[1] = w[pos4 + 1]; w0[2] = w[pos4 + 2]; w0[3] = w[pos4 + 3]; w1[0] = w[pos4 + 4]; w1[1] = w[pos4 + 5]; w1[2] = w[pos4 + 6]; w1[3] = w[pos4 + 7]; w2[0] = w[pos4 + 8]; w2[1] = w[pos4 + 9]; w2[2] = w[pos4 + 10]; w2[3] = w[pos4 + 11]; w3[0] = w[pos4 + 12]; w3[1] = w[pos4 + 13]; w3[2] = w[pos4 + 14]; w3[3] = w[pos4 + 15]; md4_update_vector_64 (ctx, w0, w1, w2, w3, len - pos1); } void md4_final_vector (md4_ctx_vector_t *ctx) { const int pos = ctx->len & 63; append_0x80_4x4 (ctx->w0, ctx->w1, ctx->w2, ctx->w3, pos); if (pos >= 56) { md4_transform_vector (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h); ctx->w0[0] = 0; ctx->w0[1] = 0; ctx->w0[2] = 0; ctx->w0[3] = 0; ctx->w1[0] = 0; ctx->w1[1] = 0; ctx->w1[2] = 0; ctx->w1[3] = 0; ctx->w2[0] = 0; ctx->w2[1] = 0; ctx->w2[2] = 0; ctx->w2[3] = 0; ctx->w3[0] = 0; ctx->w3[1] = 0; ctx->w3[2] = 0; ctx->w3[3] = 0; } ctx->w3[2] = ctx->len * 8; ctx->w3[3] = 0; md4_transform_vector (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h); }