Exemplo n.º 1
0
main(){
    uint64_t md5val;
    int i;
    uint8_t in[1000];

    for(i=0; i<1000; i++) in[i]= i*i;
    av_md5_sum( (uint8_t*)&md5val, in,  1000); printf("%"PRId64"\n", md5val);
    av_md5_sum( (uint8_t*)&md5val, in,  63); printf("%"PRId64"\n", md5val);
    av_md5_sum( (uint8_t*)&md5val, in,  64); printf("%"PRId64"\n", md5val);
    av_md5_sum( (uint8_t*)&md5val, in,  65); printf("%"PRId64"\n", md5val);
    for(i=0; i<1000; i++) in[i]= i % 127;
    av_md5_sum( (uint8_t*)&md5val, in,  999); printf("%"PRId64"\n", md5val);
}
Exemplo n.º 2
0
int main(void){
    uint8_t md5val[16];
    int i;
    uint8_t in[1000];

    for (i = 0; i < 1000; i++)
        in[i] = i * i;
    av_md5_sum(md5val, in, 1000); print_md5(md5val);
    av_md5_sum(md5val, in,   63); print_md5(md5val);
    av_md5_sum(md5val, in,   64); print_md5(md5val);
    av_md5_sum(md5val, in,   65); print_md5(md5val);
    for (i = 0; i < 1000; i++)
        in[i] = i % 127;
    av_md5_sum(md5val, in,  999); print_md5(md5val);

    return 0;
}
Exemplo n.º 3
0
int main(void){
    uint8_t md5val[16];
    int i;
    volatile uint8_t in[1000]; // volatile to workaround http://llvm.org/bugs/show_bug.cgi?id=20849
    // FIXME remove volatile once it has been fixed and all fate clients are updated

    for (i = 0; i < 1000; i++)
        in[i] = i * i;
    av_md5_sum(md5val, in, 1000); print_md5(md5val);
    av_md5_sum(md5val, in,   63); print_md5(md5val);
    av_md5_sum(md5val, in,   64); print_md5(md5val);
    av_md5_sum(md5val, in,   65); print_md5(md5val);
    for (i = 0; i < 1000; i++)
        in[i] = i % 127;
    av_md5_sum(md5val, in,  999); print_md5(md5val);

    return 0;
}
Exemplo n.º 4
0
void av_cold av_lfg_init(AVLFG *c, unsigned int seed){
    uint8_t tmp[16]={0};
    int i;

    for(i=8; i<64; i+=4){
        AV_WL32(tmp, seed); tmp[4]=i;
        av_md5_sum(tmp, tmp,  16);
        c->state[i  ]= AV_RL32(tmp);
        c->state[i+1]= AV_RL32(tmp+4);
        c->state[i+2]= AV_RL32(tmp+8);
        c->state[i+3]= AV_RL32(tmp+12);
    }
    c->index=0;
}
Exemplo n.º 5
0
static char *mp_get_playback_resume_config_filename(struct MPContext *mpctx,
                                                    const char *fname)
{
    struct MPOpts *opts = mpctx->opts;
    char *res = NULL;
    void *tmp = talloc_new(NULL);
    const char *realpath = fname;
    bstr bfname = bstr0(fname);
    if (!mp_is_url(bfname)) {
        if (opts->ignore_path_in_watch_later_config) {
            realpath = mp_basename(fname);
        } else {
            char *cwd = mp_getcwd(tmp);
            if (!cwd)
                goto exit;
            realpath = mp_path_join(tmp, cwd, fname);
        }
    }
    if (bstr_startswith0(bfname, "dvd://") && opts->dvd_opts && opts->dvd_opts->device)
        realpath = talloc_asprintf(tmp, "%s - %s", realpath, opts->dvd_opts->device);
    if ((bstr_startswith0(bfname, "br://") || bstr_startswith0(bfname, "bd://") ||
         bstr_startswith0(bfname, "bluray://")) && opts->bluray_device)
        realpath = talloc_asprintf(tmp, "%s - %s", realpath, opts->bluray_device);
    uint8_t md5[16];
    av_md5_sum(md5, realpath, strlen(realpath));
    char *conf = talloc_strdup(tmp, "");
    for (int i = 0; i < 16; i++)
        conf = talloc_asprintf_append(conf, "%02X", md5[i]);

    if (!mpctx->cached_watch_later_configdir) {
        char *wl_dir = mpctx->opts->watch_later_directory;
        if (wl_dir && wl_dir[0]) {
            mpctx->cached_watch_later_configdir =
                mp_get_user_path(mpctx, mpctx->global, wl_dir);
        }
    }

    if (!mpctx->cached_watch_later_configdir) {
        mpctx->cached_watch_later_configdir =
            mp_find_user_config_file(mpctx, mpctx->global, MP_WATCH_LATER_CONF);
    }

    if (mpctx->cached_watch_later_configdir)
        res = mp_path_join(NULL, mpctx->cached_watch_later_configdir, conf);

exit:
    talloc_free(tmp);
    return res;
}
static void real_calc_response_and_checksum (char *response, char *chksum, char *challenge) {

  int   ch_len;
  int   i;
  unsigned char zres[16], buf[64];

  /* initialize buffer */
  AV_WB32(buf, 0xa1e9149d);
  AV_WB32(buf+4, 0x0e6b3b59);

  /* some (length) checks */
  if (challenge != NULL)
  {
    ch_len = strlen (challenge);

    if (ch_len == 40) /* what a hack... */
      ch_len=32;
    if ( ch_len > 56 ) ch_len=56;

    /* copy challenge to buf */
    memcpy(buf+8, challenge, ch_len);
    memset(buf+8+ch_len, 0, 56-ch_len);
  }

    /* xor challenge bytewise with xor_table */
    for (i=0; i<XOR_TABLE_SIZE; i++)
      buf[8+i] ^= xor_table[i];

  av_md5_sum(zres, buf, 64);

  /* convert zres to ascii string */
  for (i=0; i<16; i++ )
    sprintf(response+i*2, "%02x", zres[i]);

  /* add tail */
  strcpy (&response[32], "01d0a8e3");

  /* calculate checksum */
  for (i=0; i<8; i++)
    chksum[i] = response[i*4];
  chksum[8] = 0;
}
Exemplo n.º 7
0
static char *mp_get_playback_resume_config_filename(struct mpv_global *global,
                                                    const char *fname)
{
    struct MPOpts *opts = global->opts;
    char *res = NULL;
    void *tmp = talloc_new(NULL);
    const char *realpath = fname;
    bstr bfname = bstr0(fname);
    if (!mp_is_url(bfname)) {
        if (opts->ignore_path_in_watch_later_config) {
            realpath = mp_basename(fname);
        } else {
            char *cwd = mp_getcwd(tmp);
            if (!cwd)
                goto exit;
            realpath = mp_path_join(tmp, bstr0(cwd), bstr0(fname));
        }
    }
    if (bstr_startswith0(bfname, "dvd://"))
        realpath = talloc_asprintf(tmp, "%s - %s", realpath, opts->dvd_device);
    if (bstr_startswith0(bfname, "br://") || bstr_startswith0(bfname, "bd://") ||
        bstr_startswith0(bfname, "bluray://"))
        realpath = talloc_asprintf(tmp, "%s - %s", realpath, opts->bluray_device);
    uint8_t md5[16];
    av_md5_sum(md5, realpath, strlen(realpath));
    char *conf = talloc_strdup(tmp, "");
    for (int i = 0; i < 16; i++)
        conf = talloc_asprintf_append(conf, "%02X", md5[i]);

    res = talloc_asprintf(tmp, MP_WATCH_LATER_CONF "/%s", conf);
    res = mp_find_config_file(NULL, global, res);

    if (!res) {
        res = mp_find_config_file(tmp, global, MP_WATCH_LATER_CONF);
        if (res)
            res = talloc_asprintf(NULL, "%s/%s", res, conf);
    }

exit:
    talloc_free(tmp);
    return res;
}
Exemplo n.º 8
0
void
ff_rdt_calc_response_and_checksum(char response[41], char chksum[9],
                                  const char *challenge)
{
	int ch_len = strlen (challenge), i;
	unsigned char zres[16],
	         buf[64] = { 0xa1, 0xe9, 0x14, 0x9d, 0x0e, 0x6b, 0x3b, 0x59 };
#define XOR_TABLE_SIZE 37
	const unsigned char xor_table[XOR_TABLE_SIZE] =
	{
		0x05, 0x18, 0x74, 0xd0, 0x0d, 0x09, 0x02, 0x53,
		0xc0, 0x01, 0x05, 0x05, 0x67, 0x03, 0x19, 0x70,
		0x08, 0x27, 0x66, 0x10, 0x10, 0x72, 0x08, 0x09,
		0x63, 0x11, 0x03, 0x71, 0x08, 0x08, 0x70, 0x02,
		0x10, 0x57, 0x05, 0x18, 0x54
	};

	/* some (length) checks */
	if (ch_len == 40) /* what a hack... */
		ch_len = 32;
	else if (ch_len > 56)
		ch_len = 56;
	memcpy(buf + 8, challenge, ch_len);

	/* xor challenge bytewise with xor_table */
	for (i = 0; i < XOR_TABLE_SIZE; i++)
		buf[8 + i] ^= xor_table[i];

	av_md5_sum(zres, buf, 64);
	ff_data_to_hex(response, zres, 16, 1);

	/* add tail */
	strcpy (response + 32, "01d0a8e3");

	/* calculate checksum */
	for (i = 0; i < 8; i++)
		chksum[i] = response[i * 4];
	chksum[8] = 0;
}
Exemplo n.º 9
0
static char *mp_get_playback_resume_config_filename(struct mpv_global *global,
        const char *fname)
{
    char *res = NULL;
    void *tmp = talloc_new(NULL);
    const char *realpath = fname;
    bstr bfname = bstr0(fname);
    if (!mp_is_url(bfname)) {
        char *cwd = mp_getcwd(tmp);
        if (!cwd)
            goto exit;
        realpath = mp_path_join(tmp, bstr0(cwd), bstr0(fname));
    }
#if HAVE_DVDREAD || HAVE_DVDNAV
    if (bstr_startswith0(bfname, "dvd://"))
        realpath = talloc_asprintf(tmp, "%s - %s", realpath, dvd_device);
#endif
#if HAVE_LIBBLURAY
    if (bstr_startswith0(bfname, "br://") || bstr_startswith0(bfname, "bd://") ||
            bstr_startswith0(bfname, "bluray://"))
        realpath = talloc_asprintf(tmp, "%s - %s", realpath, bluray_device);
#endif
    uint8_t md5[16];
    av_md5_sum(md5, realpath, strlen(realpath));
    char *conf = talloc_strdup(tmp, "");
    for (int i = 0; i < 16; i++)
        conf = talloc_asprintf_append(conf, "%02X", md5[i]);

    conf = talloc_asprintf(tmp, "%s/%s", MP_WATCH_LATER_CONF, conf);

    res = mp_find_user_config_file(NULL, global, conf);

exit:
    talloc_free(tmp);
    return res;
}
Exemplo n.º 10
0
/* Do something useful with the filtered data: this simple
 * example just prints the MD5 checksum of each plane to stdout. */
static int process_output(struct AVMD5 *md5, AVFrame *frame)
{
    int planar     = av_sample_fmt_is_planar(frame->format);
    int channels   = av_get_channel_layout_nb_channels(frame->channel_layout);
    int planes     = planar ? channels : 1;
    int bps        = av_get_bytes_per_sample(frame->format);
    int plane_size = bps * frame->nb_samples * (planar ? 1 : channels);
    int i, j;

    for (i = 0; i < planes; i++) {
        uint8_t checksum[16];

        av_md5_init(md5);
        av_md5_sum(checksum, frame->extended_data[i], plane_size);

        fprintf(stdout, "plane %d: 0x", i);
        for (j = 0; j < sizeof(checksum); j++)
            fprintf(stdout, "%02X", checksum[j]);
        fprintf(stdout, "\n");
    }
    fprintf(stdout, "\n");

    return 0;
}
Exemplo n.º 11
0
static void run_lavu_md5(uint8_t *output,
                         const uint8_t *input, unsigned size)
{
    av_md5_sum(output, input, size);
}