2018-11-17 22:19:09 +08:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Copyright (C) 2018 Merlok
|
|
|
|
//
|
|
|
|
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
|
|
|
// at your option, any later version. See the LICENSE.txt file for the text of
|
|
|
|
// the license.
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// FIDO2 authenticators core data and commands
|
|
|
|
// https://fidoalliance.org/specs/fido-v2.0-id-20180227/fido-client-to-authenticator-protocol-v2.0-id-20180227.html
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
#ifndef __FIDOCORE_H__
|
|
|
|
#define __FIDOCORE_H__
|
|
|
|
|
2019-08-08 22:57:33 +08:00
|
|
|
#include "common.h"
|
|
|
|
|
2018-11-22 01:46:57 +08:00
|
|
|
#include <jansson.h>
|
2019-08-08 22:57:33 +08:00
|
|
|
#include "emv/apduinfo.h" // sAPDU
|
2018-11-17 22:19:09 +08:00
|
|
|
|
2018-11-18 00:39:21 +08:00
|
|
|
typedef enum {
|
2019-03-10 06:35:06 +08:00
|
|
|
fido2CmdMakeCredential = 0x01,
|
|
|
|
fido2CmdGetAssertion = 0x02,
|
|
|
|
fido2CmdCancel = 0x03,
|
|
|
|
fido2CmdGetInfo = 0x04,
|
|
|
|
fido2CmdClientPIN = 0x06,
|
|
|
|
fido2CmdReset = 0x07,
|
|
|
|
fido2CmdGetNextAssertion = 0x08,
|
2019-03-09 15:59:13 +08:00
|
|
|
|
2019-03-10 06:35:06 +08:00
|
|
|
// another data
|
|
|
|
fido2COSEKey = 0xF0
|
2018-11-18 00:39:21 +08:00
|
|
|
} fido2Commands;
|
2018-11-17 22:19:09 +08:00
|
|
|
|
2018-11-18 00:39:21 +08:00
|
|
|
typedef enum {
|
2019-03-10 06:35:06 +08:00
|
|
|
ptQuery,
|
|
|
|
ptResponse,
|
2018-11-18 00:39:21 +08:00
|
|
|
} fido2PacketType;
|
2018-11-17 22:19:09 +08:00
|
|
|
|
2019-04-06 06:52:55 +08:00
|
|
|
int FIDOSelect(bool ActivateField, bool LeaveFieldON, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw);
|
|
|
|
int FIDOExchange(sAPDU apdu, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw);
|
|
|
|
int FIDORegister(uint8_t *params, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw);
|
|
|
|
int FIDOAuthentication(uint8_t *params, uint8_t paramslen, uint8_t controlb, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw);
|
|
|
|
int FIDO2GetInfo(uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw);
|
|
|
|
int FIDO2MakeCredential(uint8_t *params, uint8_t paramslen, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw);
|
|
|
|
int FIDO2GetAssertion(uint8_t *params, uint8_t paramslen, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw);
|
|
|
|
|
|
|
|
int FIDOCheckDERAndGetKey(uint8_t *der, size_t derLen, bool verbose, uint8_t *publicKey, size_t publicKeyMaxLen);
|
|
|
|
|
2019-04-10 16:21:42 +08:00
|
|
|
const char *fido2GetCmdMemberDescription(uint8_t cmdCode, bool isResponse, int memberNum);
|
|
|
|
const char *fido2GetCmdErrorDescription(uint8_t errorCode);
|
2019-04-06 06:52:55 +08:00
|
|
|
|
|
|
|
bool CheckrpIdHash(json_t *json, uint8_t *hash);
|
|
|
|
int FIDO2CreateMakeCredentionalReq(json_t *root, uint8_t *data, size_t maxdatalen, size_t *datalen);
|
|
|
|
int FIDO2MakeCredentionalParseRes(json_t *root, uint8_t *data, size_t dataLen, bool verbose, bool verbose2, bool showCBOR, bool showDERTLV);
|
|
|
|
int FIDO2CreateGetAssertionReq(json_t *root, uint8_t *data, size_t maxdatalen, size_t *datalen, bool createAllowList);
|
|
|
|
int FIDO2GetAssertionParseRes(json_t *root, uint8_t *data, size_t dataLen, bool verbose, bool verbose2, bool showCBOR);
|
2018-11-22 01:46:57 +08:00
|
|
|
|
2018-11-17 22:19:09 +08:00
|
|
|
#endif /* __FIDOCORE_H__ */
|