Search in sources :

Example 71 with Provider

use of java.security.Provider in project robovm by robovm.

the class MessageDigest2Test method test_getDigestLength.

/**
     * java.security.MessageDigest#getDigestLength()
     */
public void test_getDigestLength() throws Exception {
    for (Entry<Provider, List<String>> e : digestAlgs.entrySet()) {
        for (String algorithm : e.getValue()) {
            MessageDigest md = MessageDigest.getInstance(algorithm, e.getKey().getName());
            assertTrue("length not ok", md.getDigestLength() > 0);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) MessageDigest(java.security.MessageDigest) Provider(java.security.Provider)

Example 72 with Provider

use of java.security.Provider in project robovm by robovm.

the class MessageDigest2Test method test_clone.

/**
     * java.security.MessageDigest#clone()
     */
public void test_clone() throws Exception {
    for (Entry<Provider, List<String>> e : digestAlgs.entrySet()) {
        for (String algorithm : e.getValue()) {
            MessageDigest d1 = MessageDigest.getInstance(algorithm, e.getKey().getName());
            for (byte b = 0; b < 84; b++) {
                d1.update(b);
            }
            MessageDigest d2 = (MessageDigest) d1.clone();
            d1.update((byte) 1);
            d2.update((byte) 1);
            assertTrue("cloned hash differs from original for algorithm " + algorithm, MessageDigest.isEqual(d1.digest(), d2.digest()));
        }
    }
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) MessageDigest(java.security.MessageDigest) Provider(java.security.Provider)

Example 73 with Provider

use of java.security.Provider in project robovm by robovm.

the class ProviderTest method testProviderStringdoubleString.

/*
     * Class under test for void Provider(String, double, String)
     */
public final void testProviderStringdoubleString() {
    Provider p = new MyProvider("Provider name", 123.456, "Provider info");
    assertEquals("Provider name", p.getName());
    assertEquals(123.456, p.getVersion(), 0L);
    assertEquals("Provider info", p.getInfo());
}
Also used : Provider(java.security.Provider)

Example 74 with Provider

use of java.security.Provider in project robovm by robovm.

the class ProviderServiceTest method testSupportsParameter.

public void testSupportsParameter() {
    Provider p = new MyProvider();
    Provider.Service s1 = new Provider.Service(p, "type", "algorithm", "className", null, null);
    assertTrue(s1.supportsParameter(null));
    assertTrue(s1.supportsParameter(new Object()));
}
Also used : Service(java.security.Provider.Service) Service(java.security.Provider.Service) Provider(java.security.Provider)

Example 75 with Provider

use of java.security.Provider in project robovm by robovm.

the class ProviderServiceTest method testToString.

public void testToString() {
    Provider p = new MyProvider();
    Provider.Service s1 = new Provider.Service(p, "type", "algorithm", "className", null, null);
    s1.toString();
    Provider.Service s2 = new Provider.Service(p, "SecureRandom", "algorithm", "tests.java.security.support.RandomImpl", null, null);
    s2.toString();
}
Also used : Service(java.security.Provider.Service) Service(java.security.Provider.Service) Provider(java.security.Provider)

Aggregations

Provider (java.security.Provider)243 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)49 ArrayList (java.util.ArrayList)26 MessageDigest (java.security.MessageDigest)21 List (java.util.List)20 Key (java.security.Key)19 KeyStore (java.security.KeyStore)19 Service (java.security.Provider.Service)15 ExemptionMechanism (javax.crypto.ExemptionMechanism)14 SpiEngUtils (org.apache.harmony.security.tests.support.SpiEngUtils)14 InvalidKeyException (java.security.InvalidKeyException)13 SecureRandom (java.security.SecureRandom)13 IOException (java.io.IOException)12 NoSuchProviderException (java.security.NoSuchProviderException)12 SecretKey (javax.crypto.SecretKey)12 KeyStoreException (java.security.KeyStoreException)11 CertificateException (java.security.cert.CertificateException)11 Cipher (javax.crypto.Cipher)11 KeyGenerator (javax.crypto.KeyGenerator)11 MyExemptionMechanismSpi.tmpKey (org.apache.harmony.crypto.tests.support.MyExemptionMechanismSpi.tmpKey)11