Commit 19e238ea authored by garciay's avatar garciay
Browse files

Add Brainpool Security support

parent 36a04d69
Loading
Loading
Loading
Loading
+278 −0
Original line number Diff line number Diff line
@@ -282,4 +282,282 @@ module TestCodec_SecuredFuntions {
      setverdict(pass);
    } // End of test tc_f_signWithEcdsaBrainpoolp256WithSha256_1

    testcase tc_f_signWithEcdsaBrainpoolp384WithSha384_1() runs on TCType system TCType {
      var Oct48 v_private_key;
      var Oct48 v_publicKeyX;
      var Oct48 v_publicKeyY;
      var octetstring v_encMsg := '0A0A0102030405060708090A0B0C0D0E0F0A0A'O; 
      var octetstring v_sig := ''O;

      if (f_generate_key_pair_brainpoolp384(v_private_key, v_publicKeyX, v_publicKeyY) == false) {
        setverdict(fail);
        stop;
      }
      log("v_private_key = ", v_private_key);
      log("v_public_key X= ", v_publicKeyX);
      log("v_public_key Y= ", v_publicKeyY);
        
      v_sig := f_signWithEcdsaBrainpoolp384WithSha384(v_encMsg, v_private_key);  
      if (lengthof(v_sig) == 0) {
        setverdict(fail);
        stop;
      }
      
      setverdict(pass);
    } // End of test tc_f_signWithEcdsaBrainpoolp384WithSha384_1

    testcase tc_f_verifyWithEcdsaBrainpoolp256WithSha256_1() runs on TCType system TCType {
      var Oct32 v_private_key;
      var Oct32 v_publicKeyX;
      var Oct32 v_publicKeyY;
      var octetstring v_encMsg := '0A0A0102030405060708090A0B0C0D0E0F0A0A'O; 
      var octetstring v_sig := ''O;

      if (f_generate_key_pair_nistp256(v_private_key, v_publicKeyX, v_publicKeyY) == false) {
        setverdict(fail);
        stop;
      }
      log("v_private_key = ", v_private_key);
      log("v_public_key X= ", v_publicKeyX);
      log("v_public_key Y= ", v_publicKeyY);
        
      v_sig := f_signWithEcdsaBrainpoolp256WithSha256(v_encMsg, v_private_key);  
      if (lengthof(v_sig) == 0) {
        setverdict(fail);
        stop;
      }
      
      if (f_verifyWithEcdsaBrainpoolp256WithSha256(v_encMsg, v_sig, v_publicKeyX, v_publicKeyY) == false) {
        setverdict(fail);
        stop;
      } else {
        setverdict(pass);
      }
    } // End of test tc_f_verifyWithEcdsaBrainpoolp256WithSha256_1

    testcase tc_f_verifyWithEcdsaBrainpoolp256WithSha256_2() runs on TCType system TCType {
      var Oct32 v_private_key;
      var Oct32 v_publicKeyX;
      var Oct32 v_publicKeyY;
      var Oct32 v_private_key_wrong;
      var octetstring v_encMsg := '0A0A0102030405060708090A0B0C0D0E0F0A0A'O; 
      var octetstring v_sig := ''O;

      if (f_generate_key_pair_nistp256(v_private_key, v_publicKeyX, v_publicKeyY) == false) {
        setverdict(fail);
        stop;
      }
      log("v_private_key = ", v_private_key);
      log("v_public_key X= ", v_publicKeyX);
      log("v_public_key Y= ", v_publicKeyY);
      
      v_private_key_wrong := v_private_key;
        
      v_sig := f_signWithEcdsaBrainpoolp256WithSha256(v_encMsg, v_private_key);  
      if (lengthof(v_sig) == 0) {
        setverdict(fail);
        stop;
      }
      
      if (f_verifyWithEcdsaBrainpoolp256WithSha256(v_encMsg, v_sig, v_publicKeyX, v_publicKeyY) == false) {
        setverdict(fail);
        stop;
      } else {
        setverdict(pass);
      }
      
      v_private_key_wrong[2] := 'AA'O;
      v_sig := f_signWithEcdsaBrainpoolp256WithSha256(v_encMsg, v_private_key_wrong);  
      if (lengthof(v_sig) == 0) {
        setverdict(fail);
        stop;
      }
      if (f_verifyWithEcdsaBrainpoolp256WithSha256(v_encMsg, v_sig, v_publicKeyX, v_publicKeyY) == true) {
        setverdict(fail);
        stop;
      } else {
        setverdict(pass);
      }
    } // End of test tc_f_verifyWithEcdsaBrainpoolp256WithSha256_2

    testcase tc_f_verifyWithEcdsaBrainpoolp256WithSha256_3() runs on TCType system TCType {
      var Oct32 v_private_key;
      var Oct32 v_publicKeyX;
      var Oct32 v_publicKeyY;
      var octetstring v_encMsg := '0A0A0102030405060708090A0B0C0D0E0F0A0A'O; 
      var octetstring v_sig := ''O;
      var octetstring v_sig_wrong := ''O;
      var Oct32 v_publicKeyX_wrong;
      var Oct32 v_publicKeyY_wrong;

      if (f_generate_key_pair_nistp256(v_private_key, v_publicKeyX, v_publicKeyY) == false) {
        setverdict(fail);
        stop;
      }
      log("v_private_key = ", v_private_key);
      log("v_public_key X= ", v_publicKeyX);
      log("v_public_key Y= ", v_publicKeyY);
        
      v_sig := f_signWithEcdsaBrainpoolp256WithSha256(v_encMsg, v_private_key);  
      if (f_verifyWithEcdsaBrainpoolp256WithSha256(v_encMsg, v_sig, v_publicKeyX, v_publicKeyY) == false) {
        setverdict(fail);
        stop;
      }
      
      if (f_verifyWithEcdsaBrainpoolp256WithSha256('0A0A0A0A'O, v_sig, v_publicKeyX, v_publicKeyY) == true) {
        setverdict(fail);
        stop;
      }
      
      v_sig_wrong := v_sig;
      v_sig_wrong[0] := 'FF'O;
      if (f_verifyWithEcdsaBrainpoolp256WithSha256(v_encMsg, v_sig_wrong, v_publicKeyX, v_publicKeyY) == true) {
        setverdict(fail);
        stop;
      }
      
      v_publicKeyX_wrong := v_publicKeyX;
      v_publicKeyX_wrong[0] := 'FF'O;
      if (f_verifyWithEcdsaBrainpoolp256WithSha256(v_encMsg, v_sig, v_publicKeyX_wrong, v_publicKeyY) == true) {
        setverdict(fail);
        stop;
      }
      
      v_publicKeyY_wrong := v_publicKeyY;
      v_publicKeyY_wrong[0] := 'FF'O;
      if (f_verifyWithEcdsaBrainpoolp256WithSha256(v_encMsg, v_sig, v_publicKeyX, v_publicKeyY_wrong) == true) {
        setverdict(fail);
        stop;
      }
      
      setverdict(pass);
    } // End of test tc_f_verifyWithEcdsaBrainpoolp256WithSha256_3

    testcase tc_f_verifyWithEcdsaBrainpoolp384WithSha384_1() runs on TCType system TCType {
      var Oct48 v_private_key;
      var Oct48 v_publicKeyX;
      var Oct48 v_publicKeyY;
      var octetstring v_encMsg := '0A0A0102030405060708090A0B0C0D0E0F0A0A'O; 
      var octetstring v_sig := ''O;

      if (f_generate_key_pair_brainpoolp384(v_private_key, v_publicKeyX, v_publicKeyY) == false) {
        setverdict(fail);
        stop;
      }
      log("v_private_key = ", v_private_key);
      log("v_public_key X= ", v_publicKeyX);
      log("v_public_key Y= ", v_publicKeyY);
        
      v_sig := f_signWithEcdsaBrainpoolp384WithSha384(v_encMsg, v_private_key);  
      if (lengthof(v_sig) == 0) {
        setverdict(fail);
        stop;
      }
      
      if (f_verifyWithEcdsaBrainpoolp384WithSha384(v_encMsg, v_sig, v_publicKeyX, v_publicKeyY) == false) {
        setverdict(fail);
        stop;
      } else {
        setverdict(pass);
      }
    } // End of test tc_f_verifyWithEcdsaBrainpoolp384WithSha384_1

    testcase tc_f_verifyWithEcdsaBrainpoolp384WithSha384_2() runs on TCType system TCType {
      var Oct48 v_private_key;
      var Oct48 v_publicKeyX;
      var Oct48 v_publicKeyY;
      var Oct48 v_private_key_wrong;
      var octetstring v_encMsg := '0A0A0102030405060708090A0B0C0D0E0F0A0A'O; 
      var octetstring v_sig := ''O;

      if (f_generate_key_pair_brainpoolp384(v_private_key, v_publicKeyX, v_publicKeyY) == false) {
        setverdict(fail);
        stop;
      }
      log("v_private_key = ", v_private_key);
      log("v_public_key X= ", v_publicKeyX);
      log("v_public_key Y= ", v_publicKeyY);
      
      v_private_key_wrong := v_private_key;
        
      v_sig := f_signWithEcdsaBrainpoolp384WithSha384(v_encMsg, v_private_key);  
      if (lengthof(v_sig) == 0) {
        setverdict(fail);
        stop;
      }
      
      if (f_verifyWithEcdsaBrainpoolp384WithSha384(v_encMsg, v_sig, v_publicKeyX, v_publicKeyY) == false) {
        setverdict(fail);
        stop;
      } else {
        setverdict(pass);
      }
      
      v_private_key_wrong[2] := 'AA'O;
      v_sig := f_signWithEcdsaBrainpoolp384WithSha384(v_encMsg, v_private_key_wrong);  
      if (lengthof(v_sig) == 0) {
        setverdict(fail);
        stop;
      }
      if (f_verifyWithEcdsaBrainpoolp384WithSha384(v_encMsg, v_sig, v_publicKeyX, v_publicKeyY) == true) {
        setverdict(fail);
        stop;
      } else {
        setverdict(pass);
      }
    } // End of test tc_f_verifyWithEcdsaBrainpoolp384WithSha384_2

    testcase tc_f_verifyWithEcdsaBrainpoolp384WithSha384_3() runs on TCType system TCType {
      var Oct48 v_private_key;
      var Oct48 v_publicKeyX;
      var Oct48 v_publicKeyY;
      var octetstring v_encMsg := '0A0A0102030405060708090A0B0C0D0E0F0A0A'O; 
      var octetstring v_sig := ''O;
      var octetstring v_sig_wrong := ''O;
      var Oct48 v_publicKeyX_wrong;
      var Oct48 v_publicKeyY_wrong;

      if (f_generate_key_pair_brainpoolp384(v_private_key, v_publicKeyX, v_publicKeyY) == false) {
        setverdict(fail);
        stop;
      }
      log("v_private_key = ", v_private_key);
      log("v_public_key X= ", v_publicKeyX);
      log("v_public_key Y= ", v_publicKeyY);
        
      v_sig := f_signWithEcdsaBrainpoolp384WithSha384(v_encMsg, v_private_key);  
      if (f_verifyWithEcdsaBrainpoolp384WithSha384(v_encMsg, v_sig, v_publicKeyX, v_publicKeyY) == false) {
        setverdict(fail);
        stop;
      }
      
      if (f_verifyWithEcdsaBrainpoolp384WithSha384('0A0A0A0A'O, v_sig, v_publicKeyX, v_publicKeyY) == true) {
        setverdict(fail);
        stop;
      }
      
      v_sig_wrong := v_sig;
      v_sig_wrong[0] := 'FF'O;
      if (f_verifyWithEcdsaBrainpoolp384WithSha384(v_encMsg, v_sig_wrong, v_publicKeyX, v_publicKeyY) == true) {
        setverdict(fail);
        stop;
      }
      
      v_publicKeyX_wrong := v_publicKeyX;
      v_publicKeyX_wrong[0] := 'FF'O;
      if (f_verifyWithEcdsaBrainpoolp384WithSha384(v_encMsg, v_sig, v_publicKeyX_wrong, v_publicKeyY) == true) {
        setverdict(fail);
        stop;
      }
      
      v_publicKeyY_wrong := v_publicKeyY;
      v_publicKeyY_wrong[0] := 'FF'O;
      if (f_verifyWithEcdsaBrainpoolp384WithSha384(v_encMsg, v_sig, v_publicKeyX, v_publicKeyY_wrong) == true) {
        setverdict(fail);
        stop;
      }
      
      setverdict(pass);
    } // End of test tc_f_verifyWithEcdsaBrainpoolp384WithSha384_3

} // End of module TestCodec_SecuredFuntions