MCPcopy Create free account
hub / github.com/NetHack/NetHack / nhmd4_final

Function nhmd4_final

src/nhmd4.c:234–287  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

232}
233
234void
235nhmd4_final(
236 struct nhmd4_context *ctx,
237 unsigned char result[NHMD4_RESULTLEN])
238{
239 /* @UNSAFE */
240 unsigned long used, free;
241
242 used = ctx->lo & 0x3fUL;
243
244 ctx->buffer[used++] = 0x80;
245
246 free = 64 - used;
247
248 if (free < 8) {
249 memset(&ctx->buffer[used], 0, free);
250 nhmd4_body(ctx, ctx->buffer, 64);
251 used = 0;
252 free = 64;
253 }
254
255 memset(&ctx->buffer[used], 0, free - 8);
256
257 ctx->lo <<= 3;
258 ctx->buffer[56] = ctx->lo;
259 ctx->buffer[57] = ctx->lo >> 8;
260 ctx->buffer[58] = ctx->lo >> 16;
261 ctx->buffer[59] = ctx->lo >> 24;
262 ctx->buffer[60] = ctx->hi;
263 ctx->buffer[61] = ctx->hi >> 8;
264 ctx->buffer[62] = ctx->hi >> 16;
265 ctx->buffer[63] = ctx->hi >> 24;
266
267 nhmd4_body(ctx, ctx->buffer, 64);
268
269 result[0] = ctx->a;
270 result[1] = ctx->a >> 8;
271 result[2] = ctx->a >> 16;
272 result[3] = ctx->a >> 24;
273 result[4] = ctx->b;
274 result[5] = ctx->b >> 8;
275 result[6] = ctx->b >> 16;
276 result[7] = ctx->b >> 24;
277 result[8] = ctx->c;
278 result[9] = ctx->c >> 8;
279 result[10] = ctx->c >> 16;
280 result[11] = ctx->c >> 24;
281 result[12] = ctx->d;
282 result[13] = ctx->d >> 8;
283 result[14] = ctx->d >> 16;
284 result[15] = ctx->d >> 24;
285
286 memset(ctx, 0, sizeof *ctx);
287}
288
289#undef F
290#undef G

Callers

nothing calls this directly

Calls 1

nhmd4_bodyFunction · 0.85

Tested by

no test coverage detected