116 } |
116 } |
117 |
117 |
118 // initialize for signing. See JCA doc |
118 // initialize for signing. See JCA doc |
119 @Override |
119 @Override |
120 protected void engineInitSign(PrivateKey key) throws InvalidKeyException { |
120 protected void engineInitSign(PrivateKey key) throws InvalidKeyException { |
121 |
121 if (key == null) { |
|
122 throw new InvalidKeyException("Key cannot be null"); |
|
123 } |
122 if ((key instanceof CPrivateKey) == false |
124 if ((key instanceof CPrivateKey) == false |
123 || !key.getAlgorithm().equalsIgnoreCase("RSA")) { |
125 || !key.getAlgorithm().equalsIgnoreCase("RSA")) { |
124 throw new InvalidKeyException("Key type not supported: " |
126 throw new InvalidKeyException("Key type not supported: " |
125 + key.getClass() + " " + key.getAlgorithm()); |
127 + key.getClass() + " " + key.getAlgorithm()); |
126 } |
128 } |
137 } |
139 } |
138 |
140 |
139 // initialize for signing. See JCA doc |
141 // initialize for signing. See JCA doc |
140 @Override |
142 @Override |
141 protected void engineInitVerify(PublicKey key) throws InvalidKeyException { |
143 protected void engineInitVerify(PublicKey key) throws InvalidKeyException { |
|
144 if (key == null) { |
|
145 throw new InvalidKeyException("Key cannot be null"); |
|
146 } |
142 // This signature accepts only RSAPublicKey |
147 // This signature accepts only RSAPublicKey |
143 if ((key instanceof RSAPublicKey) == false) { |
148 if ((key instanceof RSAPublicKey) == false) { |
144 throw new InvalidKeyException("Key type not supported"); |
149 throw new InvalidKeyException("Key type not supported: " |
|
150 + key.getClass()); |
145 } |
151 } |
146 |
152 |
147 |
153 |
148 if ((key instanceof CPublicKey) == false) { |
154 if ((key instanceof CPublicKey) == false) { |
149 |
155 |
425 } |
431 } |
426 |
432 |
427 // initialize for signing. See JCA doc |
433 // initialize for signing. See JCA doc |
428 @Override |
434 @Override |
429 protected void engineInitSign(PrivateKey key) throws InvalidKeyException { |
435 protected void engineInitSign(PrivateKey key) throws InvalidKeyException { |
|
436 if (key == null) { |
|
437 throw new InvalidKeyException("Key cannot be null"); |
|
438 } |
430 if ((key instanceof CPrivateKey) == false |
439 if ((key instanceof CPrivateKey) == false |
431 || !key.getAlgorithm().equalsIgnoreCase("EC")) { |
440 || !key.getAlgorithm().equalsIgnoreCase("EC")) { |
432 throw new InvalidKeyException("Key type not supported"); |
441 throw new InvalidKeyException("Key type not supported: " |
|
442 + key.getClass() + " " + key.getAlgorithm()); |
433 } |
443 } |
434 privateKey = (CPrivateKey) key; |
444 privateKey = (CPrivateKey) key; |
435 |
445 |
436 this.publicKey = null; |
446 this.publicKey = null; |
437 resetDigest(); |
447 resetDigest(); |
438 } |
448 } |
439 |
449 |
440 // initialize for signing. See JCA doc |
450 // initialize for signing. See JCA doc |
441 @Override |
451 @Override |
442 protected void engineInitVerify(PublicKey key) throws InvalidKeyException { |
452 protected void engineInitVerify(PublicKey key) throws InvalidKeyException { |
|
453 if (key == null) { |
|
454 throw new InvalidKeyException("Key cannot be null"); |
|
455 } |
443 // This signature accepts only ECPublicKey |
456 // This signature accepts only ECPublicKey |
444 if ((key instanceof ECPublicKey) == false) { |
457 if ((key instanceof ECPublicKey) == false) { |
445 throw new InvalidKeyException("Key type not supported"); |
458 throw new InvalidKeyException("Key type not supported: " |
446 } |
459 + key.getClass()); |
447 |
460 } |
448 |
461 |
449 if ((key instanceof CPublicKey) == false) { |
462 if ((key instanceof CPublicKey) == false) { |
450 try { |
463 try { |
451 publicKey = importECPublicKey("EC", |
464 publicKey = importECPublicKey("EC", |
452 CKey.generateECBlob(key), |
465 CKey.generateECBlob(key), |
506 fallbackSignature = null; |
519 fallbackSignature = null; |
507 } |
520 } |
508 |
521 |
509 @Override |
522 @Override |
510 protected void engineInitVerify(PublicKey key) throws InvalidKeyException { |
523 protected void engineInitVerify(PublicKey key) throws InvalidKeyException { |
|
524 if (key == null) { |
|
525 throw new InvalidKeyException("Key cannot be null"); |
|
526 } |
511 // This signature accepts only RSAPublicKey |
527 // This signature accepts only RSAPublicKey |
512 if ((key instanceof java.security.interfaces.RSAPublicKey) == false) { |
528 if ((key instanceof java.security.interfaces.RSAPublicKey) == false) { |
513 throw new InvalidKeyException("Key type not supported"); |
529 throw new InvalidKeyException("Key type not supported: " |
|
530 + key.getClass()); |
514 } |
531 } |
515 |
532 |
516 this.privateKey = null; |
533 this.privateKey = null; |
517 |
534 |
518 if (key instanceof CPublicKey) { |
535 if (key instanceof CPublicKey) { |