Converts a KEY/DNSKEY record into a PublicKey
(KEYBase r)
| 523 | |
| 524 | /** Converts a KEY/DNSKEY record into a PublicKey */ |
| 525 | static PublicKey |
| 526 | toPublicKey(KEYBase r) throws DNSSECException { |
| 527 | int alg = r.getAlgorithm(); |
| 528 | try { |
| 529 | switch (alg) { |
| 530 | case Algorithm.RSAMD5: |
| 531 | case Algorithm.RSASHA1: |
| 532 | case Algorithm.RSA_NSEC3_SHA1: |
| 533 | case Algorithm.RSASHA256: |
| 534 | case Algorithm.RSASHA512: |
| 535 | return toRSAPublicKey(r); |
| 536 | case Algorithm.DSA: |
| 537 | case Algorithm.DSA_NSEC3_SHA1: |
| 538 | return toDSAPublicKey(r); |
| 539 | case Algorithm.ECC_GOST: |
| 540 | return toECGOSTPublicKey(r, GOST); |
| 541 | case Algorithm.ECDSAP256SHA256: |
| 542 | return toECDSAPublicKey(r, ECDSA_P256); |
| 543 | case Algorithm.ECDSAP384SHA384: |
| 544 | return toECDSAPublicKey(r, ECDSA_P384); |
| 545 | default: |
| 546 | throw new UnsupportedAlgorithmException(alg); |
| 547 | } |
| 548 | } |
| 549 | catch (IOException e) { |
| 550 | throw new MalformedKeyException(r); |
| 551 | } |
| 552 | catch (GeneralSecurityException e) { |
| 553 | throw new DNSSECException(e.toString()); |
| 554 | } |
| 555 | } |
| 556 | |
| 557 | private static byte [] |
| 558 | fromRSAPublicKey(RSAPublicKey key) { |
no test coverage detected