// Stop the scan from the context of the main loop to avoid race conditions.
// g_main_context_invoke_full() cannot be used here, because we need to defer the callback
// to be run INSIDE g_main_loop_run() in StartLEScanAndAwaitStop(), otherwise
- // g_main_loop_quit() will succeed, but the yet unstarted g_main_loop_run() will be left
+ // g_main_loop_quit() will succeed, but the not yet started g_main_loop_run() will be left
// uninterrupted indefinitely waiting for g_main_loop_quit() that already happened.
m_scanCancellationCallbackId = g_timeout_add_full(
G_PRIORITY_HIGH,
* @brief Stop Bluetooth LE scan. May be called from other threads.
*
* @details Cancels current or the next LE scan. May be called without holding any mutex. Due to
- * the possible race conditions, the design decison was made to cancel the next scan if
- * there is no scan in progress. Also note that if for the currenty executed scan is too late to
- * be cancelled (e.g. the scan has just ended) this function will report success, but do
+ * the possible race conditions, the design decision was made to cancel the next scan if
+ * there is no scan in progress. Also note that if for the currently executed scan is too late
+ * to be cancelled (e.g. the scan has just ended) this function will report success, but do
* nothing.
*/
virtual void StopLEScan() = 0;
struct InitialHandshakeMessage {
CryptoBuffer msg;
- Crypto::X9_62_P_256_Key ephermalKey;
+ Crypto::X9_62_P_256_Key ephemeralKey;
Crypto::Noise::SymmetricState noise;
};
res.noise.MixKeyAndHash(psk);
- auto exportedEphermalKeyPublic = res.ephermalKey.ExportPublicKey(false);
- res.noise.MixHash(exportedEphermalKeyPublic);
- res.noise.MixKey(exportedEphermalKeyPublic);
+ auto exportedEphemeralKeyPublic = res.ephemeralKey.ExportPublicKey(false);
+ res.noise.MixHash(exportedEphemeralKeyPublic);
+ res.noise.MixKey(exportedEphemeralKeyPublic);
- res.msg = std::move(exportedEphermalKeyPublic);
+ res.msg = std::move(exportedEphemeralKeyPublic);
auto ciphertext = res.noise.EncryptAndHash({});
res.msg.insert(res.msg.end(), ciphertext.begin(), ciphertext.end());
return res;
};
ProcessedHandshakeResponse processHandshakeResponse(const CryptoBuffer &peerHandshakeMessage,
- const Crypto::X9_62_P_256_Key &ephermalKey,
+ const Crypto::X9_62_P_256_Key &ephemeralKey,
const Crypto::X9_62_P_256_Key &privKey,
Crypto::Noise::SymmetricState &&noise)
{
noise.MixKey(peerPointBytes);
auto peerPublicKey = Crypto::X9_62_P_256_Key::ImportPublicKey(peerPointBytes);
- noise.MixKey(Crypto::deriveECDHSharedSecret(ephermalKey, peerPublicKey));
+ noise.MixKey(Crypto::deriveECDHSharedSecret(ephemeralKey, peerPublicKey));
noise.MixKey(Crypto::deriveECDHSharedSecret(privKey, peerPublicKey));
auto plaintext = noise.DecryptAndHash(ciphertext);
// Handshake
auto psk = DeriveKey(qrSecret, decryptedBleAdvert, KeyPurpose::PSK, PSK_LEN);
- auto [msg, ephermalKey, noise] = initialHandshakeMessage(psk, identityKey);
+ auto [msg, ephemeralKey, noise] = initialHandshakeMessage(psk, identityKey);
m_tunnel->WriteBinary(msg); // Should throw if Cancel is already called.
// process response
auto [splitRes, handshakeHash] =
- processHandshakeResponse(response, ephermalKey, identityKey, std::move(noise));
+ processHandshakeResponse(response, ephemeralKey, identityKey, std::move(noise));
LogDebug("handshake hash: " << LowercaseHexStringOf(handshakeHash));
auto guard = std::unique_lock{m_lock};
namespace {
enum class StatusCode : uint8_t {
- CTAP1_ERR_SUCCES = 0x00,
+ CTAP1_ERR_SUCCESS = 0x00,
CTAP2_OK = 0x00, // Indicates successful response.
CTAP1_ERR_INVALID_COMMAND = 0x01, // The command is not a valid CTAP command.
CTAP1_ERR_INVALID_PARAMETER = 0x02, // The command included an invalid parameter.
// Get Info response
constexpr int64_t KEY_GI_BUFFER = 0x01;
constexpr int64_t KEY_GI_RSP_VERSIONS = 0x01;
-constexpr int64_t KEY_GI_RSP_EXTENSTIONS = 0x02;
+constexpr int64_t KEY_GI_RSP_EXTENSIONS = 0x02;
constexpr int64_t KEY_GI_RSP_AAGUID = 0x03;
constexpr int64_t KEY_GI_RSP_OPTIONS = 0x04;
constexpr int64_t KEY_GI_RSP_MAX_MSG_SIZE = 0x05;
m_versions.emplace_back(versionArray.GetTextString());
}
- if (auto extensionsArray = getInfoMap.EnterArrayAt(KEY_GI_RSP_EXTENSTIONS)) {
+ if (auto extensionsArray = getInfoMap.EnterArrayAt(KEY_GI_RSP_EXTENSIONS)) {
for (size_t i = 0; i < extensionsArray->Length(); i++)
m_extensions.emplace_back(extensionsArray->GetTextString());
}
if (err == BT_ERROR_CANCELLED)
THROW_CANCELLED();
if (err != BT_ERROR_NONE)
- THROW_UNKNOWN("Awating BLE advert failed with code = " << err);
+ THROW_UNKNOWN("Awaiting BLE advert failed with code = " << err);
UpdateStateAndCheckForCancel(State::DOING_HANDSHAKE);
auto encryptedTunnel =
void Process(
const wauthn_client_data_s *client_data,
Request request,
- // If null, default implementations will be set in the function body to control excepitions.
+ // If null, default implementations will be set in the function body to control exceptions.
std::unique_ptr<IQrCodeShower> qrCodeShower = nullptr,
IBtAdvertScannerUPtr btAdvertScanner = nullptr,
std::unique_ptr<IHandshake> handshake = nullptr)
wauthn_const_buffer_s attestationObject;
wauthn_const_buffer_s subjectPubkeyInfo;
wauthn_authenticator_attestation_response_s response;
- wauthn_pubkey_credential_attestaion_s ca;
+ wauthn_pubkey_credential_attestation_s ca;
} val{};
return val;
} else {
auto proto = lws_get_protocol(wsi);
if (proto == nullptr) {
- // Normally it happes 2 times during the connection establishment.
+ // Normally it happens 2 times during the connection establishment.
TRY_LOG_DEBUG("Protocol is NULL");
return 0;
}
};
CallbackInfo<const char *, void *> qrCallback;
-CallbackInfo<const wauthn_pubkey_credential_attestaion_s *, wauthn_error_e, void *> mcCallback;
+CallbackInfo<const wauthn_pubkey_credential_attestation_s *, wauthn_error_e, void *> mcCallback;
CallbackInfo<const wauthn_pubkey_credential_assertion_s *, wauthn_error_e, void *> gaCallback;
void QrCallback(const char *qr_contents, void *user_data)
throw Exception::InvalidParam();
}
-void McCallback(const wauthn_pubkey_credential_attestaion_s *pubkey_cred,
+void McCallback(const wauthn_pubkey_credential_attestation_s *pubkey_cred,
wauthn_error_e result,
void *user_data)
{
memset(&mcOptions, 0, sizeof mcOptions);
memset(&gaOptions, 0, sizeof gaOptions);
- auto mcInvalid = invalidParamChecker<wauthn_pubkey_credential_attestaion_s>(&userData);
+ auto mcInvalid = invalidParamChecker<wauthn_pubkey_credential_attestation_s>(&userData);
auto gaInvalid = invalidParamChecker<wauthn_pubkey_credential_assertion_s>(&userData);
mocked_wah_make_credential(&client, &mcOptions, nullptr);
return &userData == user_data;
};
- auto mcInvalid = invalidParamChecker<wauthn_pubkey_credential_attestaion_s>(&userData);
+ auto mcInvalid = invalidParamChecker<wauthn_pubkey_credential_attestation_s>(&userData);
auto gaInvalid = invalidParamChecker<wauthn_pubkey_credential_assertion_s>(&userData);
qrCallback.SetArgsChecker(qrCheck);
ret.tm_min = date.minute;
ret.tm_sec = date.second;
ret.tm_mday = date.day;
- ret.tm_mon = date.month - 1; // month since january
+ ret.tm_mon = date.month - 1; // month since January
ret.tm_year = date.year - 1900; // This is year-1900
return ret;
TEST(NoiseTest, KNpsk0_P256_AESGCM_SHA256_initial_state)
{
SymmetricState noise{SymmetricState::HandshakeKind::KNpsk0_P256_AESGCM_SHA256};
- // Values come from an alternative implemantation of Dong Sun Lee
+ // Values come from an alternative implementation of Dong Sun Lee
EXPECT_EQ(noise.GetHandshakeHash(),
(CryptoBuffer{0x4e, 0x6f, 0x69, 0x73, 0x65, 0x5f, 0x4b, 0x4e, 0x70, 0x73, 0x6b,
0x30, 0x5f, 0x50, 0x32, 0x35, 0x36, 0x5f, 0x41, 0x45, 0x53, 0x47,
TEST(NoiseTest, NKpsk0_P256_AESGCM_SHA256_initial_state)
{
SymmetricState noise{SymmetricState::HandshakeKind::NKpsk0_P256_AESGCM_SHA256};
- // Values come from an alternative implemantation of Dong Sun Lee
+ // Values come from an alternative implementation of Dong Sun Lee
EXPECT_EQ(noise.GetHandshakeHash(),
(CryptoBuffer{0x4e, 0x6f, 0x69, 0x73, 0x65, 0x5f, 0x4e, 0x4b, 0x70, 0x73, 0x6b,
0x30, 0x5f, 0x50, 0x32, 0x35, 0x36, 0x5f, 0x41, 0x45, 0x53, 0x47,
{
SymmetricState noise{SymmetricState::HandshakeKind::KNpsk0_P256_AESGCM_SHA256};
noise.MixHash({'a', 'b', 'c'});
- // Values come from an alternative implemantation of Dong Sun Lee
+ // Values come from an alternative implementation of Dong Sun Lee
EXPECT_EQ(noise.GetHandshakeHash(),
(CryptoBuffer{0xe0, 0x92, 0xb5, 0x62, 0x6c, 0x14, 0xf8, 0x3f, 0x8d, 0x28, 0x9f,
0x2c, 0x37, 0x61, 0xba, 0x15, 0xf9, 0x68, 0xb0, 0x7e, 0x40, 0x80,
{
SymmetricState noise{SymmetricState::HandshakeKind::NKpsk0_P256_AESGCM_SHA256};
noise.MixHash({'a', 'b', 'c'});
- // Values come from an alternative implemantation of Dong Sun Lee
+ // Values come from an alternative implementation of Dong Sun Lee
EXPECT_EQ(noise.GetHandshakeHash(),
(CryptoBuffer{0xc3, 0xec, 0x18, 0xe6, 0x5f, 0x80, 0xcc, 0xe1, 0x43, 0x86, 0xab,
0x76, 0x5d, 0xbc, 0x2f, 0xfc, 0x82, 0xc5, 0x94, 0x68, 0x9a, 0x45,
{
SymmetricState noise{SymmetricState::HandshakeKind::KNpsk0_P256_AESGCM_SHA256};
noise.MixKey({'a', 'b', 'c'});
- // Values come from an alternative implemantation of Dong Sun Lee
+ // Values come from an alternative implementation of Dong Sun Lee
EXPECT_EQ(noise.GetHandshakeHash(),
(CryptoBuffer{0x4e, 0x6f, 0x69, 0x73, 0x65, 0x5f, 0x4b, 0x4e, 0x70, 0x73, 0x6b,
0x30, 0x5f, 0x50, 0x32, 0x35, 0x36, 0x5f, 0x41, 0x45, 0x53, 0x47,
{
SymmetricState noise{SymmetricState::HandshakeKind::NKpsk0_P256_AESGCM_SHA256};
noise.MixKey({'a', 'b', 'c'});
- // Values come from an alternative implemantation of Dong Sun Lee
+ // Values come from an alternative implementation of Dong Sun Lee
EXPECT_EQ(noise.GetHandshakeHash(),
(CryptoBuffer{0x4e, 0x6f, 0x69, 0x73, 0x65, 0x5f, 0x4e, 0x4b, 0x70, 0x73, 0x6b,
0x30, 0x5f, 0x50, 0x32, 0x35, 0x36, 0x5f, 0x41, 0x45, 0x53, 0x47,
{
SymmetricState noise{SymmetricState::HandshakeKind::KNpsk0_P256_AESGCM_SHA256};
noise.MixKeyAndHash({'a', 'b', 'c'});
- // Values come from an alternative implemantation of Dong Sun Lee
+ // Values come from an alternative implementation of Dong Sun Lee
EXPECT_EQ(noise.GetHandshakeHash(),
(CryptoBuffer{0x3a, 0xf7, 0x39, 0xd6, 0xa2, 0xf4, 0x87, 0x05, 0x3c, 0xf7, 0x20,
0x30, 0x91, 0x02, 0x85, 0xdf, 0x70, 0x33, 0x67, 0x53, 0xcf, 0xf1,
{
SymmetricState noise{SymmetricState::HandshakeKind::NKpsk0_P256_AESGCM_SHA256};
noise.MixKeyAndHash({'a', 'b', 'c'});
- // Values come from an alternative implemantation of Dong Sun Lee
+ // Values come from an alternative implementation of Dong Sun Lee
EXPECT_EQ(noise.GetHandshakeHash(),
(CryptoBuffer{0x3f, 0x46, 0xd8, 0x5d, 0x19, 0x65, 0x9a, 0x23, 0x62, 0x16, 0x48,
0xde, 0x8d, 0x47, 0x38, 0x06, 0x8b, 0x54, 0x6a, 0x7b, 0x99, 0x30,
auto plaintext1 = noise2.DecryptAndHash(ciphertext1);
EXPECT_EQ(msg1, plaintext1);
// clang-format off
- // Value comes from an alternative implemantation of Dong Sun Lee
+ // Value comes from an alternative implementation of Dong Sun Lee
EXPECT_EQ(ciphertext1,
(CryptoBuffer{
0x73, 0xa5, 0x70, 0x0a, 0x9f, 0x2b, 0x63, 0x8c, 0xa9, 0x68,
auto plaintext1 = noise2.DecryptAndHash(ciphertext1);
EXPECT_EQ(msg1, plaintext1);
// clang-format off
- // Value comes from an alternative implemantation of Dong Sun Lee
+ // Value comes from an alternative implementation of Dong Sun Lee
EXPECT_EQ(ciphertext1,
(CryptoBuffer{
0x6e, 0x5f, 0x52, 0xf4, 0xf8, 0x53, 0xa3, 0x6c, 0xb0, 0x27,
}
}
- // Test writing and writting padding.
+ // Test writing and writing padding.
for (int blocks = 0; blocks < 10; ++blocks) {
for (int i = blocks * 32; i < (blocks + 1) * 32; ++i) {
auto msg = Crypto::RandomBytes(i);
auto exportedPublicKeyLen = m_platformIdentityPublicKey.ExportPublicKey(false).size();
ASSERT_GE(msg.size(), exportedPublicKeyLen);
- auto platformEphermalPublicKeyBytes =
+ auto platformEphemeralPublicKeyBytes =
CryptoBuffer{msg.data(), msg.data() + exportedPublicKeyLen};
- noise.MixHash(platformEphermalPublicKeyBytes);
- noise.MixKey(platformEphermalPublicKeyBytes);
+ noise.MixHash(platformEphemeralPublicKeyBytes);
+ noise.MixKey(platformEphemeralPublicKeyBytes);
auto ciphertext = CryptoBuffer{msg.begin() + exportedPublicKeyLen, msg.end()};
auto plaintext = noise.DecryptAndHash(ciphertext);
ASSERT_TRUE(plaintext.empty());
// Prepare response
- auto platformEphermalPublicKey =
- Crypto::X9_62_P_256_Key::ImportPublicKey(platformEphermalPublicKeyBytes);
+ auto platformEphemeralPublicKey =
+ Crypto::X9_62_P_256_Key::ImportPublicKey(platformEphemeralPublicKeyBytes);
- auto response = m_authenticatorEphermalKey.ExportPublicKey(false);
+ auto response = m_authenticatorEphemeralKey.ExportPublicKey(false);
noise.MixHash(response);
noise.MixKey(response);
- noise.MixKey(
- Crypto::deriveECDHSharedSecret(m_authenticatorEphermalKey, platformEphermalPublicKey));
- noise.MixKey(Crypto::deriveECDHSharedSecret(m_authenticatorEphermalKey,
+ noise.MixKey(Crypto::deriveECDHSharedSecret(m_authenticatorEphemeralKey,
+ platformEphemeralPublicKey));
+ noise.MixKey(Crypto::deriveECDHSharedSecret(m_authenticatorEphemeralKey,
m_platformIdentityPublicKey));
ciphertext = noise.EncryptAndHash({});
const CryptoBuffer &m_decryptedBleAdvert;
const CryptoBuffer &m_getInfoMsg;
- Crypto::X9_62_P_256_Key m_authenticatorEphermalKey = Crypto::X9_62_P_256_Key::Create();
+ Crypto::X9_62_P_256_Key m_authenticatorEphemeralKey = Crypto::X9_62_P_256_Key::Create();
CryptoBuffer m_handshakeResponse;
CryptoBuffer m_encryptedGetInfoMsg;
int m_readNo = 0;
Buffer ToBuffer(wauthn_const_buffer_s buff) { return Buffer{buff.data, buff.data + buff.size}; }
-void MCCallback(const wauthn_pubkey_credential_attestaion_s *pubkey_cred,
+void MCCallback(const wauthn_pubkey_credential_attestation_s *pubkey_cred,
wauthn_error_e result,
void *data)
{
}
});
- size_t sucessfullCancellations = 0;
+ size_t successfulCancellations = 0;
auto lock = std::unique_lock{mutex};
for (size_t i = 0; i < reps; ++i) {
auto transactionObj = maker();
} catch (const Exception::Cancelled &) {
// This may happen if cancellation happens before or during the transaction and is
// expected.
- ++sucessfullCancellations;
+ ++successfulCancellations;
} catch (const std::exception &e) {
ADD_FAILURE() << "Unexpected exception: " << e.what();
} catch (...) {
cv.notify_all();
canceller.join();
- std::cerr << "sucessfullCancellations: " << sucessfullCancellations << " of " << reps
+ std::cerr << "successfulCancellations: " << successfulCancellations << " of " << reps
<< std::endl;
// Reasonable number of cancellations has to happen, otherwise this code is wrong.
- EXPECT_GE(sucessfullCancellations, minExpectedCancellationsNum);
+ EXPECT_GE(successfulCancellations, minExpectedCancellationsNum);
}
assert(m_testState.m_cancelCalledOn == CancelCalledOn::NONE);
m_testState.m_transaction->Cancel();
if (hasCancel) {
- // ITransaction::Cancel() should call apropriate Cancel() method immediately.
+ // ITransaction::Cancel() should call appropriate Cancel() method immediately.
assert(m_testState.m_cancelCalledOn != CancelCalledOn::NONE);
}
return true;
const std::string &TestUrl();
struct MockedLws;
-struct MocketContext;
class MockedSockets : public IWebsockets {
protected:
private:
/*
* Default setting for tests running on emulator and websocket_server.py server running on the
- * host. Can be overriden by using "--server=" argument.
+ * host. Can be overridden by using "--server=" argument.
*/
Config() : m_testServer("10.0.2.2:7890") {}
{
struct UnsafeSockets2 : public UnsafeSockets {
public:
- void CheckPath(const std::string &path) {
- EXPECT_EQ(m_path, path);
- }
+ void CheckPath(const std::string &path) { EXPECT_EQ(m_path, path); }
+
protected:
Lws *ClientConnectViaInfo(const struct lws_client_connect_info &info) noexcept override
{