Skip to content

Commit

Permalink
Add CtapParseClientPin GetPinToken test
Browse files Browse the repository at this point in the history
  • Loading branch information
pokusew committed Jan 15, 2025
1 parent 6809ec3 commit dcf7fc2
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/src/ctap_parse_client_pin_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,34 @@ TEST(CtapParseClientPin, GetKeyAgreement) {
EXPECT_EQ(cp.rpIdPresent, false);
}

TEST(CtapParseClientPin, GetPinToken) {
const uint8_t request[] = "\xa4\x01\x01\x02\x05\x03\xa5\x01\x02\x03\x38\x18\x20\x01\x21\x58" \
"\x20\x39\x09\xe3\x89\xb5\x45\x66\x2b\xfb\xee\x67\x90\x5d\xd4\x32" \
"\xe7\x01\xa1\xc1\x46\xac\xab\x6a\x5b\x42\x0b\x75\xdd\x35\x10\x5e" \
"\x5d\x22\x58\x20\xf0\xb7\xcb\x3e\xbf\x62\x59\x4b\x9e\x8d\x98\x70" \
"\xb1\xa9\x15\x4a\xb5\x0c\xdd\x2c\x1e\x6e\x86\x14\x90\xb8\x2d\x92" \
"\xf0\x9e\x19\x84\x06\x50\x4d\x72\x7d\x4d\xc0\x14\x04\xd7\xe9\x59" \
"\x0d\xe7\xf0\x4d\x89\xca";
CTAP_clientPIN cp;
uint8_t status;
status = ctap_parse_client_pin(request, sizeof(request), &cp);
ASSERT_EQ(status, CTAP2_OK);
EXPECT_EQ(cp.pinUvAuthProtocol, 1);
EXPECT_EQ(cp.subCommand, CTAP_clientPIN_subCmd_getPinToken);
EXPECT_EQ(cp.keyAgreementPresent, true);
EXPECT_EQ(cp.keyAgreement.kty, 2);
EXPECT_EQ(cp.keyAgreement.crv, 1);
const uint8_t x[] = "\x39\x09\xe3\x89\xb5\x45\x66\x2b\xfb\xee\x67\x90\x5d\xd4\x32\xe7" \
"\x01\xa1\xc1\x46\xac\xab\x6a\x5b\x42\x0b\x75\xdd\x35\x10\x5e\x5d";
const uint8_t y[] = "\xf0\xb7\xcb\x3e\xbf\x62\x59\x4b\x9e\x8d\x98\x70\xb1\xa9\x15\x4a" \
"\xb5\x0c\xdd\x2c\x1e\x6e\x86\x14\x90\xb8\x2d\x92\xf0\x9e\x19\x84";
EXPECT_EQ(cp.keyAgreement.pubkey.x, x);
EXPECT_EQ(cp.keyAgreement.pubkey.y, y);
EXPECT_EQ(cp.pinUvAuthParamPresent, false);
EXPECT_EQ(cp.newPinEncSize, 0);
EXPECT_EQ(cp.pinHashEncPresent, true);
EXPECT_EQ(cp.permissionsPresent, false);
EXPECT_EQ(cp.rpIdPresent, false);
}

} // namespace

0 comments on commit dcf7fc2

Please sign in to comment.