Builds a DNSKEY record from a PublicKey
(PublicKey key, int alg)
| 619 | |
| 620 | /** Builds a DNSKEY record from a PublicKey */ |
| 621 | static byte [] |
| 622 | fromPublicKey(PublicKey key, int alg) throws DNSSECException |
| 623 | { |
| 624 | switch (alg) { |
| 625 | case Algorithm.RSAMD5: |
| 626 | case Algorithm.RSASHA1: |
| 627 | case Algorithm.RSA_NSEC3_SHA1: |
| 628 | case Algorithm.RSASHA256: |
| 629 | case Algorithm.RSASHA512: |
| 630 | if (! (key instanceof RSAPublicKey)) |
| 631 | throw new IncompatibleKeyException(); |
| 632 | return fromRSAPublicKey((RSAPublicKey) key); |
| 633 | case Algorithm.DSA: |
| 634 | case Algorithm.DSA_NSEC3_SHA1: |
| 635 | if (! (key instanceof DSAPublicKey)) |
| 636 | throw new IncompatibleKeyException(); |
| 637 | return fromDSAPublicKey((DSAPublicKey) key); |
| 638 | case Algorithm.ECC_GOST: |
| 639 | if (! (key instanceof ECPublicKey)) |
| 640 | throw new IncompatibleKeyException(); |
| 641 | return fromECGOSTPublicKey((ECPublicKey) key, GOST); |
| 642 | case Algorithm.ECDSAP256SHA256: |
| 643 | if (! (key instanceof ECPublicKey)) |
| 644 | throw new IncompatibleKeyException(); |
| 645 | return fromECDSAPublicKey((ECPublicKey) key, ECDSA_P256); |
| 646 | case Algorithm.ECDSAP384SHA384: |
| 647 | if (! (key instanceof ECPublicKey)) |
| 648 | throw new IncompatibleKeyException(); |
| 649 | return fromECDSAPublicKey((ECPublicKey) key, ECDSA_P384); |
| 650 | default: |
| 651 | throw new UnsupportedAlgorithmException(alg); |
| 652 | } |
| 653 | } |
| 654 | |
| 655 | /** |
| 656 | * Convert an algorithm number to the corresponding JCA string. |
no test coverage detected