diff options
author | Karsten Heimrich <karsten.heimrich@qt.io> | 2018-12-12 16:06:47 +0100 |
---|---|---|
committer | Karsten Heimrich <karsten.heimrich@qt.io> | 2019-01-30 13:24:23 +0000 |
commit | 8c40f720d089a2c66e8378bbc66fd953157bb00d (patch) | |
tree | 71426f02a134dc35f4b79e2f57684d4aa1db0aaa /tests | |
parent | 7c713ff5deabe185cea9cc9a1315527cbaf2a68f (diff) |
AN159: Introduce secure user ID enumeration + documentation
Change-Id: I9c77c987a6adc80d3ce7372e282ad783b2842619
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qknxcryptographicengine/tst_qknxcryptographicengine.cpp | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/tests/auto/qknxcryptographicengine/tst_qknxcryptographicengine.cpp b/tests/auto/qknxcryptographicengine/tst_qknxcryptographicengine.cpp index b242e5a..80b85a1 100644 --- a/tests/auto/qknxcryptographicengine/tst_qknxcryptographicengine.cpp +++ b/tests/auto/qknxcryptographicengine/tst_qknxcryptographicengine.cpp @@ -231,10 +231,9 @@ private slots: QCOMPARE(passwordHash, QKnxByteArray::fromHex("03fcedb66660251ec81a1a716901696a")); knxNetIpSecureHeader = QKnxNetIpFrameHeader::fromBytes(QKnxByteArray::fromHex("061009530018")); - quint16 userId = 0x0001; mac = QKnxCryptographicEngine::calculateMessageAuthenticationCode(passwordHash, - knxNetIpSecureHeader, userId, XOR_X_Y); + knxNetIpSecureHeader, QKnxNetIp::SecureUserId::Management, XOR_X_Y); QCOMPARE(mac, QKnxByteArray::fromHex("741669f5e32bff6fa2edf51c52d4bd8f")); encMac = QKnxCryptographicEngine::encryptMessageAuthenticationCode(passwordHash, mac); @@ -249,7 +248,7 @@ private slots: knxNetIpSecureHeader = QKnxNetIpFrameHeader::fromBytes(QKnxByteArray::fromHex("06100950003e")); auto frame = QKnxNetIpSessionAuthenticateProxy::builder() - .setUserId(userId) + .setUserId(QKnxNetIp::SecureUserId::Management) .setMessageAuthenticationCode(encMac) .create(); @@ -362,7 +361,7 @@ private slots: void testSecureWrapperFrame() { auto sessionAuthenticate = QKnxNetIpSessionAuthenticateProxy::builder() - .setUserId(0x0001) + .setUserId(QKnxNetIp::SecureUserId::Management) .setMessageAuthenticationCode(QKnxByteArray::fromHex("1f1d59ea9f12a152e5d9727f08462cde")) .create(); @@ -474,35 +473,30 @@ private slots: auto serverPublicKey = QKnxCurve25519PublicKey::fromBytes(QKnxByteArray::fromHex("bdf09990" "9923143ef0a5de0b3be3687bc5bd3cf5f9e6f901699cd870ec1ff824")); - quint16 userId = 0x0001; const QByteArray password { "secret" }; auto mac = QKnxByteArray::fromHex("1f1d59ea9f12a152e5d9727f08462cde"); auto sessionAuth = QKnxNetIpSessionAuthenticateProxy::builder() - .setUserId(userId) + .setUserId(QKnxNetIp::SecureUserId::Management) .setMessageAuthenticationCode(mac) .create(); QKnxNetIpSessionAuthenticateProxy proxy(sessionAuth); QCOMPARE(proxy.isValid(), true); - QCOMPARE(proxy.userId(), userId); + QCOMPARE(proxy.userId(), QKnxNetIp::SecureUserId::Management); QCOMPARE(proxy.messageAuthenticationCode(), mac); auto sessionAuth2 = QKnxNetIpSessionAuthenticateProxy::secureBuilder() - .setUserId(userId) + .setUserId(QKnxNetIp::SecureUserId::Management) .create(password, clientPublicKey.bytes(), serverPublicKey.bytes()); QKnxNetIpSessionAuthenticateProxy proxy2(sessionAuth2); QCOMPARE(proxy2.isValid(), true); - QCOMPARE(proxy2.userId(), userId); + QCOMPARE(proxy2.userId(), QKnxNetIp::SecureUserId::Management); QCOMPARE(proxy2.messageAuthenticationCode(), mac); } - - void cleanupTestCase() - {} }; - QTEST_APPLESS_MAIN(tst_qknxcryptographicengine) #include "tst_qknxcryptographicengine.moc" |