1 /* 2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.adservices.service.stats.kanon; 18 19 /** This class represents the constant values used for kanon logging. */ 20 public class KAnonSignJoinStatsConstants { 21 22 // Code for different KAnon actions (0-13). 23 24 /** Unknown action or unset action */ 25 public static final int KANON_ACTION_UNSET = 0; 26 27 /** KAnon get challenge action */ 28 public static final int KANON_ACTION_GET_CHALLENGE_HTTP_CALL = 1; 29 30 /** Generating a kanon key attestation. */ 31 public static final int KANON_ACTION_KEY_ATTESTATION_CERT_GENERATION = 2; 32 33 /** Making an http server call to fetch server parameters */ 34 public static final int KANON_ACTION_SERVER_PARAM_HTTP_CALL = 3; 35 36 /** Parsing the server public params from the http response. */ 37 public static final int KANON_ACTION_SERVER_PUBLIC_PARAMS_PROTO_COMPOSITION = 4; 38 39 /** Generating the client parameters using the ACT Library */ 40 public static final int KANON_ACTION_GENERATE_CLIENT_PARAM_ACT = 5; 41 42 /** Making an http server call to register the client */ 43 public static final int KANON_ACTION_REGISTER_CLIENT_HTTP_CALL = 6; 44 45 /** Parsing the register client proto from the http response */ 46 public static final int KANON_ACTION_REGISTER_CLIENT_RESPONSE_PROTO_COMPOSITION = 7; 47 48 /** Generating the tokens request using the ACT library */ 49 public static final int KANON_ACTION_GENERATE_TOKENS_REQUEST_ACT = 8; 50 51 /** Making an http server call to get the tokens */ 52 public static final int KANON_ACTION_GET_TOKENS_REQUEST_HTTP_CALL = 9; 53 54 /** Parsing the get tokens response into a proto from the http response */ 55 public static final int KANON_ACTION_GET_TOKENS_RESPONSE_PROTO_COMPOSITION = 10; 56 57 /** Verifying the tokens using the ACT library */ 58 public static final int KANON_ACTION_VERIFY_TOKENS_RESPONSE_ACT = 11; 59 60 /** Recovering the tokens using ACT library */ 61 public static final int KANON_ACTION_RECOVER_TOKENS_ACT = 12; 62 63 /** Making an http call to the server to make the join request */ 64 public static final int KANON_ACTION_JOIN_HTTP_CALL = 13; 65 66 // The following are the result for the failure reason for the kanon action. It is set to 0 if 67 // there was no failure. 68 69 public static final int KANON_ACTION_FAILURE_REASON_UNSET = 0; 70 71 /** Represents a network exception. Eg. 404 error. */ 72 public static final int KANON_ACTION_FAILURE_REASON_NETWORK_EXCEPTION = 1; 73 74 /** Exception from the server. Eg. Server failed our request. */ 75 public static final int KANON_ACTION_FAILURE_REASON_SERVER_EXCEPTION = 2; 76 77 /** 78 * Not able to parse the protobuf. This will most likely happen when the server returned a bad 79 * response 80 */ 81 public static final int KANON_ACTION_FAILURE_REASON_PROTO_PARSE_EXCEPTION = 3; 82 83 /** Internal error in our implementation. */ 84 public static final int KANON_ACTION_FAILURE_REASON_INTERNAL_ERROR = 4; 85 86 /** Unknown error */ 87 public static final int KANON_ACTION_FAILURE_REASON_UNKNOWN_ERROR = 5; 88 89 // The result code of a K-Anon Job (triggered immediately after auction or via background job) 90 91 public static final int KANON_JOB_RESULT_UNSET = 0; 92 93 /** Failure during KAnon initialize method */ 94 public static final int KANON_JOB_RESULT_INITIALIZE_FAILED = 1; 95 96 /** Failure during sign process for this job */ 97 public static final int KANON_JOB_RESULT_SOME_OR_ALL_SIGN_FAILED = 2; 98 99 /** Failure during join process for this job */ 100 public static final int KANON_JOB_RESULT_SOME_OR_ALL_JOIN_FAILED = 3; 101 102 /** No failure in the job, everything is successful */ 103 public static final int KANON_JOB_RESULT_SUCCESS = 4; 104 105 // The following result codes are related to the KAnon get challenge path. 106 107 /** Unset result code, used for unknown scenarios */ 108 public static final int KEY_ATTESTATION_RESULT_UNSET = 0; 109 110 /** Result code indicating the {@link java.security.KeyStoreException} error thrown. */ 111 public static final int KEY_ATTESTATION_RESULT_KEYSTORE_EXCEPTION = 1; 112 113 /** Result code indicating the {@link IllegalStateException} error thrown. */ 114 public static final int KEY_ATTESTATION_RESULT_ILLEGAL_STATE_EXCEPTION = 2; 115 116 /** Result code indicating the {@link java.security.cert.CertificateException} error thrown. */ 117 public static final int KEY_ATTESTATION_RESULT_CERTIFICATE_EXCEPTION = 3; 118 119 /** Result code indicating the {@link java.security.NoSuchAlgorithmException} error thrown. */ 120 public static final int KEY_ATTESTATION_RESULT_IO_EXCEPTION = 4; 121 122 /** Result code indicating the {@link java.security.NoSuchAlgorithmException} error thrown. */ 123 public static final int KEY_ATTESTATION_RESULT_NO_SUCH_ALGORITHM_EXCEPTION = 5; 124 125 /** Result code indicating get challenge was successful */ 126 public static final int KEY_ATTESTATION_RESULT_SUCCESS = 6; 127 } 128