change enums to uppercase
authorDongsun Lee <ds73.lee@samsung.com>
Mon, 22 Jan 2024 04:27:30 +0000 (13:27 +0900)
committer이동선/Security&Privacy팀(SR)/삼성전자 <ds73.lee@samsung.com>
Mon, 22 Jan 2024 04:59:49 +0000 (13:59 +0900)
include/webauthn-types.h
srcs/common/serialization.cpp
srcs/server/service.cpp
tests/serialization-test.cpp
tests/webauthn-client-test.cpp

index 90a44bad0c229605de4e8336ad6709b500087330..37bffd06f568a8d8146a520cfe57cbb211b6db58 100644 (file)
@@ -115,10 +115,10 @@ typedef enum __wauthn_cose_algorithm {
  * @since_tizen 9.0
  */
 typedef enum __wauthn_attestation_pref {
-    ap_none                     = 0, /**< none */
-    ap_indirect                 = 1, /**< "indirect" */
-    ap_direct                   = 2, /**< "direct" */
-    ap_enterprise               = 3, /**< "enterprise" */
+    AP_NONE                     = 0, /**< none */
+    AP_INDIRECT                 = 1, /**< "indirect" */
+    AP_DIRECT                   = 2, /**< "direct" */
+    AP_ENTERPRISE               = 3, /**< "enterprise" */
 } wauthn_attestation_pref_e;
 
 /**
@@ -126,10 +126,10 @@ typedef enum __wauthn_attestation_pref {
  * @since_tizen 9.0
  */
 typedef enum __wauthn_pubkey_cred_hint {
-    pch_none                    = 0, /**< none */
-    pch_security_key            = 1, /**< "security-key" */
-    pch_client_device           = 2, /**< "client-device" */
-    pch_hybrid                  = 3, /**< "hybrid" */
+    PCH_NONE                    = 0, /**< none */
+    PCH_SECURITY_KEY            = 1, /**< "security-key" */
+    PCH_CLIENT_DEVICE           = 2, /**< "client-device" */
+    PCH_HYBRID                  = 3, /**< "hybrid" */
 } wauthn_pubkey_cred_hint_e;
 
 /**
@@ -137,10 +137,10 @@ typedef enum __wauthn_pubkey_cred_hint {
  * @since_tizen 9.0
  */
 typedef enum __wauthn_user_verification_requirement {
-    uvr_none                    = 0, /**< none */
-    uvr_required                = 1, /**< "required" */
-    uvr_preferred               = 2, /**< "preferred" */
-    uvr_discouraged             = 3, /**< "discouraged" */
+    UVR_NONE                    = 0, /**< none */
+    UVR_REQUIRED                = 1, /**< "required" */
+    UVR_PREFERRED               = 2, /**< "preferred" */
+    UVR_DISCOURAGED             = 3, /**< "discouraged" */
 } wauthn_user_verification_requirement_e;
 
 /**
@@ -148,10 +148,10 @@ typedef enum __wauthn_user_verification_requirement {
  * @since_tizen 9.0
  */
 typedef enum __wauthn_resident_key_requirement {
-    rkr_none                    = 0, /**< none */
-    rkr_discouraged             = 1, /**< "discouraged" */
-    rkr_preferred               = 2, /**< "preferred" */
-    rkr_required                = 3, /**< "required" */
+    RKR_NONE                    = 0, /**< none */
+    RKR_DISCOURAGED             = 1, /**< "discouraged" */
+    RKR_PREFERRED               = 2, /**< "preferred" */
+    RKR_REQUIRED                = 3, /**< "required" */
 } wauthn_resident_key_requirement_e;
 
 /**
@@ -159,9 +159,9 @@ typedef enum __wauthn_resident_key_requirement {
  * @since_tizen 9.0
  */
 typedef enum __wauthn_authenticator_attachment {
-    aa_none                     = 0, /**< none */
-    aa_platform                 = 1, /**< "platform" */
-    aa_cross_platform           = 2, /**< "cross-platform" */
+    AA_NONE                     = 0, /**< none */
+    AA_PLATFORM                 = 1, /**< "platform" */
+    AA_CROSS_PLATFORM           = 2, /**< "cross-platform" */
 } wauthn_authenticator_attachment_e;
 
 /**
@@ -170,7 +170,7 @@ typedef enum __wauthn_authenticator_attachment {
  * @since_tizen 9.0
  */
 typedef enum __wauthn_pubkey_cred_type {
-    pct_public_key              = 1, /**< public-key */
+    PCT_PUBLIC_KEY              = 1, /**< public-key */
 } wauthn_pubkey_cred_type_e;
 
 /**
@@ -400,7 +400,7 @@ typedef struct __wauthn_pubkey_cred_creation_options {
         guide the user agent in interacting with the user. (optional)*/
     wauthn_attestation_pref_e attestation; /**<
         The Relying Party MAY use this member to specify a preference regarding attestation
-        conveyance. The default value is #ap_none (optional) */
+        conveyance. The default value is #AP_NONE (optional) */
     wauthn_attestation_formats_s *attestation_formats; /**<
         The Relying Party MAY use this member to specify a preference regarding the attestation
         statement format used by the authenticator. The default value is the empty list, which
@@ -435,13 +435,13 @@ typedef struct __wauthn_pubkey_cred_request_options {
     wauthn_user_verification_requirement_e user_verification; /**<
         This member specifies the Relying Party's requirements regarding
         user verification for the wauthn_get_assertion() operation.
-        The default value is #uvr_preferred (optional) */
+        The default value is #UVR_PREFERRED (optional) */
     wauthn_pubkey_cred_hints_s *hints; /**<
         This member contains zero or more elements from #wauthn_pubkey_cred_hint_e to
         guide the user agent in interacting with the user. (optional)*/
     wauthn_attestation_pref_e attestation; /**<
         The Relying Party MAY use this member to specify a preference regarding
-        attestation conveyance. The default value is #ap_none (optional)*/
+        attestation conveyance. The default value is #AP_NONE (optional)*/
     wauthn_attestation_formats_s *attestation_formats; /**<
         The Relying Party MAY use this member to specify a preference regarding the attestation
         statement format used by the authenticator. The default value is the empty list, which
index 15c7fb5422922bd88466896c74d048cfdb973dde..c39950adf880a7afa3afb07ef501287a3e6c88cd 100644 (file)
@@ -246,7 +246,7 @@ void WAuthnCtypeSerializer::deserialize(IStream& stream, wauthn_user_entity_s**
 
 // For wauthn_pubkey_cred_param_s
 void __checkValidity(const wauthn_pubkey_cred_type_e type) {
-    if (type != pct_public_key)
+    if (type != PCT_PUBLIC_KEY)
         ThrowMsg(SerializationException::InvalidStreamData,
             "Invalid wauthn_pubkey_cred_type_e: type=" << type);
 }
@@ -472,9 +472,9 @@ void WAuthnCtypeSerializer::deserialize(IStream& stream, wauthn_authentication_e
 // For wauthn_authenticator_sel_cri_s
 void __checkValidity(const wauthn_authenticator_attachment_e attachment) {
     switch(attachment) {
-        case aa_none:
-        case aa_platform:
-        case aa_cross_platform:
+        case AA_NONE:
+        case AA_PLATFORM:
+        case AA_CROSS_PLATFORM:
             return;
         default:
             ThrowMsg(SerializationException::InvalidStreamData,
@@ -483,10 +483,10 @@ void __checkValidity(const wauthn_authenticator_attachment_e attachment) {
 }
 void __checkValidity(const wauthn_resident_key_requirement_e resident_key) {
     switch(resident_key) {
-        case rkr_none:
-        case rkr_discouraged:
-        case rkr_preferred:
-        case rkr_required:
+        case RKR_NONE:
+        case RKR_DISCOURAGED:
+        case RKR_PREFERRED:
+        case RKR_REQUIRED:
             return;
         default:
             ThrowMsg(SerializationException::InvalidStreamData,
@@ -495,10 +495,10 @@ void __checkValidity(const wauthn_resident_key_requirement_e resident_key) {
 }
 void __checkValidity(const wauthn_user_verification_requirement_e user_verification) {
     switch(user_verification) {
-        case uvr_none:
-        case uvr_required:
-        case uvr_preferred:
-        case uvr_discouraged:
+        case UVR_NONE:
+        case UVR_REQUIRED:
+        case UVR_PREFERRED:
+        case UVR_DISCOURAGED:
             return;
         default:
             ThrowMsg(SerializationException::InvalidStreamData,
@@ -530,10 +530,10 @@ void __checkValidity(const wauthn_pubkey_cred_hint_e *hint) {
     if (hint == nullptr)
         return;
     switch(*hint) {
-        case pch_none:
-        case pch_security_key:
-        case pch_client_device:
-        case pch_hybrid:
+        case PCH_NONE:
+        case PCH_SECURITY_KEY:
+        case PCH_CLIENT_DEVICE:
+        case PCH_HYBRID:
             return;
         default:
             ThrowMsg(SerializationException::InvalidStreamData,
@@ -663,10 +663,10 @@ void WAuthnCtypeSerializer::deserialize(IStream& stream, wauthn_attestation_form
 // For wauthn_pubkey_cred_creation_options_s
 void __checkValidity(wauthn_attestation_pref_e attestation) {
     switch(attestation) {
-        case ap_none:
-        case ap_indirect:
-        case ap_direct:
-        case ap_enterprise:
+        case AP_NONE:
+        case AP_INDIRECT:
+        case AP_DIRECT:
+        case AP_ENTERPRISE:
             return;
         default:
             ThrowMsg(SerializationException::InvalidStreamData,
index 2d6c136fbba690f920dadbe50136687a17a57fd1..e4a2bb55ecd2cecc8310570c9d75d5fcdec23f0a 100644 (file)
@@ -49,7 +49,7 @@ void wah_make_credential(const wauthn_client_data_s *client_data,
     sleep(2);
     wauthn_pubkey_credential_attestaion_s *pubkey_cred = 
         (wauthn_pubkey_credential_attestaion_s*) calloc(1, sizeof(wauthn_pubkey_credential_attestaion_s));
-    pubkey_cred->type = pct_public_key;
+    pubkey_cred->type = PCT_PUBLIC_KEY;
     callbacks->response_callback(pubkey_cred, WAUTHN_ERROR_NONE, callbacks->user_data);
 }
 
@@ -68,7 +68,7 @@ void wah_get_assertion(const wauthn_client_data_s *client_data,
     sleep(2);
     wauthn_pubkey_credential_assertion_s *pubkey_cred = 
         (wauthn_pubkey_credential_assertion_s*) calloc(1, sizeof(wauthn_pubkey_credential_assertion_s));
-    pubkey_cred->type = pct_public_key;
+    pubkey_cred->type = PCT_PUBLIC_KEY;
     callbacks->response_callback(pubkey_cred, WAUTHN_ERROR_NONE, callbacks->user_data);
 }
 
index 5f1626398646a37cd5a349eb88b2fb83deb45e8b..9914d54ac6fb3256bb08f73c679b0f653d473541 100644 (file)
@@ -64,7 +64,7 @@ namespace SerializationTestData {
     wauthn_user_entity_s userEntity = {const_cast<char*>(name), &bufferId, const_cast<char*>(displayName)};
     wauthn_user_entity_s emptyUserEntity = {nullptr, nullptr, nullptr};
 
-    wauthn_pubkey_cred_type_e pubkeyCredType = pct_public_key;
+    wauthn_pubkey_cred_type_e pubkeyCredType = PCT_PUBLIC_KEY;
     wauthn_pubkey_cred_param_s credParam0 = {pubkeyCredType, WAUTHN_COSE_ALGORITHM_ECDSA_P256_WITH_SHA256};
     wauthn_pubkey_cred_param_s credParam1 = {pubkeyCredType, WAUTHN_COSE_ALGORITHM_ECDSA_P521_WITH_SHA512};
     wauthn_pubkey_cred_param_s pubkeyCredParam2[2] = {credParam0, credParam1};
@@ -110,15 +110,15 @@ namespace SerializationTestData {
                                                                 authenticationExtArr2};
     wauthn_authentication_exts_s emptyAuthenticationExts = {0, nullptr};
 
-    wauthn_authenticator_attachment_e attachment = aa_platform;
-    wauthn_resident_key_requirement_e resident_key = rkr_preferred;
+    wauthn_authenticator_attachment_e attachment = AA_PLATFORM;
+    wauthn_resident_key_requirement_e resident_key = RKR_PREFERRED;
     bool require_resident_key = false;
-    wauthn_user_verification_requirement_e user_verification = uvr_discouraged;
+    wauthn_user_verification_requirement_e user_verification = UVR_DISCOURAGED;
     wauthn_authenticator_sel_cri_s authenticatorSelCri = {attachment, resident_key,
                                 require_resident_key, user_verification};
 
-    wauthn_pubkey_cred_hint_e hint0 = pch_security_key;
-    wauthn_pubkey_cred_hint_e hint1 = pch_client_device;
+    wauthn_pubkey_cred_hint_e hint0 = PCH_SECURITY_KEY;
+    wauthn_pubkey_cred_hint_e hint1 = PCH_CLIENT_DEVICE;
     wauthn_pubkey_cred_hint_e pubkeyCredHint1[1] = {hint0};
     wauthn_pubkey_cred_hint_e pubkeyCredHint2[2] = {hint0, hint1};
     wauthn_pubkey_cred_hints_s pubkeyCredHints1 = {sizeof(pubkeyCredHint1)/sizeof(pubkeyCredHint1[0]), pubkeyCredHint1};
@@ -159,19 +159,19 @@ namespace SerializationTestData {
     unsigned char challengeRaw[06] = {0x01, 0x02, 0x03, 0x04, };
     unsigned long timeout = 1000;
     wauthn_buffer_s challenge = {challengeRaw, sizeof(challengeRaw)};
-    wauthn_attestation_pref_e attestation = ap_direct;
+    wauthn_attestation_pref_e attestation = AP_DIRECT;
     wauthn_pubkey_cred_creation_options_s pubkeyCredCreationOptions = {&rpEntity, &userEntity, &challenge,
             &pubkeyCredParams2, timeout, &pubkeyCredDescriptors2, &authenticatorSelCri, &pubkeyCredHints2,
             attestation, &attestationFormats1, &authenticationExts2, &hybirdLinkedData};
     wauthn_pubkey_cred_creation_options_s emptyPubkeyCredCreationOptions = {nullptr, nullptr, nullptr,
-            nullptr, 0, nullptr, nullptr, nullptr, ap_none, nullptr, nullptr, nullptr};
+            nullptr, 0, nullptr, nullptr, nullptr, AP_NONE, nullptr, nullptr, nullptr};
 
     const char *rpId = "test RP ID";
     wauthn_pubkey_cred_request_options_s pubkeyCredRequestOptions = {&challenge, timeout, const_cast<char *>(rpId),
             &pubkeyCredDescriptors2, user_verification, &pubkeyCredHints2, attestation, &attestationFormats1,
             &authenticationExts2, &hybirdLinkedData};
     wauthn_pubkey_cred_request_options_s emptyPubkeyCredRequestOptions = {nullptr, 0, nullptr,
-            nullptr, uvr_none, nullptr, ap_none, nullptr, nullptr, nullptr};
+            nullptr, UVR_NONE, nullptr, AP_NONE, nullptr, nullptr, nullptr};
 
     bool is_conditional_mediation_available = false;
     wauthn_pubkey_credential_attestaion_s pubkeyCredentialAttestation = {&bufferId, pubkeyCredType, &bufferId0,
@@ -643,8 +643,8 @@ bool __compareWAuthnPubkeyCredParamS(const wauthn_pubkey_cred_param_s *expected,
 }
 TEST_F(WAuthnSerializationTest, wauthn_pubkey_cred_param_s_P)
 {
-    wauthn_pubkey_cred_param_s data1 = {pct_public_key, WAUTHN_COSE_ALGORITHM_ECDSA_P256_WITH_SHA256};
-    wauthn_pubkey_cred_param_s data2 = {pct_public_key, WAUTHN_COSE_ALGORITHM_ECDSA_P521_WITH_SHA512};
+    wauthn_pubkey_cred_param_s data1 = {PCT_PUBLIC_KEY, WAUTHN_COSE_ALGORITHM_ECDSA_P256_WITH_SHA256};
+    wauthn_pubkey_cred_param_s data2 = {PCT_PUBLIC_KEY, WAUTHN_COSE_ALGORITHM_ECDSA_P521_WITH_SHA512};
 
     __testSerialization(&data1, __compareWAuthnPubkeyCredParamS);
     __testSerialization(&data2, __compareWAuthnPubkeyCredParamS);
@@ -655,7 +655,7 @@ TEST_F(WAuthnSerializationTest, wauthn_pubkey_cred_param_s_N1)
     wauthn_pubkey_cred_param_s data1 = {static_cast<wauthn_pubkey_cred_type_e>(0x00FFFFFF),
                                         WAUTHN_COSE_ALGORITHM_ECDSA_P256_WITH_SHA256};
     __testSerializeForInvalidMember(&data1);
-    wauthn_pubkey_cred_param_s data2 = {pct_public_key,
+    wauthn_pubkey_cred_param_s data2 = {PCT_PUBLIC_KEY,
                                         static_cast<wauthn_cose_algorithm_e>(0x00FFFFFF)};
     __testSerializeForInvalidMember(&data2);
 }
@@ -877,23 +877,23 @@ TEST_F(WAuthnSerializationTest, wauthn_authenticator_sel_cri_s_N2)
 TEST_F(WAuthnSerializationTest, wauthn_authenticator_sel_cri_s_N3)
 {// deserialize: for invalid attachment
     wauthn_authenticator_sel_cri_s data = {static_cast<wauthn_authenticator_attachment_e>(0x00FFFFFF),
-                                rkr_discouraged,
+                                RKR_DISCOURAGED,
                                 false,
-                                uvr_discouraged};
+                                UVR_DISCOURAGED};
     __testDeserializeInvalidMember(data);
 }
 TEST_F(WAuthnSerializationTest, wauthn_authenticator_sel_cri_s_N4)
 {// deserialize: for invalid resident_key
-    wauthn_authenticator_sel_cri_s data = {aa_cross_platform,
+    wauthn_authenticator_sel_cri_s data = {AA_CROSS_PLATFORM,
                                 static_cast<wauthn_resident_key_requirement_e>(0x00FFFFFF),
                                 false,
-                                uvr_discouraged};
+                                UVR_DISCOURAGED};
     __testDeserializeInvalidMember(data);
 }
 TEST_F(WAuthnSerializationTest, wauthn_authenticator_sel_cri_s_N5)
 {// deserialize: for invalid user_verification
-    wauthn_authenticator_sel_cri_s data = {aa_cross_platform,
-                                rkr_discouraged,
+    wauthn_authenticator_sel_cri_s data = {AA_CROSS_PLATFORM,
+                                RKR_DISCOURAGED,
                                 false,
                                 static_cast<wauthn_user_verification_requirement_e>(0x00FFFFFF)};
     __testDeserializeInvalidMember(data);
index a2e0044bb2d264dd33b80394e42aa7a5391003eb..b5d73c659a564a1131f0f92305d5544b141d8fa6 100644 (file)
@@ -67,7 +67,7 @@ namespace CommonTestData {
     wauthn_user_entity_s userEntity = {const_cast<char*>(name), &bufferId, const_cast<char*>(displayName)};
     wauthn_user_entity_s emptyUserEntity = {nullptr, nullptr, nullptr};
 
-    wauthn_pubkey_cred_type_e pubkeyCredType = pct_public_key;
+    wauthn_pubkey_cred_type_e pubkeyCredType = PCT_PUBLIC_KEY;
     wauthn_pubkey_cred_param_s credParam0 = {pubkeyCredType, WAUTHN_COSE_ALGORITHM_ECDSA_P256_WITH_SHA256};
     wauthn_pubkey_cred_param_s credParam1 = {pubkeyCredType, WAUTHN_COSE_ALGORITHM_ECDSA_P521_WITH_SHA512};
     wauthn_pubkey_cred_param_s pubkeyCredParam2[2] = {credParam0, credParam1};
@@ -113,15 +113,15 @@ namespace CommonTestData {
                                                                 authenticationExtArr2};
     wauthn_authentication_exts_s emptyAuthenticationExts = {0, nullptr};
 
-    wauthn_authenticator_attachment_e attachment = aa_platform;
-    wauthn_resident_key_requirement_e resident_key = rkr_preferred;
+    wauthn_authenticator_attachment_e attachment = AA_PLATFORM;
+    wauthn_resident_key_requirement_e resident_key = RKR_PREFERRED;
     bool require_resident_key = false;
-    wauthn_user_verification_requirement_e user_verification = uvr_discouraged;
+    wauthn_user_verification_requirement_e user_verification = UVR_DISCOURAGED;
     wauthn_authenticator_sel_cri_s authenticatorSelCri = {attachment, resident_key,
                                 require_resident_key, user_verification};
 
-    wauthn_pubkey_cred_hint_e hint0 = pch_security_key;
-    wauthn_pubkey_cred_hint_e hint1 = pch_client_device;
+    wauthn_pubkey_cred_hint_e hint0 = PCH_SECURITY_KEY;
+    wauthn_pubkey_cred_hint_e hint1 = PCH_CLIENT_DEVICE;
     wauthn_pubkey_cred_hint_e pubkeyCredHint1[1] = {hint0};
     wauthn_pubkey_cred_hint_e pubkeyCredHint2[2] = {hint0, hint1};
     wauthn_pubkey_cred_hints_s pubkeyCredHints1 = {sizeof(pubkeyCredHint1)/sizeof(pubkeyCredHint1[0]), pubkeyCredHint1};
@@ -162,19 +162,19 @@ namespace CommonTestData {
     unsigned char challengeRaw[06] = {0x01, 0x02, 0x03, 0x04, };
     unsigned long timeout = 1000;
     wauthn_buffer_s challenge = {challengeRaw, sizeof(challengeRaw)};
-    wauthn_attestation_pref_e attestation = ap_direct;
+    wauthn_attestation_pref_e attestation = AP_DIRECT;
     wauthn_pubkey_cred_creation_options_s pubkeyCredCreationOptions = {&rpEntity, &userEntity, &challenge,
             &pubkeyCredParams2, timeout, &pubkeyCredDescriptors2, &authenticatorSelCri, &pubkeyCredHints2,
             attestation, &attestationFormats1, &authenticationExts2, &hybirdLinkedData};
     wauthn_pubkey_cred_creation_options_s emptyPubkeyCredCreationOptions = {nullptr, nullptr, nullptr,
-            nullptr, 0, nullptr, nullptr, nullptr, ap_none, nullptr, nullptr, nullptr};
+            nullptr, 0, nullptr, nullptr, nullptr, AP_NONE, nullptr, nullptr, nullptr};
 
     const char *rpId = "test RP ID";
     wauthn_pubkey_cred_request_options_s pubkeyCredRequestOptions = {&challenge, timeout, const_cast<char *>(rpId),
             &pubkeyCredDescriptors2, user_verification, &pubkeyCredHints2, attestation, &attestationFormats1,
             &authenticationExts2, &hybirdLinkedData};
     wauthn_pubkey_cred_request_options_s emptyPubkeyCredRequestOptions = {nullptr, 0, nullptr,
-            nullptr, uvr_none, nullptr, ap_none, nullptr, nullptr, nullptr};
+            nullptr, UVR_NONE, nullptr, AP_NONE, nullptr, nullptr, nullptr};
 
     bool is_conditional_mediation_available = false;
     wauthn_pubkey_credential_attestaion_s pubkeyCredentialAttestation = {&bufferId, pubkeyCredType, &bufferId0,