Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8364121

DESKeySpec.isWeak does not check negative offset

XMLWordPrintable

      A DESCRIPTION OF THE PROBLEM :
      DESKeySpec.isWeak doesn't check negative offset and throws ArrayIndexOutOfBoundsException

      ACTUAL -
      Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 8
      at java.base/javax.crypto.spec.DESKeySpec.isWeak(DESKeySpec.java:230)

      ---------- BEGIN SOURCE ----------
          public static void main(String[] args) throws Exception {

              byte[] strongKey = {
                  (byte)0x12, (byte)0x34, (byte)0x56, (byte)0x78,
                  (byte)0x9A, (byte)0xBC, (byte)0xDE, (byte)0xF0
              };
              try {
                  DESKeySpec.isWeak(strongKey, -1);
                  System.out.println("Error: Negative offset didn't throw InvalidKeyException");
              } catch (InvalidKeyException e) {

              }
          }
      ---------- END SOURCE ----------

            kdriver Kevin Driver
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: