Commit ad72d312 authored by garciay's avatar garciay
Browse files

Add Brainpool Security support

parent 102e454e
Loading
Loading
Loading
Loading
+4 −4
Changes for ttcn/TestCodec/TestCodec_Certificates.ttcn: 4 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@ module TestCodec_Certificates {
    var octetstring v_sig := ''O;
    var bitstring v_encMsg := ''B;

    if (f_generate_key_pair(v_private_key, v_publicKeyX, v_publicKeyY) == false) {
    if (f_generate_key_pair_nistp256(v_private_key, v_publicKeyX, v_publicKeyY) == false) {
      setverdict(fail);
      stop;
    }
@@ -117,7 +117,7 @@ module TestCodec_Certificates {
    var octetstring v_sig := ''O;
    var bitstring v_encMsg := ''B;

    if (f_generate_key_pair(v_private_key, v_publicKeyX, v_publicKeyY) == false) {
    if (f_generate_key_pair_nistp256(v_private_key, v_publicKeyX, v_publicKeyY) == false) {
      setverdict(fail);
      stop;
    }
@@ -201,7 +201,7 @@ module TestCodec_Certificates {
    var bitstring v_encMsg := ''B;
      
    // Generate Private/Public keys
    f_generate_key_pair(v_private_key, v_publicKeyX, v_publicKeyX);
    f_generate_key_pair_nistp256(v_private_key, v_publicKeyX, v_publicKeyX);
    // Store Private key in binary format
    //f_save_key(v_private_key);
    // Fill Certificate template with the public key      
@@ -264,7 +264,7 @@ module TestCodec_Certificates {
    var octetstring v_exp_enc_msg := '80030080AF232618BE5E6F55B0811876656869636C652D746573742E6578616D706C652E636F6D5E6F5B0002010A8F1C86000A83010280000C800022010180012381038300010102E08101020100C0E0800102800123818002010081010101000080808208C3C070B040C040108033070D0501CE0C0A0806017B00F030D203EA04BE0903808008B2030104020A0D010C0105C0F80BB1460239348D17405C1A845151D40612002617CF4E6B25097F03F502AD0C6F2F125974700D31A60FD1EF12040E4D8231AB'O;
      
    // Generate Private/Public keys
    f_generate_key_pair(v_private_key, v_publicKeyX, v_publicKeyX);
    f_generate_key_pair_nistp256(v_private_key, v_publicKeyX, v_publicKeyX);
    // Store Private key in binary format
    //f_save_key(v_private_key);
    // Fill Certificate template with the public key      
+62 −5
Changes for ttcn/TestCodec/TestCodec_SecuredFuntions.ttcn: 62 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -64,16 +64,49 @@ module TestCodec_SecuredFuntions {
      var Oct32 v_publicKeyX;
      var Oct32 v_publicKeyY;

      if (f_generate_key_pair(v_private_key, v_publicKeyX, v_publicKeyY) == false) {
      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);
      
      setverdict(pass);
    } // End of test tc_f_generate_key_pair_1

    testcase tc_f_generate_key_pair_2() runs on TCType system TCType {
      var Oct32 v_private_key;
      var Oct32 v_publicKeyX;
      var Oct32 v_publicKeyY;

      if (f_generate_key_pair_brainpoolp256(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);
      
      setverdict(pass);
    } // End of test tc_f_generate_key_pair_2

    testcase tc_f_generate_key_pair_3() runs on TCType system TCType {
      var Oct48 v_private_key;
      var Oct48 v_publicKeyX;
      var Oct48 v_publicKeyY;

      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);
      
      setverdict(pass);
    } // End of test tc_f_generate_key_pair_3

    testcase tc_f_signWithEcdsaNistp256WithSha256_1() runs on TCType system TCType {
      var Oct32 v_private_key;
      var Oct32 v_publicKeyX;
@@ -81,7 +114,7 @@ module TestCodec_SecuredFuntions {
      var octetstring v_encMsg := '0A0A0102030405060708090A0B0C0D0E0F0A0A'O; 
      var octetstring v_sig := ''O;

      if (f_generate_key_pair(v_private_key, v_publicKeyX, v_publicKeyY) == false) {
      if (f_generate_key_pair_nistp256(v_private_key, v_publicKeyX, v_publicKeyY) == false) {
        setverdict(fail);
        stop;
      }
@@ -105,7 +138,7 @@ module TestCodec_SecuredFuntions {
      var octetstring v_encMsg := '0A0A0102030405060708090A0B0C0D0E0F0A0A'O; 
      var octetstring v_sig := ''O;

      if (f_generate_key_pair(v_private_key, v_publicKeyX, v_publicKeyY) == false) {
      if (f_generate_key_pair_nistp256(v_private_key, v_publicKeyX, v_publicKeyY) == false) {
        setverdict(fail);
        stop;
      }
@@ -135,7 +168,7 @@ module TestCodec_SecuredFuntions {
      var octetstring v_encMsg := '0A0A0102030405060708090A0B0C0D0E0F0A0A'O; 
      var octetstring v_sig := ''O;

      if (f_generate_key_pair(v_private_key, v_publicKeyX, v_publicKeyY) == false) {
      if (f_generate_key_pair_nistp256(v_private_key, v_publicKeyX, v_publicKeyY) == false) {
        setverdict(fail);
        stop;
      }
@@ -182,7 +215,7 @@ module TestCodec_SecuredFuntions {
      var Oct32 v_publicKeyX_wrong;
      var Oct32 v_publicKeyY_wrong;

      if (f_generate_key_pair(v_private_key, v_publicKeyX, v_publicKeyY) == false) {
      if (f_generate_key_pair_nistp256(v_private_key, v_publicKeyX, v_publicKeyY) == false) {
        setverdict(fail);
        stop;
      }
@@ -225,4 +258,28 @@ module TestCodec_SecuredFuntions {
      setverdict(pass);
    } // End of test tc_f_verifyWithEcdsaNistp256WithSha256_3

    testcase tc_f_signWithEcdsaBrainpoolp256WithSha256_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_brainpoolp256(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;
      }
      
      setverdict(pass);
    } // End of test tc_f_signWithEcdsaBrainpoolp256WithSha256_1

} // End of module TestCodec_SecuredFuntions 
+37 −1
Changes for ttcn/TestCodec/TestCodec_SecuredMessages.ttcn: 37 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -30,6 +30,42 @@ module TestCodec_SecuredMessages {
    // TestCodec
    import from TestCodec_TestAndSystem all;
    
    testcase tc_ssp_cam() runs on TCType system TCType {
        var SspCAM v_sspCAM := valueof(m_sspCAMContainer_sign_all);
        var bitstring v_encMsg;
        
        v_encMsg := encvalue(valueof(v_sspCAM));
        if (lengthof(v_encMsg) != 32) {
            setverdict(fail);
        } else {
            var SspCAM v_sspCAM_dec;
            if (decvalue(v_encMsg, v_sspCAM_dec) != 0) {
                setverdict(fail);
            } else if (not(match(v_sspCAM_dec, v_sspCAM))) {
            } else {
                setverdict(pass);
            }
        }
    }
    
    testcase tc_ssp_denm() runs on TCType system TCType {
        var SspDENM v_sspDENM := valueof(m_sspDENMContainer_sign_all);
        var bitstring v_encMsg;
        
        v_encMsg := encvalue(valueof(v_sspDENM));
        if (lengthof(v_encMsg) != 32) {
            setverdict(fail);
        } else {
            var SspDENM v_sspDENM_dec;
            if (decvalue(v_encMsg, v_sspDENM_dec) != 0) {
                setverdict(fail);
            } else if (not(match(v_sspDENM_dec, v_sspDENM))) {
            } else {
                setverdict(pass);
            }
        }
    }
    
    testcase tc_secured_message_unsecured() runs on TCType system TCType {
        var template (value) EtsiTs103097Data v_secured_data;
        var bitstring v_encMsg;
@@ -37,7 +73,7 @@ module TestCodec_SecuredMessages {
        v_secured_data := m_etsiTs103097Data_unsecured(
                                                   'CAFEDECA'O
                                                  );
        //v_encMsg := encvalue(v_secured_data);
        v_encMsg := encvalue(v_secured_data);
      
        setverdict(pass, "Encoding passed.");
    }