|
|
@ -65,8 +65,8 @@ void appendUriSubtypes(uint32_t mask, unsigned char *buf) { |
|
|
|
|
|
|
|
|
|
|
|
char *cc_conditionUri(const CC *cond) { |
|
|
|
unsigned char *fp = cond->type->fingerprint(cond); |
|
|
|
if (!fp) return NULL; |
|
|
|
unsigned char *fp = calloc(1, 32); |
|
|
|
cond->type->fingerprint(cond, fp); |
|
|
|
|
|
|
|
unsigned char *encoded = base64_encode(fp, 32); |
|
|
|
|
|
|
@ -117,9 +117,8 @@ uint32_t fromAsnSubtypes(const ConditionTypes_t types) { |
|
|
|
|
|
|
|
size_t cc_conditionBinary(const CC *cond, unsigned char *buf) { |
|
|
|
Condition_t *asn = calloc(1, sizeof(Condition_t)); |
|
|
|
bool r = asnCondition(cond, asn); |
|
|
|
asnCondition(cond, asn); |
|
|
|
size_t out = 0; |
|
|
|
if (!r) goto end; |
|
|
|
asn_enc_rval_t rc = der_encode_to_buffer(&asn_DEF_Condition, asn, buf, 1000); |
|
|
|
if (rc.encoded == -1) goto end; |
|
|
|
out = rc.encoded; |
|
|
@ -141,7 +140,7 @@ size_t cc_fulfillmentBinary(const CC *cond, unsigned char *buf, size_t length) { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool asnCondition(const CC *cond, Condition_t *asn) { |
|
|
|
void asnCondition(const CC *cond, Condition_t *asn) { |
|
|
|
asn->present = cc_isAnon(cond) ? cond->conditionType->asnType : cond->type->asnType; |
|
|
|
|
|
|
|
// This may look a little weird - we dont have a reference here to the correct
|
|
|
@ -150,13 +149,10 @@ bool asnCondition(const CC *cond, Condition_t *asn) { |
|
|
|
|
|
|
|
CompoundSha256Condition_t *choice = &asn->choice.thresholdSha256; |
|
|
|
choice->cost = cc_getCost(cond); |
|
|
|
choice->fingerprint.buf = cond->type->fingerprint(cond); |
|
|
|
if (choice->fingerprint.buf == 0) { |
|
|
|
return 0; |
|
|
|
} |
|
|
|
choice->fingerprint.size = 32; |
|
|
|
choice->fingerprint.buf = calloc(1, 32); |
|
|
|
cond->type->fingerprint(cond, choice->fingerprint.buf); |
|
|
|
choice->subtypes = asnSubtypes(cond->type->getSubtypes(cond)); |
|
|
|
return 1; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|