#!/usr/bin/perl
#This small perl script is to help in processing the 
#CAVS 3.3 test tool's vst .req files
#use is
# vsttest < reqfile > rspfile

$cipher = INVALID;
@cmdline = ();

while( <> ) {
	$done = 0;
	if( /Key[0-9]* = ([0-9a-f]+)$/ ) {
		push @cmdline, $1;
		#print "mid command line: @cmdline\n";
	} elsif( /DT = ([0-9a-f]+)$/ ) {
		$DT=$1;
	} elsif( /V = ([0-9a-f]+)$/ ) {
		push @cmdline, $1;
		#print "mid command line: @cmdline\n";
		$done = 1;
	} elsif( /\[2-Key TDES\]/ ) {
		$cipher = "TDES2";
		print;
	} elsif( /\[3-Key TDES\]/ ) {
		$cipher = "TDES3";
		print;
	} elsif( /\[AES / ) {
		$cipher = "AES";
		print;
	} elsif( /R = [0-9a-f]+$/ ) {
	} else {
		print;
	}

	if($done == 1) {
		unshift @cmdline, ("./test931", $cipher);
		#print "head command line: @cmdline\n";
		push @cmdline, $DT, "10000";
		#print "final command line: @cmdline\n";
		system(@cmdline);
		@cmdline = ();
	}
}
