// // Just as a gadget, I implemented tone decoding by taking the // fft of the last rxsymbol samples. Cannot say that it was // better, so it was deleted after all. void throb::throb_rx (DSPCOMPLEX in) { DSPCOMPLEX rxword [MAX_TONES]; int16_t i, tone1, tone2, maxtone; static int cnt = 0; symbol [symptr] = in; if (rxcntr > 0.0) return; // correlate against the predefined tones for (i = 0; i < tonesformode (throbMode); i++) rxword [i] = cmac (rxtone[i], symbol, symptr + 1, rxsymlen); // // and find the strongest tones maxtone = findtones(rxword, &tone1, &tone2); // decode if (!throbReverse) decodechar (tone1, tone2); else decodechar (tonesformode (throbMode) - 1 - tone2, tonesformode (throbMode) - 1 - tone1); if (afcOn && (metrics >= thresHold)) { DSPCOMPLEX z1, z2; float f; // // for error correction, we compute the freq difference // between the current maxtone and the previous one // Note that correction basically works for only half // the distance of two subsequent tones. z1 = rxword [maxtone]; z2 = cmac (rxtone [maxtone], symbol, symptr + 2, rxsymlen); f = arg (conj (z2) * z1) / ((2 * downRate * M_PI) / sampleRate); f += freqs [maxtone]; throbIF -= f / (tonesformode (throbMode) - 1); } // done with this symbol, start over rxcntr = rxsymlen; waitsync = 1; if (++cnt > 10) { cnt = 0; showS2N (s2n); showMetrics (metrics); } }
BUF_MEM * authenticate(const KA_CTX *ctx, const BUF_MEM *data) { switch (EVP_CIPHER_nid(ctx->cipher)) { case NID_des_ede_cbc: return retail_mac_des(ctx->k_mac, data); case NID_aes_128_cbc: case NID_aes_192_cbc: case NID_aes_256_cbc: return cmac(ctx->cmac_ctx, ctx->cipher, ctx->k_mac, data, EAC_AES_MAC_LENGTH); default: log_err("Unknown cipher"); return NULL; } }
void fcmul(cplxfloat_t *c, const cplxfloat_t *a, const cplxfloat_t *b, unsigned int d1, unsigned int d2, unsigned int d3) { cplxfloat_t *r = c, s; unsigned int i, j, k; if (c == a || c == b) r = alloca(d1 * d3 * sizeof(r[0])); for (i = 0; i < d1; i++) for (k = 0; k < d3; k++) { cplx(s, 0, 0); for (j = 0; j < d2; j++) cmac(s, a[i*d2+j], b[j*d3+k]); r[i*d3+k] = s; } if (r != c) memcpy(c, r, d1 * d3 * sizeof(c[0])); }
void tool_app_t::create_docheader() { netlist_tool_t nt(*this, "netlist"); nt.init(); nt.log().verbose.set_enabled(false); nt.log().warning.set_enabled(false); nt.setup().register_source(plib::make_unique_base<netlist::source_t, netlist::source_proc_t>(nt.setup(), "dummy", &netlist_dummy)); nt.setup().include("dummy"); std::vector<pstring> devs; for (auto &e : nt.setup().factory()) devs.push_back(e->name()); std::sort(devs.begin(), devs.end(), [&](pstring &a, pstring &b) { return a < b; }); pout("// license:GPL-2.0+\n"); pout("// copyright-holders:Couriersud\n"); pout("/* ----------------------------------------------------------------------------\n"); pout(" * Automatically created file. DO NOT MODIFY.\n"); pout(" * ---------------------------------------------------------------------------*/\n"); pout("/*!\n"); pout(" * \\page devices Devices\n"); pout(" *\n"); pout(" * Below is a list of all the devices currently known to the system ...\n"); pout(" *\n"); for (auto &s : devs) pout(" * - \\subpage {1}\n", s); pout(" *\n"); for (auto &e : nt.setup().factory()) { pout("//! [{1} csynopsis]\n", e->name()); cmac(e.get()); pout("//! [{1} csynopsis]\n", e->name()); pout("//! [{1} synopsis]\n", e->name()); mac(e.get()); pout("//! [{1} synopsis]\n", e->name()); } nt.stop(); }
void tool_app_t::create_header() { netlist_tool_t nt(*this, "netlist"); nt.init(); nt.log().verbose.set_enabled(false); nt.log().warning.set_enabled(false); nt.setup().register_source(plib::make_unique_base<netlist::source_t, netlist::source_proc_t>(nt.setup(), "dummy", &netlist_dummy)); nt.setup().include("dummy"); pout("// license:GPL-2.0+\n"); pout("// copyright-holders:Couriersud\n"); pout("#ifndef NLD_DEVINC_H\n"); pout("#define NLD_DEVINC_H\n"); pout("\n"); pout("#include \"nl_setup.h\"\n"); pout("#ifndef __PLIB_PREPROCESSOR__\n"); pout("\n"); pout("/* ----------------------------------------------------------------------------\n"); pout(" * Netlist Macros\n"); pout(" * ---------------------------------------------------------------------------*/\n"); pout("\n"); pstring last_source(""); for (auto &e : nt.setup().factory()) { if (last_source != e->sourcefile()) { last_source = e->sourcefile(); pout("{1}\n", pstring("// ").rpad("-", 72)); pout("{1}{2}\n", pstring("// Source: "), e->sourcefile().replace_all("../", "")); pout("{1}\n", pstring("// ").rpad("-", 72)); } cmac(e.get()); } pout("#endif // __PLIB_PREPROCESSOR__\n"); pout("#endif\n"); nt.stop(); }
void cmd_mac(char *conf, char *key) { printf("# MAC information\n"); einittoken_t *token; token = load_einittoken(conf); unsigned char device_pubkey[DEVICE_KEY_LENGTH]; unsigned char device_seckey[DEVICE_KEY_LENGTH]; unsigned char launch_key[DEVICE_KEY_LENGTH]; unsigned char mac[MAC_SIZE]; //do we need this? //rsa_context *ctx; char *launch_key_str; char *mac_str; load_rsa_keys(key, device_pubkey, device_seckey, DEVICE_KEY_LENGTH_BITS); { char *pubkey_str = fmt_bytes(device_pubkey, DEVICE_KEY_LENGTH); char *seckey_str = fmt_bytes(device_seckey, DEVICE_KEY_LENGTH); printf("DEVICE PUBKEY : %s\n", pubkey_str); printf("DEVICE SECKEY : %s\n", seckey_str); free(pubkey_str); free(seckey_str); } generate_launch_key(device_seckey, launch_key); cmac(launch_key, (unsigned char *)token, 192, mac); launch_key_str = fmt_bytes(launch_key, DEVICE_KEY_LENGTH); mac_str = fmt_bytes(mac, MAC_SIZE); printf("LAUNCH LEY : %s\n", launch_key_str); printf("MAC : %s\n", mac_str); memcpy(token->mac, mac, 16); char *msg = dbg_dump_einittoken(token); printf("# EINITTOKEN START\n"); printf("%s\n", msg); printf("# EINITTOKEN END\n"); }