equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
392 } |
392 } |
393 if (mechInfo == null) { |
393 if (mechInfo == null) { |
394 // skip the check if no native info available |
394 // skip the check if no native info available |
395 return; |
395 return; |
396 } |
396 } |
397 int minKeySize = (int) mechInfo.ulMinKeySize; |
397 int minKeySize = mechInfo.iMinKeySize; |
398 int maxKeySize = (int) mechInfo.ulMaxKeySize; |
398 int maxKeySize = mechInfo.iMaxKeySize; |
|
399 |
399 // need to override the MAX keysize for SHA1withDSA |
400 // need to override the MAX keysize for SHA1withDSA |
400 if (md != null && mechanism == CKM_DSA && maxKeySize > 1024) { |
401 if (md != null && mechanism == CKM_DSA && maxKeySize > 1024) { |
401 maxKeySize = 1024; |
402 maxKeySize = 1024; |
402 } |
403 } |
403 int keySize = 0; |
404 int keySize = 0; |
417 } catch (ClassCastException cce) { |
418 } catch (ClassCastException cce) { |
418 throw new InvalidKeyException(keyAlgo + |
419 throw new InvalidKeyException(keyAlgo + |
419 " key must be the right type", cce); |
420 " key must be the right type", cce); |
420 } |
421 } |
421 } |
422 } |
422 if ((minKeySize != -1) && (keySize < minKeySize)) { |
423 if (keySize < minKeySize) { |
423 throw new InvalidKeyException(keyAlgo + |
424 throw new InvalidKeyException(keyAlgo + |
424 " key must be at least " + minKeySize + " bits"); |
425 " key must be at least " + minKeySize + " bits"); |
425 } |
426 } |
426 if ((maxKeySize != -1) && (keySize > maxKeySize)) { |
427 if (keySize > maxKeySize) { |
427 throw new InvalidKeyException(keyAlgo + |
428 throw new InvalidKeyException(keyAlgo + |
428 " key must be at most " + maxKeySize + " bits"); |
429 " key must be at most " + maxKeySize + " bits"); |
429 } |
430 } |
430 if (keyAlgo.equals("RSA")) { |
431 if (keyAlgo.equals("RSA")) { |
431 checkRSAKeyLength(keySize); |
432 checkRSAKeyLength(keySize); |