} wauthn_pubkey_cred_type_e;
/**
- * @brief The structure for binary buffer used in this CAPI.
+ * @brief The structure for const binary buffer used in this CAPI.
* @since_tizen 9.0
*/
-typedef struct __wauthn_buffer {
- unsigned char *data; /**< Byte array containing binary data */
+typedef struct __wauthn_const_buffer {
+ const unsigned char *data; /**< Byte array containing binary data */
size_t size; /**< The size of the binary data */
-} wauthn_buffer_s;
+} wauthn_const_buffer_s;
/**
* @brief The structure for response of wauthn_make_credential.
* @see #wauthn_cose_algorithm_e
*/
typedef struct __wauthn_authenticator_attestation_response {
- wauthn_buffer_s *client_data_json;
- wauthn_buffer_s *attestation_object; /**< The CBOR encoded Attestation Object to be returned to the RP */
+ wauthn_const_buffer_s *client_data_json;
+ wauthn_const_buffer_s *attestation_object; /**< The CBOR encoded Attestation Object to be returned to the RP */
unsigned int transports; /**< To represent multiple transports,
#wauthn_authenticator_transport_e can be ORed multiple times */
- wauthn_buffer_s *authenticator_data;
- wauthn_buffer_s *subject_pubkey_info;
+ wauthn_const_buffer_s *authenticator_data;
+ wauthn_const_buffer_s *subject_pubkey_info;
wauthn_cose_algorithm_e pubkey_alg;
} wauthn_authenticator_attestation_response_s;
* @see #wauthn_pubkey_credential_assertion_s
*/
typedef struct __wauthn_authenticator_assertion_response {
- wauthn_buffer_s *client_data_json;
- wauthn_buffer_s *authenticator_data;
- wauthn_buffer_s *signature;
- wauthn_buffer_s *user_handle;
- wauthn_buffer_s *attestation_object;
+ wauthn_const_buffer_s *client_data_json;
+ wauthn_const_buffer_s *authenticator_data;
+ wauthn_const_buffer_s *signature;
+ wauthn_const_buffer_s *user_handle;
+ wauthn_const_buffer_s *attestation_object;
} wauthn_authenticator_assertion_response_s;
/**
* @since_tizen 9.0
*/
typedef struct __wauthn_rp_entity {
- char *name; /**< The name of RP */
- char *id; /**< The RPID */
+ const char *name; /**< The name of RP */
+ const char *id; /**< The RPID */
} wauthn_rp_entity_s;
#define WEBAUTHN_MAX_USER_ID_LENGTH 64
* @since_tizen 9.0
*/
typedef struct __wauthn_user_entity {
- char *name;
- wauthn_buffer_s *id; /**< The ID of the user account. An ID is a byte sequence with a maximum size of
+ const char *name;
+ wauthn_const_buffer_s *id; /**< The ID of the user account. An ID is a byte sequence with a maximum size of
64 bytes, and is not meant to be displayed to the user */
- char *display_name; /**< A human-palatable name for the user account, intended only for display */
+ const char *display_name; /**< A human-palatable name for the user account, intended only for display */
} wauthn_user_entity_s;
*/
typedef struct __wauthn_pubkey_cred_descriptor {
wauthn_pubkey_cred_type_e type;
- wauthn_buffer_s *id;
+ wauthn_const_buffer_s *id;
unsigned int transports; /**< To represent multiple transports,
#wauthn_authenticator_transport_e can be ORed multiple times */
} wauthn_pubkey_cred_descriptor_s;
* @see #wauthn_authentication_ext_s
*/
typedef struct __wauthn_authentication_ext {
- wauthn_buffer_s *extension_id; /**<
+ wauthn_const_buffer_s *extension_id; /**<
Extension Identifier defined in the following registry.
https://www.iana.org/assignments/webauthn/webauthn.xhtml#webauthn-extension-ids. */
- wauthn_buffer_s *extension_value; /**<
+ wauthn_const_buffer_s *extension_value; /**<
Extension value */
} wauthn_authentication_ext_s;
* @since_tizen 9.0
*/
typedef struct __wauthn_hybrid_linked_data {
- wauthn_buffer_s *contact_id; // cbor:"1"
- wauthn_buffer_s *link_id; // cbor:"2"
- wauthn_buffer_s *link_secret; // cbor:"3"
- wauthn_buffer_s *authenticator_pubkey; // cbor:"4"
- wauthn_buffer_s *authenticator_name; // cbor:"5"
- wauthn_buffer_s *signature; // cbor:"6"
- wauthn_buffer_s *auth_pubkey;
- wauthn_buffer_s *tunnel_server_domain;
+ wauthn_const_buffer_s *contact_id; // cbor:"1"
+ wauthn_const_buffer_s *link_id; // cbor:"2"
+ wauthn_const_buffer_s *link_secret; // cbor:"3"
+ wauthn_const_buffer_s *authenticator_pubkey; // cbor:"4"
+ wauthn_const_buffer_s *authenticator_name; // cbor:"5"
+ wauthn_const_buffer_s *signature; // cbor:"6"
+ wauthn_const_buffer_s *auth_pubkey;
+ wauthn_const_buffer_s *tunnel_server_domain;
} wauthn_hybrid_linked_data_s;
/**
*/
typedef struct __wauthn_attestation_formats {
size_t size;
- wauthn_buffer_s *attestation_formats;
+ wauthn_const_buffer_s *attestation_formats;
} wauthn_attestation_formats_s;
/**
wauthn_user_entity_s *user; /**< This member contains names and
an identifier for the user account
performing the registration */
- wauthn_buffer_s *challenge; /**< This member specifies a challenge
- that the authenticator signs,
- along with other data, when producing
- an attestation object for the newly
- created credential */
+ wauthn_const_buffer_s *challenge; /**< This member specifies a challenge
+ that the authenticator signs,
+ along with other data, when producing
+ an attestation object for the newly
+ created credential */
wauthn_pubkey_cred_params_s *pubkey_cred_params; /**< This member lists the key types and
signature algorithms the Relying Party
supports, ordered from most preferred
* @see #wauthn_hybrid_linked_data_s
*/
typedef struct __wauthn_pubkey_cred_request_options {
- wauthn_buffer_s *challenge; /**< This member specifies a challenge that the authenticator signs,
- along with other data, when producing an authentication assertion */
+ wauthn_const_buffer_s *challenge; /**< This member specifies a challenge that the authenticator
+ signs, along with other data, when producing
+ an authentication assertion */
unsigned long timeout; /**< This member specifies a time, in milliseconds,
that the Relying Party is willing to wait for the call to complete.
The value, '0', means no timeout is set. (optional)*/
- char *rpId; /**< This member specifies the RP ID claimed by the Relying Party (optional)*/
+ const char *rpId; /**< This member specifies the RP ID claimed by the Relying Party (optional)*/
wauthn_pubkey_cred_descriptors_s *allow_credentials; /**< This member is used by the client
to find authenticators eligible for this
authentication ceremony (optional)*/
* @see #wauthn_hybrid_linked_data_s
*/
typedef struct __wauthn_pubkey_credential_attestaion {
- wauthn_buffer_s *id;
+ wauthn_const_buffer_s *id;
wauthn_pubkey_cred_type_e type;
- wauthn_buffer_s *rawId;
+ wauthn_const_buffer_s *rawId;
wauthn_authenticator_attestation_response_s *response;
wauthn_authenticator_attachment_e authenticator_attachment;
wauthn_authentication_exts_s *extensions;
bool is_conditional_mediation_available;
- wauthn_buffer_s *json_data;
+ wauthn_const_buffer_s *json_data;
wauthn_hybrid_linked_data_s *linked_device;
} wauthn_pubkey_credential_attestaion_s;
* @see #wauthn_hybrid_linked_data_s
*/
typedef struct __wauthn_pubkey_credential_assertion {
- wauthn_buffer_s *id;
+ wauthn_const_buffer_s *id;
wauthn_pubkey_cred_type_e type;
- wauthn_buffer_s *rawId;
+ wauthn_const_buffer_s *rawId;
wauthn_authenticator_assertion_response_s *response;
wauthn_authenticator_attachment_e authenticator_attachment;
wauthn_authentication_exts_s *extensions;
bool is_conditional_mediation_available;
- wauthn_buffer_s *json_data;
+ wauthn_const_buffer_s *json_data;
wauthn_hybrid_linked_data_s *linked_device;
} wauthn_pubkey_credential_assertion_s;
* @see #wauthn_hash_algorithm_e
*/
typedef struct __wauthn_client_data {
- wauthn_buffer_s *client_data_json;// UTF-8 encoded JSON serialization of the client data
+ wauthn_const_buffer_s *client_data_json;// UTF-8 encoded JSON serialization of the client data
wauthn_hash_algorithm_e hash_alg; // Hash algorithm used to hash the client_data_json field
} wauthn_client_data_s;
if (data == nullptr)
ThrowMsg(SerializationException::InvalidStreamData, "nullptr data.");
size_t length = 0;
- deserialize(stream, reinterpret_cast<unsigned char**>(data), &length);
+ deserialize(stream, const_cast<const unsigned char**>(reinterpret_cast<unsigned char**>(data)), &length);
if (length != 0 && length != struct_size)
ThrowMsg(SerializationException::InvalidStreamData, "Invalid length: length=" << length
<< ", struct_size=" << struct_size);
if (length != 0)
stream.Write(length, data);
}
-void WAuthnCtypeSerializer::deserialize(IStream& stream, unsigned char** data, size_t* length) {
+void WAuthnCtypeSerializer::deserialize(IStream& stream, const unsigned char** data, size_t* length) {
if (data == nullptr || length == nullptr)
ThrowMsg(SerializationException::InvalidStreamData,
"nullptr data or length. data=" << data << ", length=" << length);
size_t length = (data) ? strlen(data) + 1 : 0;
serialize(stream, reinterpret_cast<const unsigned char*>(data), length);
}
-void WAuthnCtypeSerializer::deserialize(IStream& stream, char** data) {
+void WAuthnCtypeSerializer::deserialize(IStream& stream, const char** data) {
if (data == nullptr)
ThrowMsg(SerializationException::InvalidStreamData, "nullptr data");
size_t length;
- deserialize(stream, reinterpret_cast<unsigned char**>(data), &length);
+ deserialize(stream, reinterpret_cast<const unsigned char**>(data), &length);
if (*data != nullptr && length != strlen(*data) + 1)
ThrowMsg(SerializationException::InvalidStreamData,
"Invalid length of cstring (not expected one): "
__checkValidity(*data);
}
-// For wauthn_buffer_s
-void __checkValidity(const wauthn_buffer_s* data) {
+// For wauthn_const_buffer_s
+void __checkValidity(const wauthn_const_buffer_s* data) {
if (data == nullptr)
return;
if (data->data == nullptr && data->size != 0)
ThrowMsg(SerializationException::InvalidStreamData,
"Empty data with size=" << data->size);
}
-void WAuthnCtypeSerializer::serialize(IStream& stream, const wauthn_buffer_s* data) {
+void WAuthnCtypeSerializer::serialize(IStream& stream, const wauthn_const_buffer_s* data) {
__checkValidity(data);
// Seriallize struct itself
- serializeStructBody(stream, reinterpret_cast<const void *>(data), sizeof(wauthn_buffer_s));
+ serializeStructBody(stream, reinterpret_cast<const void *>(data), sizeof(wauthn_const_buffer_s));
if (data == nullptr)
return;
// Seriallize the contents of struct's pointers
serialize(stream, data->data, data->size);
}
-void WAuthnCtypeSerializer::deserialize(IStream& stream, wauthn_buffer_s** data) {
+void WAuthnCtypeSerializer::deserialize(IStream& stream, wauthn_const_buffer_s** data) {
// Deseriallize struct itself
- deserializeStructBody(stream, reinterpret_cast<void **>(data), sizeof(wauthn_buffer_s));
+ deserializeStructBody(stream, reinterpret_cast<void**>(data), sizeof(wauthn_const_buffer_s));
__checkValidity(*data);
if (*data == nullptr)
return;
ThrowMsg(SerializationException::InvalidStreamData,
"Inconsistent pointer & length: pointer=" << data->attestation_formats << ", size=" << data->size);
}
-void __serializePointerContents(IStream& stream, const wauthn_buffer_s* data) {
+void __serializePointerContents(IStream& stream, const wauthn_const_buffer_s* data) {
WAuthnCtypeSerializer::serialize(stream, data);
}
-void __deserializePointerContents(IStream& stream, wauthn_buffer_s* data) {
+void __deserializePointerContents(IStream& stream, wauthn_const_buffer_s* data) {
WAuthnCtypeSerializer::deserialize(stream, &data);
}
void WAuthnCtypeSerializer::serialize(IStream& stream, const wauthn_attestation_formats_s* data) {
return;
// Serialize array
for(size_t i=0; i < data->size; i++ )
- __serializeArrayItem(stream, reinterpret_cast<const void *>(data->attestation_formats + i), sizeof(wauthn_buffer_s));
+ __serializeArrayItem(stream, reinterpret_cast<const void *>(data->attestation_formats + i), sizeof(wauthn_const_buffer_s));
// Seriallize the contents of pointers in struct array
for(size_t i=0; i < data->size; i++ )
__serializePointerContents(stream, data->attestation_formats + i);
}
__checkValidity(*data);
// Deseriallize array
- wauthn_buffer_s* tmp;
+ wauthn_const_buffer_s* tmp;
for(size_t i=0; i < (*data)->size; i++ ) {
- __deserializeArrayItem(stream, reinterpret_cast<void **>(&tmp), sizeof(wauthn_buffer_s));
+ __deserializeArrayItem(stream, reinterpret_cast<void **>(&tmp), sizeof(wauthn_const_buffer_s));
if (i == 0) // set pointer to the first parameter
(*data)->attestation_formats = tmp;
}
public:
static void serialize(IStream& stream, const unsigned char* data, size_t length);
- static void deserialize(IStream& stream, unsigned char** data, size_t* length);
+ static void deserialize(IStream& stream, const unsigned char** data, size_t* length);
static void serialize(IStream& stream, const char* data);
- static void deserialize(IStream& stream, char** data);
+ static void deserialize(IStream& stream, const char** data);
static void serialize(IStream& stream, const wauthn_error_e data);
static void deserialize(IStream& stream, wauthn_error_e* data);
- static void serialize(IStream& stream, const wauthn_buffer_s* data);
- static void deserialize(IStream& stream, wauthn_buffer_s** data);
+ static void serialize(IStream& stream, const wauthn_const_buffer_s* data);
+ static void deserialize(IStream& stream, wauthn_const_buffer_s** data);
static void serialize(IStream& stream, const wauthn_authenticator_attestation_response_s* data);
static void deserialize(IStream& stream, wauthn_authenticator_attestation_response_s** data);
{
WAuthnCtypeSerializer::serialize(stream, data);
}
- // For wauthn_buffer_s
- static void Serialize(IStream& stream, const wauthn_buffer_s* data)
+ // For wauthn_const_buffer_s
+ static void Serialize(IStream& stream, const wauthn_const_buffer_s* data)
{
WAuthnCtypeSerializer::serialize(stream, data);
}
checkParameters(callbacks);
checkParameters(options->linked_device, callbacks->qrcode_callback);
}
-} /* namespace WebAuthn */
\ No newline at end of file
+} /* namespace WebAuthn */
unsigned char attestationObjectRaw[16] = {0x11, 0x12, 0x13, 0x14, };
unsigned char authenticatorDataRaw[26] = {0x21, 0x22, 0x23, 0x24, };
unsigned char subjectPubkeyInfoRaw[36] = {0x31, 0x32, 0x33, 0x34, };
- wauthn_buffer_s clientDataJson = {clientDataJsonRaw, sizeof(clientDataJsonRaw)};
- wauthn_buffer_s attestationObject = {attestationObjectRaw, sizeof(attestationObjectRaw)};
+ wauthn_const_buffer_s clientDataJson = {clientDataJsonRaw, sizeof(clientDataJsonRaw)};
+ wauthn_const_buffer_s attestationObject = {attestationObjectRaw, sizeof(attestationObjectRaw)};
unsigned int transports = 3;
- wauthn_buffer_s authenticatorData = {authenticatorDataRaw, sizeof(authenticatorDataRaw)};
- wauthn_buffer_s subjectPubkeyInfo = {subjectPubkeyInfoRaw, sizeof(subjectPubkeyInfoRaw)};
+ wauthn_const_buffer_s authenticatorData = {authenticatorDataRaw, sizeof(authenticatorDataRaw)};
+ wauthn_const_buffer_s subjectPubkeyInfo = {subjectPubkeyInfoRaw, sizeof(subjectPubkeyInfoRaw)};
wauthn_cose_algorithm_e pubkey_alg = WAUTHN_COSE_ALGORITHM_ECDSA_P256_WITH_SHA256;
wauthn_authenticator_attestation_response_s authenticatorAttestationResponse
= {&clientDataJson, &attestationObject, transports, &authenticatorData, &subjectPubkeyInfo, pubkey_alg};
unsigned char signatureRaw[26] = {0x21, 0x22, 0x23, 0x24, };
unsigned char userHandleRaw[36] = {0x31, 0x32, 0x33, 0x34, };
- wauthn_buffer_s signature = {signatureRaw, sizeof(signatureRaw)};
- wauthn_buffer_s userHandle = {userHandleRaw, sizeof(userHandleRaw)};
+ wauthn_const_buffer_s signature = {signatureRaw, sizeof(signatureRaw)};
+ wauthn_const_buffer_s userHandle = {userHandleRaw, sizeof(userHandleRaw)};
wauthn_authenticator_assertion_response_s authenticatorAssertionResponse
= {&clientDataJson, &authenticatorData, &signature, &userHandle, &attestationObject};
wauthn_authenticator_assertion_response_s emptyAuthenticatorAssertionResponse
const char *name = "test name";
const char *id = "test id";
- wauthn_rp_entity_s rpEntity = {const_cast<char*>(name), const_cast<char*>(id)};
+ wauthn_rp_entity_s rpEntity = {name, id};
wauthn_rp_entity_s emptyRpEntiy = {nullptr, nullptr};
unsigned char idRaw[06] = {0x01, 0x02, 0x03, 0x04, };
- wauthn_buffer_s bufferId = {idRaw, sizeof(idRaw)};
+ wauthn_const_buffer_s bufferId = {idRaw, sizeof(idRaw)};
const char *displayName = "test displayName";
wauthn_user_entity_s userEntity = {const_cast<char*>(name), &bufferId, const_cast<char*>(displayName)};
wauthn_user_entity_s emptyUserEntity = {nullptr, nullptr, nullptr};
unsigned char idRaw0[06] = {0x01, 0x02, 0x03, 0x04, };
unsigned char idRaw1[16] = {0x11, 0x12, 0x13, 0x14, };
- wauthn_buffer_s bufferId0 = {idRaw0, sizeof(idRaw0)};
- wauthn_buffer_s bufferId1 = {idRaw1, sizeof(idRaw1)};
+ wauthn_const_buffer_s bufferId0 = {idRaw0, sizeof(idRaw0)};
+ wauthn_const_buffer_s bufferId1 = {idRaw1, sizeof(idRaw1)};
wauthn_pubkey_cred_descriptor_s credDescriptor0 = {pubkeyCredType, &bufferId0, 3};
wauthn_pubkey_cred_descriptor_s credDescriptor1 = {pubkeyCredType, &bufferId1, 13};
wauthn_pubkey_cred_descriptor_s pubkeyCredDescriptor2[2] = {credDescriptor0, credDescriptor1};
unsigned char extensionIdRaw[06] = {0x01, 0x02, 0x03, 0x04, };
unsigned char extensionValueRaw[16] = {0x11, 0x12, 0x13, 0x14, };
- wauthn_buffer_s extensionId = {extensionIdRaw, sizeof(extensionIdRaw)};
- wauthn_buffer_s extensionValue = {extensionValueRaw, sizeof(extensionValueRaw)};
+ wauthn_const_buffer_s extensionId = {extensionIdRaw, sizeof(extensionIdRaw)};
+ wauthn_const_buffer_s extensionValue = {extensionValueRaw, sizeof(extensionValueRaw)};
wauthn_authentication_ext_s authenticationExt = {&extensionId, &extensionValue};
wauthn_authentication_ext_s emptyAuthenticationExt = {nullptr, nullptr};
unsigned char extensionIdRaw1[06] = {0x01, 0x02, 0x03, 0x04, };
unsigned char extensionValueRaw1[16] = {0x11, 0x12, 0x13, 0x14, };
- wauthn_buffer_s extensionId1 = {extensionIdRaw1, sizeof(extensionIdRaw1)};
- wauthn_buffer_s extensionValue1 = {extensionValueRaw1, sizeof(extensionValueRaw1)};
+ wauthn_const_buffer_s extensionId1 = {extensionIdRaw1, sizeof(extensionIdRaw1)};
+ wauthn_const_buffer_s extensionValue1 = {extensionValueRaw1, sizeof(extensionValueRaw1)};
wauthn_authentication_ext_s authenticationExt1 = {&extensionId1, &extensionValue1};
wauthn_authentication_ext_s authenticationExtArr1[1] = {authenticationExt};
wauthn_authentication_ext_s authenticationExtArr2[2] = {authenticationExt, authenticationExt1};
unsigned char authenticatorNameRaw[26] = {0x11, 0x12, 0x13, 0x14, };
unsigned char authPubkeyRaw[36] = {0x11, 0x12, 0x13, 0x14, };
unsigned char tunnelServerDomainRaw[36] = {0x11, 0x12, 0x13, 0x14, };
- wauthn_buffer_s contactId = {contactIdRaw, sizeof(contactIdRaw)};
- wauthn_buffer_s linkId = {linkIdRaw, sizeof(linkIdRaw)};
- wauthn_buffer_s linkSecret = {linkSecretRaw, sizeof(linkSecretRaw)};
- wauthn_buffer_s authenticatorPubkey = {authenticatorPubkeyRaw, sizeof(authenticatorPubkeyRaw)};
- wauthn_buffer_s authenticatorName = {authenticatorNameRaw, sizeof(authenticatorNameRaw)};
- wauthn_buffer_s authPubkey = {authPubkeyRaw, sizeof(authPubkeyRaw)};
- wauthn_buffer_s tunnelServerDomain = {tunnelServerDomainRaw, sizeof(tunnelServerDomainRaw)};
+ wauthn_const_buffer_s contactId = {contactIdRaw, sizeof(contactIdRaw)};
+ wauthn_const_buffer_s linkId = {linkIdRaw, sizeof(linkIdRaw)};
+ wauthn_const_buffer_s linkSecret = {linkSecretRaw, sizeof(linkSecretRaw)};
+ wauthn_const_buffer_s authenticatorPubkey = {authenticatorPubkeyRaw, sizeof(authenticatorPubkeyRaw)};
+ wauthn_const_buffer_s authenticatorName = {authenticatorNameRaw, sizeof(authenticatorNameRaw)};
+ wauthn_const_buffer_s authPubkey = {authPubkeyRaw, sizeof(authPubkeyRaw)};
+ wauthn_const_buffer_s tunnelServerDomain = {tunnelServerDomainRaw, sizeof(tunnelServerDomainRaw)};
wauthn_hybrid_linked_data_s hybirdLinkedData = {&contactId, &linkId, &linkSecret, &authenticatorPubkey,
&authenticatorName, &signature, &authPubkey, &tunnelServerDomain};
wauthn_hybrid_linked_data_s emptyHybirdLinkedData = {nullptr, nullptr, nullptr, nullptr,
unsigned char bufferRaw0[06] = {0x01, 0x02, 0x03, 0x04, };
unsigned char bufferRaw1[16] = {0x11, 0x12, 0x13, 0x14, };
- wauthn_buffer_s buffer0 = {bufferRaw0, sizeof(bufferRaw0)};
- wauthn_buffer_s buffer1 = {bufferRaw1, sizeof(bufferRaw1)};
- wauthn_buffer_s attestationFormat1[1] = {buffer0};
- wauthn_buffer_s attestationFormat2[2] = {buffer0, buffer1};
+ wauthn_const_buffer_s buffer0 = {bufferRaw0, sizeof(bufferRaw0)};
+ wauthn_const_buffer_s buffer1 = {bufferRaw1, sizeof(bufferRaw1)};
+ wauthn_const_buffer_s attestationFormat1[1] = {buffer0};
+ wauthn_const_buffer_s attestationFormat2[2] = {buffer0, buffer1};
wauthn_attestation_formats_s attestationFormats1 = {sizeof(attestationFormat1)/sizeof(attestationFormat1[0]),
attestationFormat1};
wauthn_attestation_formats_s attestationFormats2 = {sizeof(attestationFormat2)/sizeof(attestationFormat2[0]),
unsigned char challengeRaw[06] = {0x01, 0x02, 0x03, 0x04, };
unsigned long timeout = 1000;
- wauthn_buffer_s challenge = {challengeRaw, sizeof(challengeRaw)};
+ wauthn_const_buffer_s challenge = {challengeRaw, sizeof(challengeRaw)};
wauthn_attestation_pref_e attestation = AP_DIRECT;
wauthn_pubkey_cred_creation_options_s pubkeyCredCreationOptions = {&rpEntity, &userEntity, &challenge,
&pubkeyCredParams2, timeout, &pubkeyCredDescriptors2, &authenticatorSelCri, &pubkeyCredHints2,
}
}
-bool __compareWAuthnBuffers(const wauthn_buffer_s *expected, const wauthn_buffer_s *actual)
+bool __compareWAuthnBuffers(const wauthn_const_buffer_s *expected, const wauthn_const_buffer_s *actual)
{
if (expected == nullptr || actual == nullptr) {
return (expected == actual);
void __testUnsignedCharPtr(unsigned char *data, size_t data_size)
{
MessageBuffer buffer;
- unsigned char *deserialized = nullptr;
+ const unsigned char *deserialized = nullptr;
size_t deserialized_len = 0;
buffer.InitForStreaming();
// deserialize: for too large data size
unsigned char data[13] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,};
MessageBuffer buffer;
- unsigned char *deserialized = nullptr;
+ const unsigned char *deserialized = nullptr;
size_t deserialized_len = 0;
__fillBufferWithTestData(buffer, MAX_BUFFER_SIZE + 1, data, sizeof(data));
}
}
-TEST_F(WAuthnSerializationTest, CharPtr_P)
+TEST_F(WAuthnSerializationTest, ConstCharPtr_P)
{
- char *data = const_cast<char *>("This is a test data.");
- char *size0data = const_cast<char *>("");
- char *nulldata = nullptr;
+ const char *data = "This is a test data.";
+ const char *size0data ="";
+ const char *nulldata = nullptr;
__testSerialization(data, __compareCstring);
__testSerialization(size0data, __compareCstring);
__testSerializeForInvalidMember(data);
delete[] data;
}
-TEST_F(WAuthnSerializationTest, CharPtr_N2)
+TEST_F(WAuthnSerializationTest, ConstCharPtr_N2)
{// deserialize: for too large length
- char *deserialized = nullptr;
+ const char *deserialized = nullptr;
__testDeserializeForTooLongLength(deserialized);
}
TEST_F(WAuthnSerializationTest, CharPtr_N3)
// strlen(data) = 4, length in buffer stream = 8
unsigned char data[8] = {0x01, 0x02, 0x03, 0x04, 0x00, 0x00, 0x00, 0x00};
MessageBuffer buffer;
- char *deserialized = nullptr;
+ const char *deserialized = nullptr;
__fillBufferWithTestData(buffer, sizeof(data), data, sizeof(data));
try {
WAuthnCtypeSerializer::deserialize(buffer, &deserialized);
}
-TEST_F(WAuthnSerializationTest, wauthn_buffer_s_P)
+TEST_F(WAuthnSerializationTest, wauthn_const_buffer_s_P)
{
unsigned char testdata[26] = {0x01, 0x02, 0x03, 0x04, };
- wauthn_buffer_s buffer = {testdata, sizeof(testdata)};
+ wauthn_const_buffer_s buffer = {testdata, sizeof(testdata)};
__testSerialization(&buffer, __compareWAuthnBuffers);
- wauthn_buffer_s emptyBuffer = {nullptr, 0x00};
+ wauthn_const_buffer_s emptyBuffer = {nullptr, 0x00};
__testSerialization(&emptyBuffer, __compareWAuthnBuffers);
- __testSerialization(static_cast<wauthn_buffer_s *>(nullptr), __compareWAuthnBuffers);
+ __testSerialization(static_cast<wauthn_const_buffer_s *>(nullptr), __compareWAuthnBuffers);
}
-TEST_F(WAuthnSerializationTest, wauthn_buffer_s_N1)
+TEST_F(WAuthnSerializationTest, wauthn_const_buffer_s_N1)
{// serialize: for too large length
unsigned char testdata[26] = {0x01, 0x02, 0x03, 0x04, };
- wauthn_buffer_s data = {testdata, MAX_BUFFER_SIZE + 1};
+ wauthn_const_buffer_s data = {testdata, MAX_BUFFER_SIZE + 1};
MessageBuffer buffer;
buffer.InitForStreaming();
try {
} catch(SerializationException::InvalidStreamData &) {
}
}
-TEST_F(WAuthnSerializationTest, wauthn_buffer_s_N2)
+TEST_F(WAuthnSerializationTest, wauthn_const_buffer_s_N2)
{// serialize: for inconsistent pointer & length
unsigned char testdata[26] = {0x01, 0x02, 0x03, 0x04, };
- wauthn_buffer_s data = {nullptr, sizeof(testdata)};
+ wauthn_const_buffer_s data = {nullptr, sizeof(testdata)};
MessageBuffer buffer;
buffer.InitForStreaming();
try {
} catch(SerializationException::InvalidStreamData &) {
}
}
-TEST_F(WAuthnSerializationTest, wauthn_buffer_s_N3)
+TEST_F(WAuthnSerializationTest, wauthn_const_buffer_s_N3)
{// deserialize: for too large length
- wauthn_buffer_s *deserialized = nullptr;
+ wauthn_const_buffer_s *deserialized = nullptr;
__testDeserializeForTooLongLength(deserialized);
}
}
-} // namespace WA
\ No newline at end of file
+} // namespace WA
unsigned char attestationObjectRaw[16] = {0x11, 0x12, 0x13, 0x14, };
unsigned char authenticatorDataRaw[26] = {0x21, 0x22, 0x23, 0x24, };
unsigned char subjectPubkeyInfoRaw[36] = {0x31, 0x32, 0x33, 0x34, };
- wauthn_buffer_s clientDataJson = {clientDataJsonRaw, sizeof(clientDataJsonRaw)};
- wauthn_buffer_s attestationObject = {attestationObjectRaw, sizeof(attestationObjectRaw)};
+ wauthn_const_buffer_s clientDataJson = {clientDataJsonRaw, sizeof(clientDataJsonRaw)};
+ wauthn_const_buffer_s attestationObject = {attestationObjectRaw, sizeof(attestationObjectRaw)};
unsigned int transports = 3;
- wauthn_buffer_s authenticatorData = {authenticatorDataRaw, sizeof(authenticatorDataRaw)};
- wauthn_buffer_s subjectPubkeyInfo = {subjectPubkeyInfoRaw, sizeof(subjectPubkeyInfoRaw)};
+ wauthn_const_buffer_s authenticatorData = {authenticatorDataRaw, sizeof(authenticatorDataRaw)};
+ wauthn_const_buffer_s subjectPubkeyInfo = {subjectPubkeyInfoRaw, sizeof(subjectPubkeyInfoRaw)};
wauthn_cose_algorithm_e pubkey_alg = WAUTHN_COSE_ALGORITHM_ECDSA_P256_WITH_SHA256;
wauthn_authenticator_attestation_response_s authenticatorAttestationResponse
= {&clientDataJson, &attestationObject, transports, &authenticatorData, &subjectPubkeyInfo, pubkey_alg};
unsigned char signatureRaw[26] = {0x21, 0x22, 0x23, 0x24, };
unsigned char userHandleRaw[36] = {0x31, 0x32, 0x33, 0x34, };
- wauthn_buffer_s signature = {signatureRaw, sizeof(signatureRaw)};
- wauthn_buffer_s userHandle = {userHandleRaw, sizeof(userHandleRaw)};
+ wauthn_const_buffer_s signature = {signatureRaw, sizeof(signatureRaw)};
+ wauthn_const_buffer_s userHandle = {userHandleRaw, sizeof(userHandleRaw)};
wauthn_authenticator_assertion_response_s authenticatorAssertionResponse
= {&clientDataJson, &authenticatorData, &signature, &userHandle, &attestationObject};
wauthn_authenticator_assertion_response_s emptyAuthenticatorAssertionResponse
const char *name = "test name";
const char *id = "test id";
- wauthn_rp_entity_s rpEntity = {const_cast<char*>(name), const_cast<char*>(id)};
+ wauthn_rp_entity_s rpEntity = {name, id};
wauthn_rp_entity_s emptyRpEntiy = {nullptr, nullptr};
unsigned char idRaw[06] = {0x01, 0x02, 0x03, 0x04, };
- wauthn_buffer_s bufferId = {idRaw, sizeof(idRaw)};
+ wauthn_const_buffer_s bufferId = {idRaw, sizeof(idRaw)};
const char *displayName = "test displayName";
wauthn_user_entity_s userEntity = {const_cast<char*>(name), &bufferId, const_cast<char*>(displayName)};
wauthn_user_entity_s emptyUserEntity = {nullptr, nullptr, nullptr};
unsigned char idRaw0[06] = {0x01, 0x02, 0x03, 0x04, };
unsigned char idRaw1[16] = {0x11, 0x12, 0x13, 0x14, };
- wauthn_buffer_s bufferId0 = {idRaw0, sizeof(idRaw0)};
- wauthn_buffer_s bufferId1 = {idRaw1, sizeof(idRaw1)};
+ wauthn_const_buffer_s bufferId0 = {idRaw0, sizeof(idRaw0)};
+ wauthn_const_buffer_s bufferId1 = {idRaw1, sizeof(idRaw1)};
wauthn_pubkey_cred_descriptor_s credDescriptor0 = {pubkeyCredType, &bufferId0, 3};
wauthn_pubkey_cred_descriptor_s credDescriptor1 = {pubkeyCredType, &bufferId1, 13};
wauthn_pubkey_cred_descriptor_s pubkeyCredDescriptor2[2] = {credDescriptor0, credDescriptor1};
unsigned char extensionIdRaw[06] = {0x01, 0x02, 0x03, 0x04, };
unsigned char extensionValueRaw[16] = {0x11, 0x12, 0x13, 0x14, };
- wauthn_buffer_s extensionId = {extensionIdRaw, sizeof(extensionIdRaw)};
- wauthn_buffer_s extensionValue = {extensionValueRaw, sizeof(extensionValueRaw)};
+ wauthn_const_buffer_s extensionId = {extensionIdRaw, sizeof(extensionIdRaw)};
+ wauthn_const_buffer_s extensionValue = {extensionValueRaw, sizeof(extensionValueRaw)};
wauthn_authentication_ext_s authenticationExt = {&extensionId, &extensionValue};
wauthn_authentication_ext_s emptyAuthenticationExt = {nullptr, nullptr};
unsigned char extensionIdRaw1[06] = {0x01, 0x02, 0x03, 0x04, };
unsigned char extensionValueRaw1[16] = {0x11, 0x12, 0x13, 0x14, };
- wauthn_buffer_s extensionId1 = {extensionIdRaw1, sizeof(extensionIdRaw1)};
- wauthn_buffer_s extensionValue1 = {extensionValueRaw1, sizeof(extensionValueRaw1)};
+ wauthn_const_buffer_s extensionId1 = {extensionIdRaw1, sizeof(extensionIdRaw1)};
+ wauthn_const_buffer_s extensionValue1 = {extensionValueRaw1, sizeof(extensionValueRaw1)};
wauthn_authentication_ext_s authenticationExt1 = {&extensionId1, &extensionValue1};
wauthn_authentication_ext_s authenticationExtArr1[1] = {authenticationExt};
wauthn_authentication_ext_s authenticationExtArr2[2] = {authenticationExt, authenticationExt1};
unsigned char authenticatorNameRaw[26] = {0x11, 0x12, 0x13, 0x14, };
unsigned char authPubkeyRaw[36] = {0x11, 0x12, 0x13, 0x14, };
unsigned char tunnelServerDomainRaw[36] = {0x11, 0x12, 0x13, 0x14, };
- wauthn_buffer_s contactId = {contactIdRaw, sizeof(contactIdRaw)};
- wauthn_buffer_s linkId = {linkIdRaw, sizeof(linkIdRaw)};
- wauthn_buffer_s linkSecret = {linkSecretRaw, sizeof(linkSecretRaw)};
- wauthn_buffer_s authenticatorPubkey = {authenticatorPubkeyRaw, sizeof(authenticatorPubkeyRaw)};
- wauthn_buffer_s authenticatorName = {authenticatorNameRaw, sizeof(authenticatorNameRaw)};
- wauthn_buffer_s authPubkey = {authPubkeyRaw, sizeof(authPubkeyRaw)};
- wauthn_buffer_s tunnelServerDomain = {tunnelServerDomainRaw, sizeof(tunnelServerDomainRaw)};
+ wauthn_const_buffer_s contactId = {contactIdRaw, sizeof(contactIdRaw)};
+ wauthn_const_buffer_s linkId = {linkIdRaw, sizeof(linkIdRaw)};
+ wauthn_const_buffer_s linkSecret = {linkSecretRaw, sizeof(linkSecretRaw)};
+ wauthn_const_buffer_s authenticatorPubkey = {authenticatorPubkeyRaw, sizeof(authenticatorPubkeyRaw)};
+ wauthn_const_buffer_s authenticatorName = {authenticatorNameRaw, sizeof(authenticatorNameRaw)};
+ wauthn_const_buffer_s authPubkey = {authPubkeyRaw, sizeof(authPubkeyRaw)};
+ wauthn_const_buffer_s tunnelServerDomain = {tunnelServerDomainRaw, sizeof(tunnelServerDomainRaw)};
wauthn_hybrid_linked_data_s hybirdLinkedData = {&contactId, &linkId, &linkSecret, &authenticatorPubkey,
&authenticatorName, &signature, &authPubkey, &tunnelServerDomain};
wauthn_hybrid_linked_data_s emptyHybirdLinkedData = {nullptr, nullptr, nullptr, nullptr,
unsigned char bufferRaw0[06] = {0x01, 0x02, 0x03, 0x04, };
unsigned char bufferRaw1[16] = {0x11, 0x12, 0x13, 0x14, };
- wauthn_buffer_s buffer0 = {bufferRaw0, sizeof(bufferRaw0)};
- wauthn_buffer_s buffer1 = {bufferRaw1, sizeof(bufferRaw1)};
- wauthn_buffer_s attestationFormat1[1] = {buffer0};
- wauthn_buffer_s attestationFormat2[2] = {buffer0, buffer1};
+ wauthn_const_buffer_s buffer0 = {bufferRaw0, sizeof(bufferRaw0)};
+ wauthn_const_buffer_s buffer1 = {bufferRaw1, sizeof(bufferRaw1)};
+ wauthn_const_buffer_s attestationFormat1[1] = {buffer0};
+ wauthn_const_buffer_s attestationFormat2[2] = {buffer0, buffer1};
wauthn_attestation_formats_s attestationFormats1 = {sizeof(attestationFormat1)/sizeof(attestationFormat1[0]),
attestationFormat1};
wauthn_attestation_formats_s attestationFormats2 = {sizeof(attestationFormat2)/sizeof(attestationFormat2[0]),
unsigned char challengeRaw[06] = {0x01, 0x02, 0x03, 0x04, };
unsigned long timeout = 1000;
- wauthn_buffer_s challenge = {challengeRaw, sizeof(challengeRaw)};
+ wauthn_const_buffer_s challenge = {challengeRaw, sizeof(challengeRaw)};
wauthn_attestation_pref_e attestation = AP_DIRECT;
wauthn_pubkey_cred_creation_options_s pubkeyCredCreationOptions = {&rpEntity, &userEntity, &challenge,
&pubkeyCredParams2, timeout, &pubkeyCredDescriptors2, &authenticatorSelCri, &pubkeyCredHints2,
sleep(10);
}
-} // namespace WA
\ No newline at end of file
+} // namespace WA