MCPcopy Create free account
hub / github.com/DeNA/PacketProxy / fromPublicKey

Method fromPublicKey

src/main/java/core/org/xbill/DNS/DNSSEC.java:621–653  ·  view source on GitHub ↗

Builds a DNSKEY record from a PublicKey

(PublicKey key, int alg)

Source from the content-addressed store, hash-verified

619
620/** Builds a DNSKEY record from a PublicKey */
621static byte []
622fromPublicKey(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.

Callers 2

DNSKEYRecordMethod · 0.95
KEYRecordMethod · 0.95

Calls 4

fromRSAPublicKeyMethod · 0.95
fromDSAPublicKeyMethod · 0.95
fromECGOSTPublicKeyMethod · 0.95
fromECDSAPublicKeyMethod · 0.95

Tested by

no test coverage detected