KNOWNID(REPOKEY_TYPE_DIRNUMNUMARRAY, "repokey:type:dirnumnumarray"),
KNOWNID(REPOKEY_TYPE_MD5, "repokey:type:md5"),
KNOWNID(REPOKEY_TYPE_SHA1, "repokey:type:sha1"),
+KNOWNID(REPOKEY_TYPE_SHA256, "repokey:type:sha256"),
KNOWNID(SOLVABLE_SUMMARY, "solvable:summary"),
KNOWNID(SOLVABLE_DESCRIPTION, "solvable:description"),
read_u8(data);
break;
}
+ case REPOKEY_TYPE_SHA256:
+ {
+ int i;
+ for (i = 0; i < SIZEOF_SHA256; i++)
+ read_u8(data);
+ break;
+ }
case REPOKEY_TYPE_IDARRAY:
case REPOKEY_TYPE_REL_IDARRAY:
while ((read_u8(data) & 0xc0) != 0)
type = idmap[type];
else if (parent)
type = str2id(pool, stringpool_id2str(spool, type), 1);
- if (type < REPOKEY_TYPE_VOID || type > REPOKEY_TYPE_SHA1)
+ if (type < REPOKEY_TYPE_VOID || type > REPOKEY_TYPE_SHA256)
{
pool_debug(pool, SAT_ERROR, "unsupported data type '%s'\n", id2str(pool, type));
data.error = SOLV_ERROR_UNSUPPORTED;
}
}
+static inline int
+checksumtype2len(Id type)
+{
+ switch (type)
+ {
+ case REPOKEY_TYPE_MD5:
+ return SIZEOF_MD5;
+ case REPOKEY_TYPE_SHA1:
+ return SIZEOF_SHA1;
+ case REPOKEY_TYPE_SHA256:
+ return SIZEOF_SHA256;
+ default:
+ return 0;
+ }
+}
+
void
repodata_set_bin_checksum(Repodata *data, Id entry, Id keyname, Id type,
const unsigned char *str)
{
Repokey key;
- int l;
- switch (type)
- {
- case REPOKEY_TYPE_MD5: l = SIZEOF_MD5; break;
- case REPOKEY_TYPE_SHA1: l = SIZEOF_SHA1; break;
- default: return;
- }
+ int l = checksumtype2len(type);
+
+ if (!l)
+ return;
key.name = keyname;
key.type = type;
key.size = 0;
repodata_set_checksum(Repodata *data, Id entry, Id keyname, Id type,
const char *str)
{
- int l;
- switch (type)
- {
- case REPOKEY_TYPE_MD5: l = SIZEOF_MD5; break;
- case REPOKEY_TYPE_SHA1: l = SIZEOF_SHA1; break;
- default: return;
- }
- unsigned char buf[l];
+ unsigned char buf[64];
+ int l = checksumtype2len(type);
+
+ if (!l)
+ return;
if (hexstr2bytes(buf, str, l) != l)
{
- fprintf(stderr, "Invalid hex character in %s\n", str);
+ fprintf(stderr, "Invalid hex character in '%s'\n", str);
return;
}
repodata_set_bin_checksum(data, entry, keyname, type, buf);
{
int i, l;
char *str, *s;
- switch (type)
- {
- case REPOKEY_TYPE_MD5: l = SIZEOF_MD5; break;
- case REPOKEY_TYPE_SHA1: l = SIZEOF_SHA1; break;
- default: return id2str(data->repo->pool, ID_EMPTY);
- }
- s = str = pool_alloctmpspace(data->repo->pool, 2*l + 1);
- for (i = 0; i < l; i++, s+=2)
+
+ l = checksumtype2len(type);
+ if (!l)
+ return "";
+ s = str = pool_alloctmpspace(data->repo->pool, 2 * l + 1);
+ for (i = 0; i < l; i++)
{
unsigned char v = buf[i];
unsigned char w = v >> 4;
- s[0] = w >= 10 ? (w-10)+'a' : w + '0';
+ *s++ = w >= 10 ? w + ('a' - 10) : w + '0';
w = v & 15;
- s[1] = w >= 10 ? (w-10)+'a' : w + '0';
+ *s++ = w >= 10 ? w + ('a' - 10) : w + '0';
}
*s = 0;
return str;
case REPOKEY_TYPE_SHA1:
kv->str = (const char *)dp;
return dp + SIZEOF_SHA1;
+ case REPOKEY_TYPE_SHA256:
+ kv->str = (const char *)dp;
+ return dp + SIZEOF_SHA256;
case REPOKEY_TYPE_IDARRAY:
return data_read_ideof(dp, &kv->id, &kv->eof);
case REPOKEY_TYPE_DIRSTRARRAY:
return dp + SIZEOF_MD5;
case REPOKEY_TYPE_SHA1:
return dp + SIZEOF_SHA1;
+ case REPOKEY_TYPE_SHA256:
+ return dp + SIZEOF_SHA256;
case REPOKEY_TYPE_IDARRAY:
case REPOKEY_TYPE_REL_IDARRAY:
while ((*dp & 0xc0) != 0)
return dp + SIZEOF_MD5;
case REPOKEY_TYPE_SHA1:
return dp + SIZEOF_SHA1;
+ case REPOKEY_TYPE_SHA256:
+ return dp + SIZEOF_SHA256;
case REPOKEY_TYPE_ID:
dp = data_read_id(dp, &id);
if (id >= maxid)