/** * gnutls_ocsp_resp_print: * @resp: The structure to be printed * @format: Indicate the format to use * @out: Newly allocated datum with (0) terminated string. * * This function will pretty print a OCSP response, suitable for * display to a human. * * If the format is %GNUTLS_OCSP_PRINT_FULL then all fields of the * response will be output, on multiple lines. * * The output @out->data needs to be deallocate using gnutls_free(). * * Returns: On success, %GNUTLS_E_SUCCESS (0) is returned, otherwise a * negative error value. **/ int gnutls_ocsp_resp_print (gnutls_ocsp_resp_t resp, gnutls_ocsp_print_formats_t format, gnutls_datum_t * out) { gnutls_buffer_st str; int rc; _gnutls_buffer_init (&str); _gnutls_buffer_append_str (&str, _("OCSP Response Information:\n")); print_resp (&str, resp, format); _gnutls_buffer_append_data (&str, "\0", 1); rc = _gnutls_buffer_to_datum (&str, out); if (rc != GNUTLS_E_SUCCESS) { gnutls_assert (); return rc; } return GNUTLS_E_SUCCESS; }
//Our entry-point. int ioctl(int fd, int request, unsigned long* data){ //The hook. if(request == MD_XACT){ Request request; Response response; memcpy(&request,*(unsigned int *)data,277); response.return_code = 0; memset(response.dog_data,0x00,256); response.dog_serial = curr_dog.dog_serial; if(request.magic != MD_MAGIC){ printf("ERR-BAD MAGIC\n"); } crypt_request(&request); if(DEBUG){ print_req(&request); } //Determine transaction - Much Functionality WOW switch(request.opcode){ case MD_DOGCHECK: printf("MD_DOGCHECK\n"); break; case MD_READDOG: printf("MD_READDOG\n"); if(request.dog_password == curr_dog.dog_password){ memcpy(&response.dog_data, curr_dog.dog_flashmem+request.dog_addr,request.dog_bytes); }else{ response.return_code = MD_ERR_PW; } break; case MD_WRITEDOG: printf("MD_WRITEDOG\n"); if(request.dog_password == curr_dog.dog_password){ memcpy(curr_dog.dog_flashmem+request.dog_addr,&request.dog_data,request.dog_bytes); fseek(dogfile,0,SEEK_SET); fwrite(&curr_dog,224,1,dogfile); }else{ response.return_code = MD_ERR_PW; } break; case MD_CONVERT: printf("MD_CONVERT\n"); unsigned long dog_response = convert(request.dog_bytes,request.dog_data); memcpy(&response.dog_data,&dog_response,4); break; case MD_SETPASSWORD: printf("MD_SETPASSWORD\n"); if(request.dog_password == curr_dog.dog_password){ curr_dog.dog_password = *(unsigned long *)request.dog_data; fseek(dogfile,0,SEEK_SET); fwrite(&curr_dog,224,1,dogfile); }else{ response.return_code = MD_ERR_PW; } break; case MD_SETSHARE: printf("MD_SETSHARE\n"); b_share = request.dog_data[0]; response.dog_data[0] = b_share; break; case MD_GETLOCKNO: printf("MD_GETLOCKNO\n"); memcpy(&response.dog_data,curr_dog.mfg_serial,4); break; case MD_LOGIN: printf("MD_LOGIN\n"); int j; for(j=0;j<8;j++){ response.dog_data[j] = curr_dog.vendor_id[j]; } break; case MD_SETDOGCASCADE: printf("MD_SETDOGCASCADE\n"); response.dog_data[0] = request.dog_data[0]; break; case MD_RTADD: printf("MD_RTADD\n"); add_rtkey(request.dog_data,request.dog_bytes,request.dog_password); break; case MD_SETDOGSERIAL: printf("MD_SETDOGSERIAL\n"); set_dog_serial(request.dog_data); break; case MD_SETMFGSERIAL: printf("MD_SETMFGSERIAL\n"); set_mfg_serial(request.dog_data); break; case MD_SETVID: printf("MD_SETVID\n"); set_vendor_id(request.dog_data); break; case MD_RLRT: printf("MD_RLRT\n"); load_dogfile(); break; default: printf("Unsupported Opcode: %04X\n",request.opcode); break; } if(DEBUG){ print_resp(&response); } crypt_response(&request,&response); //Copy the response packet to the program. memcpy(*(unsigned int *)data-272,&response,208); return 0; } //Any other ioctl, we don't care about. realIOCTL(fd,request,data); }