- /* signatures should be short enough to fit one attribute */
- ASSERT(MAX_ATTR_SIZE > BASE224_ENC_LENGTH(sizeof(struct image_vector) + 4 + sig->len * sizeof(struct image_region)));
- byte buf[MAX_ATTR_SIZE], *b = buf;
- memcpy(b, &sig->vec, sizeof(struct image_vector));
- b += sizeof(struct image_vector);
- *b++ = sig->len;
- *b++ = sig->df;
- *(u16 *)b++ = sig->dh;
- for (uns i = 0; i < sig->len; i++)
- {
- memcpy(b, sig->reg + i, sizeof(struct image_region));
- b += sizeof(struct image_region);
- }
- uns len = b - buf;
- byte b224[MAX_ATTR_SIZE];
- b224[base224_encode(b224, buf, len)] = 0;
- obj_set_attr(o, 'H', b224);
+ /* signatures should be short enough to in a single attribute */
+ uns size = image_signature_size(sig->len);
+ byte buf[BASE224_ENC_LENGTH(size) + 1];
+ buf[base224_encode(buf, (byte *)sig, size)] = 0;
+ obj_set_attr(o, 'H', buf);
+}
+
+uns
+get_image_obj_signature(struct image_signature *sig, struct odes *o)
+{
+ byte *a = obj_find_aval(o, 'H');
+ if (!a)
+ return 0;
+ UNUSED uns size = base224_decode((byte *)sig, a, strlen(a));
+ ASSERT(size == image_signature_size(sig->len));
+ return 1;