1 package org.bouncycastle.jcajce.provider.asymmetric.ec; 2 3 import java.math.BigInteger; 4 import java.security.InvalidAlgorithmParameterException; 5 import java.security.InvalidKeyException; 6 import java.security.Key; 7 import java.security.PrivateKey; 8 import java.security.PublicKey; 9 import java.security.SecureRandom; 10 import java.security.spec.AlgorithmParameterSpec; 11 12 import org.bouncycastle.asn1.x9.X9IntegerConverter; 13 import org.bouncycastle.crypto.BasicAgreement; 14 import org.bouncycastle.crypto.CipherParameters; 15 import org.bouncycastle.crypto.DerivationFunction; 16 import org.bouncycastle.crypto.agreement.ECDHBasicAgreement; 17 // BEGIN Android-removed: Unsupported algorithms 18 // import org.bouncycastle.crypto.agreement.ECDHCBasicAgreement; 19 // import org.bouncycastle.crypto.agreement.ECDHCUnifiedAgreement; 20 // import org.bouncycastle.crypto.agreement.ECMQVBasicAgreement; 21 // import org.bouncycastle.crypto.agreement.kdf.ConcatenationKDFGenerator; 22 // import org.bouncycastle.crypto.digests.RIPEMD160Digest; 23 // import org.bouncycastle.crypto.generators.KDF2BytesGenerator; 24 // import org.bouncycastle.crypto.params.ECDHUPrivateParameters; 25 // import org.bouncycastle.crypto.params.ECDHUPublicParameters; 26 // END Android-removed: Unsupported algorithms 27 import org.bouncycastle.crypto.params.ECDomainParameters; 28 import org.bouncycastle.crypto.params.ECPrivateKeyParameters; 29 import org.bouncycastle.crypto.params.ECPublicKeyParameters; 30 // BEGIN Android-removed: Unsupported algorithms 31 // import org.bouncycastle.crypto.params.MQVPrivateParameters; 32 // import org.bouncycastle.crypto.params.MQVPublicParameters; 33 // import org.bouncycastle.crypto.util.DigestFactory; 34 // END Android-removed: Unsupported algorithms 35 import org.bouncycastle.jcajce.provider.asymmetric.util.BaseAgreementSpi; 36 import org.bouncycastle.jcajce.provider.asymmetric.util.ECUtil; 37 // BEGIN Android-removed: Unsupported algorithms 38 // import org.bouncycastle.jcajce.spec.DHUParameterSpec; 39 // import org.bouncycastle.jcajce.spec.MQVParameterSpec; 40 // END Android-removed: Unsupported algorithms 41 import org.bouncycastle.jcajce.spec.UserKeyingMaterialSpec; 42 import org.bouncycastle.jce.interfaces.ECPrivateKey; 43 import org.bouncycastle.jce.interfaces.ECPublicKey; 44 // BEGIN Android-removed: Unsupported algorithms 45 // import org.bouncycastle.jce.interfaces.MQVPrivateKey; 46 // import org.bouncycastle.jce.interfaces.MQVPublicKey; 47 // END Android-removed: Unsupported algorithms 48 import org.bouncycastle.util.Arrays; 49 50 /** 51 * Diffie-Hellman key agreement using elliptic curve keys, ala IEEE P1363 52 * both the simple one, and the simple one with cofactors are supported. 53 * <p> 54 * Also, MQV key agreement per SEC-1 55 */ 56 public class KeyAgreementSpi 57 extends BaseAgreementSpi 58 { 59 private static final X9IntegerConverter converter = new X9IntegerConverter(); 60 61 private String kaAlgorithm; 62 63 private ECDomainParameters parameters; 64 private Object agreement; 65 66 // Android-removed: Unsupported algorithms 67 // private MQVParameterSpec mqvParameters; 68 // private DHUParameterSpec dheParameters; 69 private byte[] result; 70 71 protected KeyAgreementSpi( 72 String kaAlgorithm, 73 BasicAgreement agreement, 74 DerivationFunction kdf) 75 { 76 super(kaAlgorithm, kdf); 77 78 this.kaAlgorithm = kaAlgorithm; 79 this.agreement = agreement; 80 } 81 82 // BEGIN Android-removed: Unsupported algorithms 83 /* 84 protected KeyAgreementSpi( 85 String kaAlgorithm, 86 ECDHCUnifiedAgreement agreement, 87 DerivationFunction kdf) 88 { 89 super(kaAlgorithm, kdf); 90 91 this.kaAlgorithm = kaAlgorithm; 92 this.agreement = agreement; 93 } 94 */ 95 // END Android-removed: Unsupported algorithms 96 97 protected byte[] bigIntToBytes( 98 BigInteger r) 99 { 100 return converter.integerToBytes(r, converter.getByteLength(parameters.getCurve())); 101 } 102 103 protected Key engineDoPhase( 104 Key key, 105 boolean lastPhase) 106 throws InvalidKeyException, IllegalStateException 107 { 108 if (parameters == null) 109 { 110 throw new IllegalStateException(kaAlgorithm + " not initialised."); 111 } 112 113 if (!lastPhase) 114 { 115 throw new IllegalStateException(kaAlgorithm + " can only be between two parties."); 116 } 117 118 CipherParameters pubKey; 119 // BEGIN Android-removed: Unsupported algorithms 120 /* 121 if (agreement instanceof ECMQVBasicAgreement) 122 { 123 if (!(key instanceof MQVPublicKey)) 124 { 125 ECPublicKeyParameters staticKey = (ECPublicKeyParameters) 126 ECUtils.generatePublicKeyParameter((PublicKey)key); 127 ECPublicKeyParameters ephemKey = (ECPublicKeyParameters) 128 ECUtils.generatePublicKeyParameter(mqvParameters.getOtherPartyEphemeralKey()); 129 130 pubKey = new MQVPublicParameters(staticKey, ephemKey); 131 } 132 else 133 { 134 MQVPublicKey mqvPubKey = (MQVPublicKey)key; 135 ECPublicKeyParameters staticKey = (ECPublicKeyParameters) 136 ECUtils.generatePublicKeyParameter(mqvPubKey.getStaticKey()); 137 ECPublicKeyParameters ephemKey = (ECPublicKeyParameters) 138 ECUtils.generatePublicKeyParameter(mqvPubKey.getEphemeralKey()); 139 140 pubKey = new MQVPublicParameters(staticKey, ephemKey); 141 } 142 } 143 else if (agreement instanceof ECDHCUnifiedAgreement) 144 { 145 ECPublicKeyParameters staticKey = (ECPublicKeyParameters) 146 ECUtils.generatePublicKeyParameter((PublicKey)key); 147 ECPublicKeyParameters ephemKey = (ECPublicKeyParameters) 148 ECUtils.generatePublicKeyParameter(dheParameters.getOtherPartyEphemeralKey()); 149 150 pubKey = new ECDHUPublicParameters(staticKey, ephemKey); 151 } 152 else 153 */ 154 // END Android-removed: Unsupported algorithms 155 { 156 if (!(key instanceof PublicKey)) 157 { 158 throw new InvalidKeyException(kaAlgorithm + " key agreement requires " 159 + getSimpleName(ECPublicKey.class) + " for doPhase"); 160 } 161 162 pubKey = ECUtils.generatePublicKeyParameter((PublicKey)key); 163 } 164 165 try 166 { 167 // BEGIN Android-removed: Unsupported algorithms 168 /* 169 if (agreement instanceof BasicAgreement) 170 { 171 */ 172 // END Android-removed: Unsupported algorithms 173 result = bigIntToBytes(((BasicAgreement)agreement).calculateAgreement(pubKey)); 174 // BEGIN Android-removed: Unsupported algorithms 175 /* 176 } 177 else 178 { 179 result = ((ECDHCUnifiedAgreement)agreement).calculateAgreement(pubKey); 180 } 181 */ 182 // END Android-removed: Unsupported algorithms 183 } 184 catch (final Exception e) 185 { 186 throw new InvalidKeyException("calculation failed: " + e.getMessage()) 187 { 188 public Throwable getCause() 189 { 190 return e; 191 } 192 }; 193 } 194 195 return null; 196 } 197 198 protected void engineInit( 199 Key key, 200 AlgorithmParameterSpec params, 201 SecureRandom random) 202 throws InvalidKeyException, InvalidAlgorithmParameterException 203 { 204 // Android-removed: Unsupported algorithms 205 // if (params != null && 206 // !(params instanceof MQVParameterSpec || params instanceof UserKeyingMaterialSpec || params instanceof DHUParameterSpec)) 207 if (params != null && !(params instanceof UserKeyingMaterialSpec)) 208 { 209 throw new InvalidAlgorithmParameterException("No algorithm parameters supported"); 210 } 211 212 initFromKey(key, params); 213 } 214 215 protected void engineInit( 216 Key key, 217 SecureRandom random) 218 throws InvalidKeyException 219 { 220 try 221 { 222 initFromKey(key, null); 223 } 224 catch (InvalidAlgorithmParameterException e) 225 { 226 // this should never occur. 227 throw new InvalidKeyException(e.getMessage()); 228 } 229 } 230 231 private void initFromKey(Key key, AlgorithmParameterSpec parameterSpec) 232 throws InvalidKeyException, InvalidAlgorithmParameterException 233 { 234 // BEGIN Android-removed: Unsupported algorithms 235 /* 236 if (agreement instanceof ECMQVBasicAgreement) 237 { 238 mqvParameters = null; 239 if (!(key instanceof MQVPrivateKey) && !(parameterSpec instanceof MQVParameterSpec)) 240 { 241 throw new InvalidAlgorithmParameterException(kaAlgorithm + " key agreement requires " 242 + getSimpleName(MQVParameterSpec.class) + " for initialisation"); 243 } 244 245 ECPrivateKeyParameters staticPrivKey; 246 ECPrivateKeyParameters ephemPrivKey; 247 ECPublicKeyParameters ephemPubKey; 248 if (key instanceof MQVPrivateKey) 249 { 250 MQVPrivateKey mqvPrivKey = (MQVPrivateKey)key; 251 staticPrivKey = (ECPrivateKeyParameters) 252 ECUtil.generatePrivateKeyParameter(mqvPrivKey.getStaticPrivateKey()); 253 ephemPrivKey = (ECPrivateKeyParameters) 254 ECUtil.generatePrivateKeyParameter(mqvPrivKey.getEphemeralPrivateKey()); 255 256 ephemPubKey = null; 257 if (mqvPrivKey.getEphemeralPublicKey() != null) 258 { 259 ephemPubKey = (ECPublicKeyParameters) 260 ECUtils.generatePublicKeyParameter(mqvPrivKey.getEphemeralPublicKey()); 261 } 262 } 263 else 264 { 265 MQVParameterSpec mqvParameterSpec = (MQVParameterSpec)parameterSpec; 266 267 staticPrivKey = (ECPrivateKeyParameters) 268 ECUtil.generatePrivateKeyParameter((PrivateKey)key); 269 ephemPrivKey = (ECPrivateKeyParameters) 270 ECUtil.generatePrivateKeyParameter(mqvParameterSpec.getEphemeralPrivateKey()); 271 272 ephemPubKey = null; 273 if (mqvParameterSpec.getEphemeralPublicKey() != null) 274 { 275 ephemPubKey = (ECPublicKeyParameters) 276 ECUtils.generatePublicKeyParameter(mqvParameterSpec.getEphemeralPublicKey()); 277 } 278 mqvParameters = mqvParameterSpec; 279 ukmParameters = mqvParameterSpec.getUserKeyingMaterial(); 280 } 281 282 MQVPrivateParameters localParams = new MQVPrivateParameters(staticPrivKey, ephemPrivKey, ephemPubKey); 283 this.parameters = staticPrivKey.getParameters(); 284 285 // TODO Validate that all the keys are using the same parameters? 286 287 ((ECMQVBasicAgreement)agreement).init(localParams); 288 } 289 else if (parameterSpec instanceof DHUParameterSpec) 290 { 291 if (!(agreement instanceof ECDHCUnifiedAgreement)) 292 { 293 throw new InvalidAlgorithmParameterException(kaAlgorithm + " key agreement cannot be used with " 294 + getSimpleName(DHUParameterSpec.class)); 295 } 296 DHUParameterSpec dheParameterSpec = (DHUParameterSpec)parameterSpec; 297 ECPrivateKeyParameters staticPrivKey; 298 ECPrivateKeyParameters ephemPrivKey; 299 ECPublicKeyParameters ephemPubKey; 300 301 staticPrivKey = (ECPrivateKeyParameters) 302 ECUtil.generatePrivateKeyParameter((PrivateKey)key); 303 ephemPrivKey = (ECPrivateKeyParameters) 304 ECUtil.generatePrivateKeyParameter(dheParameterSpec.getEphemeralPrivateKey()); 305 306 ephemPubKey = null; 307 if (dheParameterSpec.getEphemeralPublicKey() != null) 308 { 309 ephemPubKey = (ECPublicKeyParameters) 310 ECUtils.generatePublicKeyParameter(dheParameterSpec.getEphemeralPublicKey()); 311 } 312 dheParameters = dheParameterSpec; 313 ukmParameters = dheParameterSpec.getUserKeyingMaterial(); 314 315 ECDHUPrivateParameters localParams = new ECDHUPrivateParameters(staticPrivKey, ephemPrivKey, ephemPubKey); 316 this.parameters = staticPrivKey.getParameters(); 317 318 ((ECDHCUnifiedAgreement)agreement).init(localParams); 319 } 320 else 321 */ 322 // END Android-removed: Unsupported algorithms 323 { 324 if (!(key instanceof PrivateKey)) 325 { 326 throw new InvalidKeyException(kaAlgorithm + " key agreement requires " 327 + getSimpleName(ECPrivateKey.class) + " for initialisation"); 328 } 329 if (kdf == null && parameterSpec instanceof UserKeyingMaterialSpec) 330 { 331 throw new InvalidAlgorithmParameterException("no KDF specified for UserKeyingMaterialSpec"); 332 } 333 ECPrivateKeyParameters privKey = (ECPrivateKeyParameters)ECUtil.generatePrivateKeyParameter((PrivateKey)key); 334 this.parameters = privKey.getParameters(); 335 ukmParameters = (parameterSpec instanceof UserKeyingMaterialSpec) ? ((UserKeyingMaterialSpec)parameterSpec).getUserKeyingMaterial() : null; 336 ((BasicAgreement)agreement).init(privKey); 337 } 338 } 339 340 private static String getSimpleName(Class clazz) 341 { 342 String fullName = clazz.getName(); 343 344 return fullName.substring(fullName.lastIndexOf('.') + 1); 345 } 346 347 protected byte[] calcSecret() 348 { 349 return Arrays.clone(result); 350 } 351 352 public static class DH 353 extends KeyAgreementSpi 354 { 355 public DH() 356 { 357 super("ECDH", new ECDHBasicAgreement(), null); 358 } 359 } 360 361 // BEGIN Android-removed: Unsupported algorithms 362 /* 363 public static class DHC 364 extends KeyAgreementSpi 365 { 366 public DHC() 367 { 368 super("ECDHC", new ECDHCBasicAgreement(), null); 369 } 370 } 371 372 public static class MQV 373 extends KeyAgreementSpi 374 { 375 public MQV() 376 { 377 super("ECMQV", new ECMQVBasicAgreement(), null); 378 } 379 } 380 381 public static class DHUC 382 extends KeyAgreementSpi 383 { 384 public DHUC() 385 { 386 super("ECCDHU", new ECDHCUnifiedAgreement(), null); 387 } 388 } 389 390 public static class DHwithSHA1KDF 391 extends KeyAgreementSpi 392 { 393 public DHwithSHA1KDF() 394 { 395 super("ECDHwithSHA1KDF", new ECDHBasicAgreement(), new KDF2BytesGenerator(DigestFactory.createSHA1())); 396 } 397 } 398 399 public static class DHwithSHA1KDFAndSharedInfo 400 extends KeyAgreementSpi 401 { 402 public DHwithSHA1KDFAndSharedInfo() 403 { 404 super("ECDHwithSHA1KDF", new ECDHBasicAgreement(), new KDF2BytesGenerator(DigestFactory.createSHA1())); 405 } 406 } 407 408 public static class CDHwithSHA1KDFAndSharedInfo 409 extends KeyAgreementSpi 410 { 411 public CDHwithSHA1KDFAndSharedInfo() 412 { 413 super("ECCDHwithSHA1KDF", new ECDHCBasicAgreement(), new KDF2BytesGenerator(DigestFactory.createSHA1())); 414 } 415 } 416 417 public static class DHwithSHA224KDFAndSharedInfo 418 extends KeyAgreementSpi 419 { 420 public DHwithSHA224KDFAndSharedInfo() 421 { 422 super("ECDHwithSHA224KDF", new ECDHBasicAgreement(), new KDF2BytesGenerator(DigestFactory.createSHA224())); 423 } 424 } 425 426 public static class CDHwithSHA224KDFAndSharedInfo 427 extends KeyAgreementSpi 428 { 429 public CDHwithSHA224KDFAndSharedInfo() 430 { 431 super("ECCDHwithSHA224KDF", new ECDHCBasicAgreement(), new KDF2BytesGenerator(DigestFactory.createSHA224())); 432 } 433 } 434 435 public static class DHwithSHA256KDFAndSharedInfo 436 extends KeyAgreementSpi 437 { 438 public DHwithSHA256KDFAndSharedInfo() 439 { 440 super("ECDHwithSHA256KDF", new ECDHBasicAgreement(), new KDF2BytesGenerator(DigestFactory.createSHA256())); 441 } 442 } 443 444 public static class CDHwithSHA256KDFAndSharedInfo 445 extends KeyAgreementSpi 446 { 447 public CDHwithSHA256KDFAndSharedInfo() 448 { 449 super("ECCDHwithSHA256KDF", new ECDHCBasicAgreement(), new KDF2BytesGenerator(DigestFactory.createSHA256())); 450 } 451 } 452 453 public static class DHwithSHA384KDFAndSharedInfo 454 extends KeyAgreementSpi 455 { 456 public DHwithSHA384KDFAndSharedInfo() 457 { 458 super("ECDHwithSHA384KDF", new ECDHBasicAgreement(), new KDF2BytesGenerator(DigestFactory.createSHA384())); 459 } 460 } 461 462 public static class CDHwithSHA384KDFAndSharedInfo 463 extends KeyAgreementSpi 464 { 465 public CDHwithSHA384KDFAndSharedInfo() 466 { 467 super("ECCDHwithSHA384KDF", new ECDHCBasicAgreement(), new KDF2BytesGenerator(DigestFactory.createSHA384())); 468 } 469 } 470 471 public static class DHwithSHA512KDFAndSharedInfo 472 extends KeyAgreementSpi 473 { 474 public DHwithSHA512KDFAndSharedInfo() 475 { 476 super("ECDHwithSHA512KDF", new ECDHBasicAgreement(), new KDF2BytesGenerator(DigestFactory.createSHA512())); 477 } 478 } 479 480 public static class CDHwithSHA512KDFAndSharedInfo 481 extends KeyAgreementSpi 482 { 483 public CDHwithSHA512KDFAndSharedInfo() 484 { 485 super("ECCDHwithSHA512KDF", new ECDHCBasicAgreement(), new KDF2BytesGenerator(DigestFactory.createSHA512())); 486 } 487 } 488 489 public static class MQVwithSHA1KDFAndSharedInfo 490 extends KeyAgreementSpi 491 { 492 public MQVwithSHA1KDFAndSharedInfo() 493 { 494 super("ECMQVwithSHA1KDF", new ECMQVBasicAgreement(), new KDF2BytesGenerator(DigestFactory.createSHA1())); 495 } 496 } 497 498 public static class MQVwithSHA224KDFAndSharedInfo 499 extends KeyAgreementSpi 500 { 501 public MQVwithSHA224KDFAndSharedInfo() 502 { 503 super("ECMQVwithSHA224KDF", new ECMQVBasicAgreement(), new KDF2BytesGenerator(DigestFactory.createSHA224())); 504 } 505 } 506 507 public static class MQVwithSHA256KDFAndSharedInfo 508 extends KeyAgreementSpi 509 { 510 public MQVwithSHA256KDFAndSharedInfo() 511 { 512 super("ECMQVwithSHA256KDF", new ECMQVBasicAgreement(), new KDF2BytesGenerator(DigestFactory.createSHA256())); 513 } 514 } 515 516 public static class MQVwithSHA384KDFAndSharedInfo 517 extends KeyAgreementSpi 518 { 519 public MQVwithSHA384KDFAndSharedInfo() 520 { 521 super("ECMQVwithSHA384KDF", new ECMQVBasicAgreement(), new KDF2BytesGenerator(DigestFactory.createSHA384())); 522 } 523 } 524 525 public static class MQVwithSHA512KDFAndSharedInfo 526 extends KeyAgreementSpi 527 { 528 public MQVwithSHA512KDFAndSharedInfo() 529 { 530 super("ECMQVwithSHA512KDF", new ECMQVBasicAgreement(), new KDF2BytesGenerator(DigestFactory.createSHA512())); 531 } 532 } 533 534 public static class DHwithSHA1CKDF 535 extends KeyAgreementSpi 536 { 537 public DHwithSHA1CKDF() 538 { 539 super("ECDHwithSHA1CKDF", new ECDHCBasicAgreement(), new ConcatenationKDFGenerator(DigestFactory.createSHA1())); 540 } 541 } 542 543 public static class DHwithSHA256CKDF 544 extends KeyAgreementSpi 545 { 546 public DHwithSHA256CKDF() 547 { 548 super("ECDHwithSHA256CKDF", new ECDHCBasicAgreement(), new ConcatenationKDFGenerator(DigestFactory.createSHA256())); 549 } 550 } 551 552 public static class DHwithSHA384CKDF 553 extends KeyAgreementSpi 554 { 555 public DHwithSHA384CKDF() 556 { 557 super("ECDHwithSHA384CKDF", new ECDHCBasicAgreement(), new ConcatenationKDFGenerator(DigestFactory.createSHA384())); 558 } 559 } 560 561 public static class DHwithSHA512CKDF 562 extends KeyAgreementSpi 563 { 564 public DHwithSHA512CKDF() 565 { 566 super("ECDHwithSHA512CKDF", new ECDHCBasicAgreement(), new ConcatenationKDFGenerator(DigestFactory.createSHA512())); 567 } 568 } 569 570 public static class MQVwithSHA1CKDF 571 extends KeyAgreementSpi 572 { 573 public MQVwithSHA1CKDF() 574 { 575 super("ECMQVwithSHA1CKDF", new ECMQVBasicAgreement(), new ConcatenationKDFGenerator(DigestFactory.createSHA1())); 576 } 577 } 578 579 public static class MQVwithSHA224CKDF 580 extends KeyAgreementSpi 581 { 582 public MQVwithSHA224CKDF() 583 { 584 super("ECMQVwithSHA224CKDF", new ECMQVBasicAgreement(), new ConcatenationKDFGenerator(DigestFactory.createSHA224())); 585 } 586 } 587 588 public static class MQVwithSHA256CKDF 589 extends KeyAgreementSpi 590 { 591 public MQVwithSHA256CKDF() 592 { 593 super("ECMQVwithSHA256CKDF", new ECMQVBasicAgreement(), new ConcatenationKDFGenerator(DigestFactory.createSHA256())); 594 } 595 } 596 597 public static class MQVwithSHA384CKDF 598 extends KeyAgreementSpi 599 { 600 public MQVwithSHA384CKDF() 601 { 602 super("ECMQVwithSHA384CKDF", new ECMQVBasicAgreement(), new ConcatenationKDFGenerator(DigestFactory.createSHA384())); 603 } 604 } 605 606 public static class MQVwithSHA512CKDF 607 extends KeyAgreementSpi 608 { 609 public MQVwithSHA512CKDF() 610 { 611 super("ECMQVwithSHA512CKDF", new ECMQVBasicAgreement(), new ConcatenationKDFGenerator(DigestFactory.createSHA512())); 612 } 613 } 614 615 public static class MQVwithSHA1KDF 616 extends KeyAgreementSpi 617 { 618 public MQVwithSHA1KDF() 619 { 620 super("ECMQVwithSHA1KDF", new ECMQVBasicAgreement(), new KDF2BytesGenerator(DigestFactory.createSHA1())); 621 } 622 } 623 624 public static class MQVwithSHA224KDF 625 extends KeyAgreementSpi 626 { 627 public MQVwithSHA224KDF() 628 { 629 super("ECMQVwithSHA224KDF", new ECMQVBasicAgreement(), new KDF2BytesGenerator(DigestFactory.createSHA224())); 630 } 631 } 632 633 public static class MQVwithSHA256KDF 634 extends KeyAgreementSpi 635 { 636 public MQVwithSHA256KDF() 637 { 638 super("ECMQVwithSHA256KDF", new ECMQVBasicAgreement(), new KDF2BytesGenerator(DigestFactory.createSHA256())); 639 } 640 } 641 642 public static class MQVwithSHA384KDF 643 extends KeyAgreementSpi 644 { 645 public MQVwithSHA384KDF() 646 { 647 super("ECMQVwithSHA384KDF", new ECMQVBasicAgreement(), new KDF2BytesGenerator(DigestFactory.createSHA384())); 648 } 649 } 650 651 public static class MQVwithSHA512KDF 652 extends KeyAgreementSpi 653 { 654 public MQVwithSHA512KDF() 655 { 656 super("ECMQVwithSHA512KDF", new ECMQVBasicAgreement(), new KDF2BytesGenerator(DigestFactory.createSHA512())); 657 } 658 } 659 660 public static class DHUwithSHA1CKDF 661 extends KeyAgreementSpi 662 { 663 public DHUwithSHA1CKDF() 664 { 665 super("ECCDHUwithSHA1CKDF", new ECDHCUnifiedAgreement(), new ConcatenationKDFGenerator(DigestFactory.createSHA1())); 666 } 667 } 668 669 public static class DHUwithSHA224CKDF 670 extends KeyAgreementSpi 671 { 672 public DHUwithSHA224CKDF() 673 { 674 super("ECCDHUwithSHA224CKDF", new ECDHCUnifiedAgreement(), new ConcatenationKDFGenerator(DigestFactory.createSHA224())); 675 } 676 } 677 678 public static class DHUwithSHA256CKDF 679 extends KeyAgreementSpi 680 { 681 public DHUwithSHA256CKDF() 682 { 683 super("ECCDHUwithSHA256CKDF", new ECDHCUnifiedAgreement(), new ConcatenationKDFGenerator(DigestFactory.createSHA256())); 684 } 685 } 686 687 public static class DHUwithSHA384CKDF 688 extends KeyAgreementSpi 689 { 690 public DHUwithSHA384CKDF() 691 { 692 super("ECCDHUwithSHA384CKDF", new ECDHCUnifiedAgreement(), new ConcatenationKDFGenerator(DigestFactory.createSHA384())); 693 } 694 } 695 696 public static class DHUwithSHA512CKDF 697 extends KeyAgreementSpi 698 { 699 public DHUwithSHA512CKDF() 700 { 701 super("ECCDHUwithSHA512CKDF", new ECDHCUnifiedAgreement(), new ConcatenationKDFGenerator(DigestFactory.createSHA512())); 702 } 703 } 704 705 public static class DHUwithSHA1KDF 706 extends KeyAgreementSpi 707 { 708 public DHUwithSHA1KDF() 709 { 710 super("ECCDHUwithSHA1KDF", new ECDHCUnifiedAgreement(), new KDF2BytesGenerator(DigestFactory.createSHA1())); 711 } 712 } 713 714 public static class DHUwithSHA224KDF 715 extends KeyAgreementSpi 716 { 717 public DHUwithSHA224KDF() 718 { 719 super("ECCDHUwithSHA224KDF", new ECDHCUnifiedAgreement(), new KDF2BytesGenerator(DigestFactory.createSHA224())); 720 } 721 } 722 723 public static class DHUwithSHA256KDF 724 extends KeyAgreementSpi 725 { 726 public DHUwithSHA256KDF() 727 { 728 super("ECCDHUwithSHA256KDF", new ECDHCUnifiedAgreement(), new KDF2BytesGenerator(DigestFactory.createSHA256())); 729 } 730 } 731 732 public static class DHUwithSHA384KDF 733 extends KeyAgreementSpi 734 { 735 public DHUwithSHA384KDF() 736 { 737 super("ECCDHUwithSHA384KDF", new ECDHCUnifiedAgreement(), new KDF2BytesGenerator(DigestFactory.createSHA384())); 738 } 739 } 740 741 public static class DHUwithSHA512KDF 742 extends KeyAgreementSpi 743 { 744 public DHUwithSHA512KDF() 745 { 746 super("ECCDHUwithSHA512KDF", new ECDHCUnifiedAgreement(), new KDF2BytesGenerator(DigestFactory.createSHA512())); 747 } 748 } 749 750 /** 751 * KeyAgreement according to BSI TR-03111 chapter 4.3.1 752 * 753 public static class ECKAEGwithSHA1KDF 754 extends KeyAgreementSpi 755 { 756 public ECKAEGwithSHA1KDF() 757 { 758 super("ECKAEGwithSHA1KDF", new ECDHBasicAgreement(), 759 new KDF2BytesGenerator(DigestFactory.createSHA1())); 760 } 761 } 762 763 /** 764 * KeyAgreement according to BSI TR-03111 chapter 4.3.1 765 * 766 public static class ECKAEGwithRIPEMD160KDF 767 extends KeyAgreementSpi 768 { 769 public ECKAEGwithRIPEMD160KDF() 770 { 771 super("ECKAEGwithRIPEMD160KDF", new ECDHBasicAgreement(), 772 new KDF2BytesGenerator(new RIPEMD160Digest())); 773 } 774 } 775 776 /** 777 * KeyAgreement according to BSI TR-03111 chapter 4.3.1 778 * 779 public static class ECKAEGwithSHA224KDF 780 extends KeyAgreementSpi 781 { 782 public ECKAEGwithSHA224KDF() 783 { 784 super("ECKAEGwithSHA224KDF", new ECDHBasicAgreement(), 785 new KDF2BytesGenerator(DigestFactory.createSHA224())); 786 } 787 } 788 789 /** 790 * KeyAgreement according to BSI TR-03111 chapter 4.3.1 791 * 792 public static class ECKAEGwithSHA256KDF 793 extends KeyAgreementSpi 794 { 795 public ECKAEGwithSHA256KDF() 796 { 797 super("ECKAEGwithSHA256KDF", new ECDHBasicAgreement(), 798 new KDF2BytesGenerator(DigestFactory.createSHA256())); 799 } 800 } 801 802 /** 803 * KeyAgreement according to BSI TR-03111 chapter 4.3.1 804 * 805 public static class ECKAEGwithSHA384KDF 806 extends KeyAgreementSpi 807 { 808 public ECKAEGwithSHA384KDF() 809 { 810 super("ECKAEGwithSHA384KDF", new ECDHBasicAgreement(), 811 new KDF2BytesGenerator(DigestFactory.createSHA384())); 812 } 813 } 814 815 /** 816 * KeyAgreement according to BSI TR-03111 chapter 4.3.1 817 * 818 public static class ECKAEGwithSHA512KDF 819 extends KeyAgreementSpi 820 { 821 public ECKAEGwithSHA512KDF() 822 { 823 super("ECKAEGwithSHA512KDF", new ECDHBasicAgreement(), 824 new KDF2BytesGenerator(DigestFactory.createSHA512())); 825 } 826 } 827 */ 828 // END Android-removed: Unsupported algorithms 829 } 830