Crypto library helper for LoadRunner (experimental)
Usage
- Grab a dll (DecEncDLL.dll) and put in a file system
- Install MC VC++ runtime (9.0 at least)
- Link your Load runner script to the dll
Notice
- cert should be PEM encoded
#defineDEBUG//DEBUG output on#defineMAXPARAM "50000" //max lenght of parsed param
#defineCHECK(p) if(!(p)) {\
lr_error_message("Check (%s) failed -- file %s line %d\n",#p,__FILE__,__LINE__);\
lr_set_transaction_status(LR_STOP);\
goto konec;}
#defineRET(p) if((nret=(p))!=0) {\
lr_error_message("Check for function (%s) failed -- return code %d",#p,nret);\
goto konec;}
#defineFREE(p) free((p));\
(p)=NULL;
#defineINITTT #ifndef DEBUG\
lr_think_time(3);\
#endif
#defineBEFTT #ifndef DEBUG\
lr_think_time(4);\
#endif
#defineBTRAN(x) tran=(x);\
lr_start_transaction((x));
#defineETRAN lr_end_transaction(tran,LR_AUTO);\
tran=NULL;
Action()
{
char*output=NULL,*action=NULL,*viewState=NULL; //for crypto in/outint*size=NULL,i;
charhash[128],nonce[128];
char*buffer=NULL,pom[256],pom2[256],*pom3=NULL,exec[256];
intnret=0;
char*tran=NULL;
intHttpRetCode;
#ifdefDEBUGci_set_debug(ci_this_context, 1, 1); /* turn ON trace & debug */#endifsize=(int*)malloc(sizeof(int));
lr_load_dll(lr_eval_string("c:\\DecEncDLL.dll"));
web_set_max_html_param_len(MAXPARAM); //because of the long param lenght
...
//digestSHA1(char *output[],char input[],int size) -- double SHA1buffer=(char*)malloc(128); // buffer allocationstrcpy(buffer,"login"); //loginstrcat(buffer,"password"); //password#ifdefDEBUGlr_output_message("Buffer: %s\n",buffer); #endifRET(digestSHA1(&output,buffer,strlen(buffer))); //check the return#ifdefDEBUGlr_output_message("HASH1: %s\n",output); //first hash#endifstrcpy(buffer,output);
strcat(buffer,lr_eval_string("{nonce}"));
RET(digestSHA1(&output,buffer,strlen(buffer)));
#ifdefDEBUGlr_output_message("HASH2: %s\n",output); #endifstrcpy(buffer,"Value=");
strcat(buffer,output);
deallocCA(&output); //do not forget to deallocate the memory that has been allocated by dll#ifdefDEBUGlr_output_message("Buffer: %s\n",buffer); #endif