static rs_result rs_loadsig_s_magic(rs_job_t *job) { int l; rs_result result; if ((result = rs_suck_n4(job, &l)) != RS_DONE) { return result; } else if (l != RS_SIG_MAGIC) { rs_error("wrong magic number %#10x for signature", l); return RS_BAD_MAGIC; } else { rs_trace("got signature magic %#10x", l); } job->statefn = rs_loadsig_s_blocklen; return RS_RUNNING; }
static rs_result rs_loadsig_s_weak(rs_job_t *job) { int l; rs_result result; result = rs_suck_n4(job, &l); if (result == RS_DONE) ; else if (result == RS_INPUT_ENDED) /* ending here is OK */ return RS_DONE; else return result; job->weak_sig = l; job->statefn = rs_loadsig_s_strong; return RS_RUNNING; }
static rs_result rs_loadsig_s_blocklen(rs_job_t *job) { int l; rs_result result; if ((result = rs_suck_n4(job, &l)) != RS_DONE) return result; job->block_len = l; if (job->block_len < 1) { rs_error("block length of %d is bogus", (int) job->block_len); return RS_CORRUPT; } job->statefn = rs_loadsig_s_stronglen; job->stats.block_len = job->block_len; return RS_RUNNING; }
/** * Called while we're trying to read the header of the patch. */ static rs_result rs_patch_s_header(rs_job_t *job) { int v; rs_result result; if ((result = rs_suck_n4(job, &v)) != RS_DONE) return result; if (v != RS_DELTA_MAGIC) { rs_log(RS_LOG_ERR, "got magic number %#x rather than expected value %#x", v, RS_DELTA_MAGIC); return RS_BAD_MAGIC; } else rs_trace("got patch magic %#x", v); job->statefn = rs_patch_s_cmdbyte; return RS_RUNNING; }
static rs_result rs_loadsig_s_magic(rs_job_t *job) { int l; rs_result result; if ((result = rs_suck_n4(job, &l)) != RS_DONE) { return result; } switch(l) { case RS_MD4_SIG_MAGIC: case RS_BLAKE2_SIG_MAGIC: job->magic = job->signature->magic = l; rs_trace("got signature magic %#10x", l); break; default: rs_error("wrong magic number %#10x for signature", l); return RS_BAD_MAGIC; } job->statefn = rs_loadsig_s_blocklen; return RS_RUNNING; }
static rs_result rs_loadsig_s_stronglen(rs_job_t *job) { int l; rs_result result; if ((result = rs_suck_n4(job, &l)) != RS_DONE) return result; job->strong_sum_len = l; if (l < 0 || l > RS_MAX_STRONG_SUM_LENGTH) { rs_error("strong sum length %d is implausible", l); return RS_CORRUPT; } job->signature->block_len = job->block_len; job->signature->strong_sum_len = job->strong_sum_len; rs_trace("allocated sigset_t (strong_sum_len=%d, block_len=%d)", (int) job->strong_sum_len, (int) job->block_len); job->statefn = rs_loadsig_s_weak; return RS_RUNNING; }