jdk/src/share/classes/sun/security/util/DisabledAlgorithmConstraints.java

Print this page
rev 5679 : 7192392: Better validation of client keys
Summary: Also reviewed by Andrew Gross<Andrew.Gross@Oracle.COM>
Reviewed-by: vinnie


 421                     this.minSize = length + 1;
 422                     this.maxSize = Integer.MAX_VALUE;
 423                     break;
 424                 case GT:
 425                     this.minSize = 0;
 426                     this.maxSize = length;
 427                     break;
 428                 case GE:
 429                     this.minSize = 0;
 430                     this.maxSize = length > 1 ? (length - 1) : 0;
 431                     break;
 432                 default:
 433                     // unlikely to happen
 434                     this.minSize = Integer.MAX_VALUE;
 435                     this.maxSize = -1;
 436             }
 437         }
 438 
 439         // Does this key constraint disable the specified key?
 440         public boolean disables(Key key) {
 441             int size = KeyLength.getKeySize(key);
 442 
 443             if (size == 0) {
 444                 return true;    // we don't allow any key of size 0.
 445             } else if (size > 0) {
 446                 return ((size < minSize) || (size > maxSize) ||
 447                     (prohibitedSize == size));
 448             }   // Otherwise, the key size is not accessible. Conservatively,
 449                 // please don't disable such keys.
 450 
 451             return false;
 452         }
 453     }
 454 
 455 }
 456 


 421                     this.minSize = length + 1;
 422                     this.maxSize = Integer.MAX_VALUE;
 423                     break;
 424                 case GT:
 425                     this.minSize = 0;
 426                     this.maxSize = length;
 427                     break;
 428                 case GE:
 429                     this.minSize = 0;
 430                     this.maxSize = length > 1 ? (length - 1) : 0;
 431                     break;
 432                 default:
 433                     // unlikely to happen
 434                     this.minSize = Integer.MAX_VALUE;
 435                     this.maxSize = -1;
 436             }
 437         }
 438 
 439         // Does this key constraint disable the specified key?
 440         public boolean disables(Key key) {
 441             int size = KeyUtil.getKeySize(key);
 442 
 443             if (size == 0) {
 444                 return true;    // we don't allow any key of size 0.
 445             } else if (size > 0) {
 446                 return ((size < minSize) || (size > maxSize) ||
 447                     (prohibitedSize == size));
 448             }   // Otherwise, the key size is not accessible. Conservatively,
 449                 // please don't disable such keys.
 450 
 451             return false;
 452         }
 453     }
 454 
 455 }
 456