PARCURISegment * parcURISegment_Clone(const PARCURISegment *segment) { assertNotNull(segment, "Parameter must be a non-null PARC_URISegment pointer."); PARCBuffer *copy = parcBuffer_Copy(segment->buffer); PARCURISegment *result = parcURISegment_CreateFromBuffer(copy); parcBuffer_Release(©); return result; }
/** * wrap the HMAC in digestToSign in a PARCSignature * * @param hashToSign is the HMAC computed by the our PARCCryptoHasher. */ static PARCSignature * _signDigest(void *interfaceContext, const PARCCryptoHash *hashToSign) { // The digest computed via our hash function (hmac) is the actual signature. // just need to wrap it up with the right parameters. PARCBuffer *signatureBits = parcBuffer_Copy(parcCryptoHash_GetDigest(hashToSign)); PARCSignature *result = parcSignature_Create(_getSigningAlgorithm(interfaceContext), parcCryptoHash_GetDigestType(hashToSign), signatureBits); parcBuffer_Release(&signatureBits); return result; }
CCNxNameSegment * ccnxNameSegment_Copy(const CCNxNameSegment *segment) { PARCBuffer *value = parcBuffer_Copy(segment->value); CCNxNameLabel *label = ccnxNameLabel_Copy(segment->label); CCNxNameSegment *result = ccnxNameSegment_CreateLabelValue(label, value); ccnxNameLabel_Release(&label); parcBuffer_Release(&value); return result; }
LONGBOW_TEST_CASE(Local, _athenaLRUContentStore_GetMatchByNameAndObjectHash) { AthenaLRUContentStore *impl = _createLRUContentStore(); PARCBuffer *payload = parcBuffer_Allocate(1200); CCNxName *name = ccnxName_CreateFromURI("lci:/boose/roo/pie"); CCNxContentObject *contentObject = ccnxContentObject_CreateWithDataPayload(name, NULL); parcBuffer_Release(&payload); _AthenaLRUContentStoreEntry *entry1 = _athenaLRUContentStoreEntry_Create(contentObject); entry1->hasKeyId = false; entry1->hasContentObjectHash = false; bool status = _athenaLRUContentStore_PutLRUContentStoreEntry(impl, entry1); assertTrue(status, "Expected to add the entry"); // Now add another content object with the same name, but an object hash too. CCNxContentObject *contentObject2 = ccnxContentObject_CreateWithDataPayload(name, NULL); _AthenaLRUContentStoreEntry *entry2 = _athenaLRUContentStoreEntry_Create(contentObject2); entry2->contentObjectHash = parcBuffer_WrapCString("corned beef"); entry2->hasContentObjectHash = true; status = _athenaLRUContentStore_PutLRUContentStoreEntry(impl, entry2); assertTrue(status, "Expected to add the entry"); assertTrue(impl->numEntries == 2, "Expected 2 store items"); // Now match on Name + ObjectHash. CCNxInterest *interest = ccnxInterest_CreateSimple(name); PARCBuffer *hashRestriction = parcBuffer_Copy(entry2->contentObjectHash); ccnxInterest_SetContentObjectHashRestriction(interest, hashRestriction); parcBuffer_Release(&hashRestriction); CCNxContentObject *match = _athenaLRUContentStore_GetMatch(impl, interest); assertNotNull(match, "Expected to match something"); assertTrue(match == contentObject2, "Expected the content object with the keyId"); _athenaLRUContentStoreEntry_Release(&entry1); _athenaLRUContentStoreEntry_Release(&entry2); ccnxContentObject_Release(&contentObject2); ccnxContentObject_Release(&contentObject); ccnxName_Release(&name); ccnxInterest_Release(&interest); _athenaLRUContentStore_Release((AthenaContentStoreImplementation *) &impl); }
static PARCBuffer * _GetDEREncodedPrivateKey(PARCPkcs12KeyStore *keystore) { parcSecurity_AssertIsInitialized(); assertNotNull(keystore, "Parameter must be non-null PARCPkcs12KeyStore"); if (keystore->private_key_der == NULL) { uint8_t *der = NULL; // this allocates memory for der int derLength = i2d_PrivateKey(keystore->private_key, &der); if (derLength > 0) { keystore->private_key_der = parcBuffer_Flip(parcBuffer_PutArray(parcBuffer_Allocate(derLength), derLength, der)); } OPENSSL_free(der); } return parcBuffer_Copy(keystore->private_key_der); }
static int _internalSEND(_TemplateLinkData *linkData, PARCBuffer *wireFormatBuffer) { parcDeque_Append(linkData->queue, parcBuffer_Copy(wireFormatBuffer)); return 0; }