// Copyright (c) The University of Cincinnati. All rights reserved. // UC MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF // THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A // PARTICULAR PURPOSE, OR NON-INFRINGEMENT. UC SHALL NOT BE LIABLE // FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, // RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS // DERIVATIVES. // By using or copying this Software, Licensee agrees to abide by the // intellectual property laws, and all other applicable laws of the // U.S., and the terms of this license. // Author : Antarpreet Singh // #include #include #include #include using namespace std; typedef vector double_vector; typedef vector bool_vector; void DPA_OPB(vector*, vector*, int, vector*, int); void DPA_DOM(int, vector&, vector&, vector*); void DES10(vector *, vector *, vector *); void TEST1(vector *, vector *, vector *); bool DPA_OPB_DOM(int no_of_output_bits, int max_key_comb, int vectors, vector &ptext, vector ¤t_data, vector &diffwf, int *final_key, vector &kg, double *max, int clock_posedge_time_min, int clock_posedge_time_max, int correct_key, ofstream &fplog,string testname,string algorithm) { vector ctext; vector ctext_temp; vector diffwf_temp; int i,j,k; double absmax; bool done; int keyvalue[no_of_output_bits]; for(k=0;k ctext.size()) { cout<<" All the vectors are exhausted. Unable to find key"<<"\n"; fplog<<" All the vectors are exhausted. Unable to find key"<<"\n"; exit(1); } //Perform DPA DPA_OPB(¤t_data,&ctext,k,&diffwf_temp,vectors); diffwf.push_back(diffwf_temp); diffwf_temp.clear(); ctext.clear(); } for(j=0;j max[j]) { *(max+j) = diffwf[j][i]; } } } absmax = *max; keyvalue[k] = 0; for(j=1;j absmax) { absmax = *(max+j); keyvalue[k] = j; } } cout<<"Bit is : "< *current_data, vector *ctext, int bit, vector *diffwf1, int vectors) { vector wf0; vector wf1; vector :: iterator iter_ii; vector :: iterator iter_ii_init; vector :: iterator iter_jj; vector :: iterator iter_cd_i = current_data->begin(); vector :: iterator iter_cd_j = iter_cd_i->begin(); iter_ii_init=ctext->begin(); //Power Model for DPA for(iter_ii=ctext->begin(); (iter_ii-iter_ii_init) < vectors; iter_ii++) { iter_jj = iter_ii->begin(); if(*(iter_jj+bit) == 0) { wf0.push_back((*iter_cd_i)); } else if (*(iter_jj+bit) == 1) { wf1.push_back((*iter_cd_i)); } iter_cd_i++; } int no_of_samples_x = (*current_data)[0].size(); int no_of_samples_y = current_data->size()-1; DPA_DOM(no_of_samples_x,wf0,wf1,diffwf1); } /******************************************************************/ void DPA_DOM(int no_of_samples_x, vector &wf0, vector &wf1, vector *diffwf1) { int i,j; double meanwf0[no_of_samples_x]; double meanwf1[no_of_samples_x]; for(i=0;i