Lines Matching refs:ctx
181 static void FLAC__MD5Update(FLAC__MD5Context *ctx, FLAC__byte const *buf, unsigned len)
187 t = ctx->bytes[0];
188 if ((ctx->bytes[0] = t + len) < t)
189 ctx->bytes[1]++; /* Carry from low to high */
191 t = 64 - (t & 0x3f); /* Space available in ctx->in (at least 1) */
193 memcpy((FLAC__byte *)ctx->in + 64 - t, buf, len);
197 memcpy((FLAC__byte *)ctx->in + 64 - t, buf, t);
198 byteSwapX16(ctx->in);
199 FLAC__MD5Transform(ctx->buf, ctx->in);
205 memcpy(ctx->in, buf, 64);
206 byteSwapX16(ctx->in);
207 FLAC__MD5Transform(ctx->buf, ctx->in);
213 memcpy(ctx->in, buf, len);
220 void FLAC__MD5Init(FLAC__MD5Context *ctx)
222 ctx->buf[0] = 0x67452301;
223 ctx->buf[1] = 0xefcdab89;
224 ctx->buf[2] = 0x98badcfe;
225 ctx->buf[3] = 0x10325476;
227 ctx->bytes[0] = 0;
228 ctx->bytes[1] = 0;
230 ctx->internal_buf = 0;
231 ctx->capacity = 0;
238 void FLAC__MD5Final(FLAC__byte digest[16], FLAC__MD5Context *ctx)
240 int count = ctx->bytes[0] & 0x3f; /* Number of bytes in ctx->in */
241 FLAC__byte *p = (FLAC__byte *)ctx->in + count;
251 byteSwapX16(ctx->in);
252 FLAC__MD5Transform(ctx->buf, ctx->in);
253 p = (FLAC__byte *)ctx->in;
257 byteSwap(ctx->in, 14);
260 ctx->in[14] = ctx->bytes[0] << 3;
261 ctx->in[15] = ctx->bytes[1] << 3 | ctx->bytes[0] >> 29;
262 FLAC__MD5Transform(ctx->buf, ctx->in);
264 byteSwap(ctx->buf, 4);
265 memcpy(digest, ctx->buf, 16);
266 memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
267 if(0 != ctx->internal_buf) {
268 free(ctx->internal_buf);
269 ctx->internal_buf = 0;
270 ctx->capacity = 0;
398 FLAC__bool FLAC__MD5Accumulate(FLAC__MD5Context *ctx, const FLAC__int32 * const signal[], unsigned channels, unsigned samples, unsigned bytes_per_sample)
408 if(ctx->capacity < bytes_needed) {
409 FLAC__byte *tmp = (FLAC__byte*)realloc(ctx->internal_buf, bytes_needed);
411 free(ctx->internal_buf);
412 if(0 == (ctx->internal_buf = (FLAC__byte*)safe_malloc_(bytes_needed)))
415 ctx->internal_buf = tmp;
416 ctx->capacity = bytes_needed;
419 format_input_(ctx->internal_buf, signal, channels, samples, bytes_per_sample);
421 FLAC__MD5Update(ctx, ctx->internal_buf, bytes_needed);