< prev index next >

test/jdk/sun/security/pkcs11/Cipher/TestKATForGCM.java

Print this page
rev 59383 : [mq]: final
   1 /*
   2  * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */


 308     public void main(Provider p) throws Exception {
 309         Cipher c;
 310         String transformation = "AES/GCM/NoPadding";
 311         try {
 312             c = Cipher.getInstance(transformation, p);
 313         } catch (GeneralSecurityException e) {
 314             System.out.println("Skip testing " + p.getName() +
 315                     ", no support for " + transformation);
 316             return;
 317         }
 318         try {
 319             if (execute(testValues, c)) {
 320                 System.out.println("Test Passed!");
 321             }
 322         } catch (Exception e) {
 323             System.out.println("Exception occured using " + p.getName() + " version " + p.getVersionStr());
 324 
 325             if (isNSS(p)) {
 326                 double ver = getNSSInfo("nss");
 327                 String osName = System.getProperty("os.name");
 328                 if (ver < 3.251d && osName.equals("SunOS")) {
 329                     // buggy behaviour from solaris on 11.2 OS (nss < 3.251)
 330                     System.out.println("Skipping: SunPKCS11-NSS: Old NSS: " + ver);
 331                     return; // OK
 332                 } else if (ver > 3.139 && ver < 3.15 && osName.equals("Linux")) {
 333                     // warn about buggy behaviour on Linux with nss 3.14
 334                     System.out.println("Warning: old NSS " + ver + " might be problematic, consider upgrading it");
 335                 }
 336             }
 337             throw e;
 338         }
 339     }
 340 }
 341 
   1 /*
   2  * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */


 308     public void main(Provider p) throws Exception {
 309         Cipher c;
 310         String transformation = "AES/GCM/NoPadding";
 311         try {
 312             c = Cipher.getInstance(transformation, p);
 313         } catch (GeneralSecurityException e) {
 314             System.out.println("Skip testing " + p.getName() +
 315                     ", no support for " + transformation);
 316             return;
 317         }
 318         try {
 319             if (execute(testValues, c)) {
 320                 System.out.println("Test Passed!");
 321             }
 322         } catch (Exception e) {
 323             System.out.println("Exception occured using " + p.getName() + " version " + p.getVersionStr());
 324 
 325             if (isNSS(p)) {
 326                 double ver = getNSSInfo("nss");
 327                 String osName = System.getProperty("os.name");
 328                 if (ver > 3.139 && ver < 3.15 && osName.equals("Linux")) {




 329                     // warn about buggy behaviour on Linux with nss 3.14
 330                     System.out.println("Warning: old NSS " + ver + " might be problematic, consider upgrading it");
 331                 }
 332             }
 333             throw e;
 334         }
 335     }
 336 }
 337 
< prev index next >