const unsigned char * solv_chksum_get(Chksum *chk, int *lenp) { if (chk->done) { if (lenp) *lenp = solv_chksum_len(chk->type); return chk->result; } switch(chk->type) { case REPOKEY_TYPE_MD5: solv_MD5_Final(chk->result, &chk->c.md5); chk->done = 1; if (lenp) *lenp = 16; return chk->result; case REPOKEY_TYPE_SHA1: solv_SHA1_Final(&chk->c.sha1, chk->result); chk->done = 1; if (lenp) *lenp = 20; return chk->result; case REPOKEY_TYPE_SHA224: solv_SHA224_Final(chk->result, &chk->c.sha224); chk->done = 1; if (lenp) *lenp = 28; return chk->result; case REPOKEY_TYPE_SHA256: solv_SHA256_Final(chk->result, &chk->c.sha256); chk->done = 1; if (lenp) *lenp = 32; return chk->result; case REPOKEY_TYPE_SHA384: solv_SHA384_Final(chk->result, &chk->c.sha384); chk->done = 1; if (lenp) *lenp = 48; return chk->result; case REPOKEY_TYPE_SHA512: solv_SHA512_Final(chk->result, &chk->c.sha512); chk->done = 1; if (lenp) *lenp = 64; return chk->result; default: if (lenp) *lenp = 0; return 0; } }
const unsigned char * solv_chksum_get(void *handle, int *lenp) { struct ctxhandle *h = handle; if (h->done) { if (lenp) *lenp = solv_chksum_len(h->type); return h->result; } switch(h->type) { case REPOKEY_TYPE_MD5: solv_MD5_Final(h->result, &h->c.md5); h->done = 1; if (lenp) *lenp = 16; return h->result; case REPOKEY_TYPE_SHA1: solv_SHA1_Final(&h->c.sha1, h->result); h->done = 1; if (lenp) *lenp = 20; return h->result; case REPOKEY_TYPE_SHA256: solv_SHA256_Final(h->result, &h->c.sha256); h->done = 1; if (lenp) *lenp = 32; return h->result; default: if (lenp) *lenp = 0; return 0; } }