static uint32_t _fetchUint32(const CCNxTlvDictionary *interestDictionary, uint32_t key, uint32_t defaultValue) { if (ccnxTlvDictionary_IsValueInteger(interestDictionary, key)) { return (uint32_t) ccnxTlvDictionary_GetInteger(interestDictionary, key); } return defaultValue; }
bool ccnxValidationRsaSha256_Test(const CCNxTlvDictionary *message) { if (ccnxTlvDictionary_IsValueInteger(message, CCNxCodecSchemaV1TlvDictionary_ValidationFastArray_CRYPTO_SUITE)) { uint64_t cryptosuite = ccnxTlvDictionary_GetInteger(message, CCNxCodecSchemaV1TlvDictionary_ValidationFastArray_CRYPTO_SUITE); return (cryptosuite == PARCCryptoSuite_RSA_SHA256); } return false; }
LONGBOW_TEST_CASE(Global, ccnxWireFormatMessage_SetProtectedRegionStart) { const char string[] = "Hello dev null\n"; PARCBuffer *buffer = parcBuffer_Wrap((void *) string, sizeof(string), 0, sizeof(string)); CCNxWireFormatMessage *message = ccnxWireFormatMessage_FromContentObjectPacketType(CCNxTlvDictionary_SchemaVersion_V1, buffer); size_t start = 5; bool success = ccnxWireFormatMessage_SetProtectedRegionStart(message, start); assertTrue(success, "Failed to put integer in to dictionary"); assertTrue(ccnxTlvDictionary_IsValueInteger(message, CCNxCodecSchemaV1TlvDictionary_HeadersFastArray_ProtectedStart), "ProtectedStart not set"); ccnxWireFormatMessage_Release(&message); parcBuffer_Release(&buffer); }
bool ccnxValidationHmacSha256_Test(const CCNxTlvDictionary *message) { switch (ccnxTlvDictionary_GetSchemaVersion(message)) { case CCNxTlvDictionary_SchemaVersion_V1: { if (ccnxTlvDictionary_IsValueInteger(message, CCNxCodecSchemaV1TlvDictionary_ValidationFastArray_CRYPTO_SUITE)) { uint64_t cryptosuite = ccnxTlvDictionary_GetInteger(message, CCNxCodecSchemaV1TlvDictionary_ValidationFastArray_CRYPTO_SUITE); return (cryptosuite == PARCCryptoSuite_HMAC_SHA256); } return false; } default: trapIllegalValue(message, "Unknown schema version: %d", ccnxTlvDictionary_GetSchemaVersion(message)); } return false; }