@Test public void testKeyAlgorithmRsa() throws IOException { byte[] data = Base64.decode(RSA_BASE64); assertThat(Asn1DerDecoder.readSubjectPublicKeyAlgorithm(data), is("RSA")); }
public static String readSubjectPublicKeyAlgorithm(final byte[] data) { DatagramReader reader = new DatagramReader(data, false); reader = SEQUENCE.createRangeReader(reader, false); reader = SEQUENCE.createRangeReader(reader, false); byte[] value = readOidValue(reader); String algorithm = null; if (Arrays.equals(value, OID_EC_PUBLIC_KEY)) { algorithm = EC; } else if (Arrays.equals(value, OID_RSA_PUBLIC_KEY)) { algorithm = RSA; } else if (Arrays.equals(value, OID_DSA_PUBLIC_KEY)) { algorithm = DSA; } else if (Arrays.equals(value, OID_DH_PUBLIC_KEY)) { algorithm = DH; } else if (Arrays.equals(value, OID_ED25519_PUBLIC_KEY)) { algorithm = ED25519; } else if (Arrays.equals(value, OID_ED448_PUBLIC_KEY)) { algorithm = ED448; } return algorithm; }
Asn1DerDecoder { public static String readSubjectPublicKeyAlgorithm(final byte[] data) { DatagramReader reader = new DatagramReader(data, false); reader = SEQUENCE.createRangeReader(reader, false); reader = SEQUENCE.createRangeReader(reader, false); byte[] value = readOidValue(reader); String algorithm = null; if (Arrays.equals(value, OID_EC_PUBLIC_KEY)) { algorithm = EC; } else if (Arrays.equals(value, OID_RSA_PUBLIC_KEY)) { algorithm = RSA; } else if (Arrays.equals(value, OID_DSA_PUBLIC_KEY)) { algorithm = DSA; } else if (Arrays.equals(value, OID_DH_PUBLIC_KEY)) { algorithm = DH; } else if (Arrays.equals(value, OID_ED25519_PUBLIC_KEY)) { algorithm = ED25519; } else if (Arrays.equals(value, OID_ED448_PUBLIC_KEY)) { algorithm = ED448; } return algorithm; } }
Asn1DerDecoder { public static String readSubjectPublicKeyAlgorithm(final byte[] data) { DatagramReader reader = new DatagramReader(data, false); reader = SEQUENCE.createRangeReader(reader, false); reader = SEQUENCE.createRangeReader(reader, false); byte[] value = readOidValue(reader); String algorithm = null; if (Arrays.equals(value, OID_EC_PUBLIC_KEY)) { algorithm = EC; } else if (Arrays.equals(value, OID_RSA_PUBLIC_KEY)) { algorithm = RSA; } else if (Arrays.equals(value, OID_DSA_PUBLIC_KEY)) { algorithm = DSA; } else if (Arrays.equals(value, OID_DH_PUBLIC_KEY)) { algorithm = DH; } else if (Arrays.equals(value, OID_ED25519_PUBLIC_KEY)) { algorithm = ED25519; } else if (Arrays.equals(value, OID_ED448_PUBLIC_KEY)) { algorithm = ED448; } return algorithm; }  }
Asn1DerDecoder { public static String readSubjectPublicKeyAlgorithm(final byte[] data) { DatagramReader reader = new DatagramReader(data, false); reader = SEQUENCE.createRangeReader(reader, false); reader = SEQUENCE.createRangeReader(reader, false); byte[] value = readOidValue(reader); String algorithm = null; if (Arrays.equals(value, OID_EC_PUBLIC_KEY)) { algorithm = EC; } else if (Arrays.equals(value, OID_RSA_PUBLIC_KEY)) { algorithm = RSA; } else if (Arrays.equals(value, OID_DSA_PUBLIC_KEY)) { algorithm = DSA; } else if (Arrays.equals(value, OID_DH_PUBLIC_KEY)) { algorithm = DH; } else if (Arrays.equals(value, OID_ED25519_PUBLIC_KEY)) { algorithm = ED25519; } else if (Arrays.equals(value, OID_ED448_PUBLIC_KEY)) { algorithm = ED448; } return algorithm; }  static Provider getEdDsaProvider(); static boolean isSupported(String algorithm); static byte[] readSequenceEntity(final DatagramReader reader); static byte[] readSequenceValue(final DatagramReader reader); static byte[] readOidValue(final DatagramReader reader); static String readOidString(final DatagramReader reader); static String readSubjectPublicKeyAlgorithm(final byte[] data); static PublicKey readSubjectPublicKey(final byte[] data); static String readPrivateKeyAlgorithm(final byte[] data); static Keys readPrivateKey(final byte[] data); static Keys readEcPrivateKeyV2(final byte[] data); static ECPublicKey readEcPublicKey(DatagramReader reader, ECParameterSpec ecParameterSpec); static PrivateKey ensureEdDsaPrivateKeyProvider(PrivateKey privateKey); static boolean equalKeyAlgorithmSynonyms(String keyAlgorithm1, String keyAlgorithm2); static ECParameterSpec getECParameterSpec(String oid); static String getEdDsaStandardAlgorithmName(String algorithm, String def); }
Asn1DerDecoder { public static String readSubjectPublicKeyAlgorithm(final byte[] data) { DatagramReader reader = new DatagramReader(data, false); reader = SEQUENCE.createRangeReader(reader, false); reader = SEQUENCE.createRangeReader(reader, false); byte[] value = readOidValue(reader); String algorithm = null; if (Arrays.equals(value, OID_EC_PUBLIC_KEY)) { algorithm = EC; } else if (Arrays.equals(value, OID_RSA_PUBLIC_KEY)) { algorithm = RSA; } else if (Arrays.equals(value, OID_DSA_PUBLIC_KEY)) { algorithm = DSA; } else if (Arrays.equals(value, OID_DH_PUBLIC_KEY)) { algorithm = DH; } else if (Arrays.equals(value, OID_ED25519_PUBLIC_KEY)) { algorithm = ED25519; } else if (Arrays.equals(value, OID_ED448_PUBLIC_KEY)) { algorithm = ED448; } return algorithm; }  static Provider getEdDsaProvider(); static boolean isSupported(String algorithm); static byte[] readSequenceEntity(final DatagramReader reader); static byte[] readSequenceValue(final DatagramReader reader); static byte[] readOidValue(final DatagramReader reader); static String readOidString(final DatagramReader reader); static String readSubjectPublicKeyAlgorithm(final byte[] data); static PublicKey readSubjectPublicKey(final byte[] data); static String readPrivateKeyAlgorithm(final byte[] data); static Keys readPrivateKey(final byte[] data); static Keys readEcPrivateKeyV2(final byte[] data); static ECPublicKey readEcPublicKey(DatagramReader reader, ECParameterSpec ecParameterSpec); static PrivateKey ensureEdDsaPrivateKeyProvider(PrivateKey privateKey); static boolean equalKeyAlgorithmSynonyms(String keyAlgorithm1, String keyAlgorithm2); static ECParameterSpec getECParameterSpec(String oid); static String getEdDsaStandardAlgorithmName(String algorithm, String def); static final String EC; static final String RSA; static final String DSA; static final String DH; static final String ECv2; static final String ED25519; static final String ED448; static final String OID_ED25519; static final String OID_ED448; static final String EDDSA; static final int EC_PUBLIC_KEY_UNCOMPRESSED; }