(PublicKey key, int alg, byte [] data, byte [] signature)
| 851 | } |
| 852 | |
| 853 | private static void |
| 854 | verify(PublicKey key, int alg, byte [] data, byte [] signature) |
| 855 | throws DNSSECException |
| 856 | { |
| 857 | if (key instanceof DSAPublicKey) { |
| 858 | try { |
| 859 | signature = DSASignaturefromDNS(signature); |
| 860 | } |
| 861 | catch (IOException e) { |
| 862 | throw new IllegalStateException(); |
| 863 | } |
| 864 | } else if (key instanceof ECPublicKey) { |
| 865 | try { |
| 866 | switch (alg) { |
| 867 | case Algorithm.ECC_GOST: |
| 868 | signature = ECGOSTSignaturefromDNS(signature, |
| 869 | GOST); |
| 870 | break; |
| 871 | case Algorithm.ECDSAP256SHA256: |
| 872 | signature = ECDSASignaturefromDNS(signature, |
| 873 | ECDSA_P256); |
| 874 | break; |
| 875 | case Algorithm.ECDSAP384SHA384: |
| 876 | signature = ECDSASignaturefromDNS(signature, |
| 877 | ECDSA_P384); |
| 878 | break; |
| 879 | default: |
| 880 | throw new UnsupportedAlgorithmException(alg); |
| 881 | } |
| 882 | } |
| 883 | catch (IOException e) { |
| 884 | throw new IllegalStateException(); |
| 885 | } |
| 886 | } |
| 887 | |
| 888 | try { |
| 889 | Signature s = Signature.getInstance(algString(alg)); |
| 890 | s.initVerify(key); |
| 891 | s.update(data); |
| 892 | if (!s.verify(signature)) |
| 893 | throw new SignatureVerificationException(); |
| 894 | } |
| 895 | catch (GeneralSecurityException e) { |
| 896 | throw new DNSSECException(e.toString()); |
| 897 | } |
| 898 | } |
| 899 | |
| 900 | private static boolean |
| 901 | matches(SIGBase sig, KEYBase key) |
no test coverage detected