static UA_StatusCode sym_encrypt_testing(const UA_SecurityPolicy *securityPolicy, void *channelContext, UA_ByteString *data) { SET_CALLED(sym_enc); ck_assert(securityPolicy != NULL); ck_assert(channelContext != NULL); ck_assert(data != NULL); return UA_STATUSCODE_GOOD; }
static UA_StatusCode generateNonce_testing(const UA_SecurityPolicy *securityPolicy, UA_ByteString *out) { ck_assert(securityPolicy != NULL); ck_assert(out != NULL); memset(out->data, 'N', out->length); SET_CALLED(generateNonce); return UA_STATUSCODE_GOOD; }
static UA_StatusCode generateKey_testing(const UA_SecurityPolicy *securityPolicy, const UA_ByteString *secret, const UA_ByteString *seed, UA_ByteString *out) { ck_assert(securityPolicy != NULL); ck_assert(secret != NULL); ck_assert(seed != NULL); ck_assert(out != NULL); SET_CALLED(generateKey); return UA_STATUSCODE_GOOD; }
static HRESULT _protocol_start(unsigned line, IInternetProtocol *protocol, LPCWSTR url, BOOL expect_mime) { HRESULT hres; SET_EXPECT(GetBindInfo); if(test_protocol == MK_PROTOCOL) SET_EXPECT(ReportProgress_DIRECTBIND); SET_EXPECT(ReportProgress_SENDINGREQUEST); if(expect_mime) SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE); if(test_protocol == MK_PROTOCOL) SET_EXPECT(ReportProgress_CACHEFILENAMEAVAIABLE); SET_EXPECT(ReportData); if(test_protocol == ITS_PROTOCOL) SET_EXPECT(ReportProgress_BEGINDOWNLOADDATA); SET_EXPECT(ReportResult); expect_hrResult = S_OK; hres = IInternetProtocol_Start(protocol, url, &protocol_sink, &bind_info, 0, 0); if(FAILED(hres)) { SET_CALLED(GetBindInfo); if(test_protocol == MK_PROTOCOL) SET_CALLED(ReportProgress_DIRECTBIND); SET_CALLED(ReportProgress_SENDINGREQUEST); if(expect_mime) SET_CALLED(ReportProgress_MIMETYPEAVAILABLE); if(test_protocol == MK_PROTOCOL) SET_EXPECT(ReportProgress_CACHEFILENAMEAVAIABLE); SET_CALLED(ReportData); if(test_protocol == ITS_PROTOCOL) SET_CALLED(ReportProgress_BEGINDOWNLOADDATA); SET_CALLED(ReportResult); }else { CHECK_CALLED(GetBindInfo); if(test_protocol == MK_PROTOCOL) SET_CALLED(ReportProgress_DIRECTBIND); CHECK_CALLED(ReportProgress_SENDINGREQUEST); if(expect_mime) CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE); if(test_protocol == MK_PROTOCOL) SET_EXPECT(ReportProgress_CACHEFILENAMEAVAIABLE); CHECK_CALLED(ReportData); if(test_protocol == ITS_PROTOCOL) CHECK_CALLED(ReportProgress_BEGINDOWNLOADDATA); CHECK_CALLED(ReportResult); } return hres; }
static UA_StatusCode setRemoteSymIv_testing(void *channelContext, const UA_ByteString *val) { SET_CALLED(setRemoteSymIv); ck_assert(channelContext != NULL); ck_assert(val != NULL); ck_assert(val->data != NULL); ck_assert_msg(val->length == keySizes->sym_enc_blockSize, "Expected length to be %i but got %i", keySizes->sym_enc_blockSize, val->length); return UA_STATUSCODE_GOOD; }
static UA_StatusCode setLocalSymSigningKey_testing(void *channelContext, const UA_ByteString *val) { SET_CALLED(setLocalSymSigningKey); ck_assert(channelContext != NULL); ck_assert(val != NULL); ck_assert(val->data != NULL); ck_assert_msg(val->length == keySizes->sym_sig_keyLen, "Expected length to be %i but got %i", keySizes->sym_sig_keyLen, val->length); return UA_STATUSCODE_GOOD; }
static UA_StatusCode newContext_testing(const UA_SecurityPolicy *securityPolicy, const UA_ByteString *remoteCertificate, void **channelContext) { SET_CALLED(newContext); ck_assert(securityPolicy != NULL); ck_assert(remoteCertificate != NULL); ck_assert(channelContext != NULL); ck_assert(funcsCalled != NULL); *channelContext = (void *)funcsCalled; return UA_STATUSCODE_GOOD; }
static UA_StatusCode makeThumbprint_testing(const UA_SecurityPolicy *securityPolicy, const UA_ByteString *certificate, UA_ByteString *thumbprint) { SET_CALLED(makeCertificateThumbprint); ck_assert(securityPolicy != NULL); ck_assert(certificate != NULL); ck_assert(thumbprint != NULL); ck_assert_msg(thumbprint->length == 20, "Thumbprints have to be 20 bytes long (current specification)"); memset(thumbprint->data, 42, 20); return UA_STATUSCODE_GOOD; }
static UA_StatusCode sym_sign_testing(const UA_SecurityPolicy *securityPolicy, void *channelContext, const UA_ByteString *message, UA_ByteString *signature) { SET_CALLED(sym_sign); ck_assert(securityPolicy != NULL); ck_assert(channelContext != NULL); ck_assert(message != NULL); ck_assert(signature != NULL); ck_assert(signature->length != 0); ck_assert(signature->data != NULL); memset(signature->data, 'S', signature->length); return UA_STATUSCODE_GOOD; }
static UA_StatusCode asym_sign_testing(const UA_SecurityPolicy *securityPolicy, void *channelContext, const UA_ByteString *message, UA_ByteString *signature) { SET_CALLED(asym_sign); ck_assert(securityPolicy != NULL); ck_assert(channelContext != NULL); ck_assert(message != NULL); ck_assert(signature != NULL); ck_assert_msg(signature->length == keySizes->asym_lcl_sig_size, "Expected signature length to be %i but was %i", keySizes->asym_lcl_sig_size, signature->length); memset(signature->data, '*', signature->length); return UA_STATUSCODE_GOOD; }
static UA_StatusCode asym_encrypt_testing(const UA_SecurityPolicy *securityPolicy, void *channelContext, UA_ByteString *data) { SET_CALLED(asym_enc); ck_assert(securityPolicy != NULL); ck_assert(channelContext != NULL); ck_assert(data != NULL); size_t blockSize = securityPolicy->asymmetricModule.cryptoModule.encryptionAlgorithm.getRemotePlainTextBlockSize(securityPolicy, channelContext); ck_assert_msg(data->length % blockSize == 0, "Expected the length of the data to be encrypted to be a multiple of the plaintext block size (%i). " "Remainder was %i", blockSize, data->length % blockSize); for(size_t i = 0; i < data->length; ++i) { data->data[i] = (UA_Byte)((data->data[i] + 1) % (UA_BYTE_MAX + 1)); } return UA_STATUSCODE_GOOD; }
static void deleteContext_testing(void *channelContext) { SET_CALLED(deleteContext); ck_assert(channelContext != NULL); }