Search in sources :

Example 11 with PSSParameterSpec

use of java.security.spec.PSSParameterSpec in project j2objc by google.

the class PSSParameterSpecTest method testGetSaltLength.

/**
     * Test for <code>getSaltLength()</code> method<br>
     * Assertion: returns salt length value
     */
public final void testGetSaltLength() {
    PSSParameterSpec pssps = new PSSParameterSpec(20);
    assertEquals(20, pssps.getSaltLength());
}
Also used : PSSParameterSpec(java.security.spec.PSSParameterSpec)

Example 12 with PSSParameterSpec

use of java.security.spec.PSSParameterSpec in project j2objc by google.

the class PSSParameterSpecTest method testGetMGFAlgorithm.

/**
     * Test for <code>getMGFAlgorithm()</code> method
     * Assertion: returns mask generation function algorithm name
     */
public final void testGetMGFAlgorithm() {
    PSSParameterSpec pssps = new PSSParameterSpec("SHA-1", "MGF1", MGF1ParameterSpec.SHA1, 20, 1);
    assertEquals("MGF1", pssps.getMGFAlgorithm());
}
Also used : PSSParameterSpec(java.security.spec.PSSParameterSpec)

Example 13 with PSSParameterSpec

use of java.security.spec.PSSParameterSpec in project robovm by robovm.

the class myMac method testInit.

/**
     * Test for
     * <code>init(Key key, AlgorithmParameterSpec params)</code>
     * <code>init(Key key)</code>
     * methods
     * Assertion: throws InvalidKeyException and InvalidAlgorithmParameterException
     * when parameters are not appropriate
     */
public void testInit() throws NoSuchAlgorithmException, NoSuchProviderException, IllegalArgumentException, IllegalStateException, InvalidAlgorithmParameterException, InvalidKeyException {
    if (!DEFSupported) {
        fail(NotSupportedMsg);
        return;
    }
    Mac[] macs = createMacs();
    assertNotNull("Mac objects were not created", macs);
    byte[] b = { (byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 5 };
    SecretKeySpec sks = new SecretKeySpec(b, "SHA1");
    DHGenParameterSpec algPS = new DHGenParameterSpec(1, 2);
    PSSParameterSpec algPSS = new PSSParameterSpec(20);
    SecretKeySpec sks1 = new SecretKeySpec(b, "RSA");
    for (int i = 0; i < macs.length; i++) {
        macs[i].init(sks);
        try {
            macs[i].init(sks1, algPSS);
            fail("init(..) accepts incorrect AlgorithmParameterSpec parameter");
        } catch (InvalidAlgorithmParameterException e) {
        }
        try {
            macs[i].init(sks, algPS);
            fail("init(..) accepts incorrect AlgorithmParameterSpec parameter");
        } catch (InvalidAlgorithmParameterException e) {
        }
        try {
            macs[i].init(null, null);
            fail("InvalidKeyException must be thrown");
        } catch (InvalidKeyException e) {
        }
        try {
            macs[i].init(null);
            fail("InvalidKeyException must be thrown");
        } catch (InvalidKeyException e) {
        }
    //            macs[i].init(sks, null);
    }
}
Also used : DHGenParameterSpec(javax.crypto.spec.DHGenParameterSpec) InvalidAlgorithmParameterException(java.security.InvalidAlgorithmParameterException) SecretKeySpec(javax.crypto.spec.SecretKeySpec) PSSParameterSpec(java.security.spec.PSSParameterSpec) InvalidKeyException(java.security.InvalidKeyException) Mac(javax.crypto.Mac)

Example 14 with PSSParameterSpec

use of java.security.spec.PSSParameterSpec in project robovm by robovm.

the class PSSParameterSpecTest method testPSSParameterSpec0201.

/**
     * Test #1 for
     * <code>
     * PSSParameterSpec(String,String,AlgorithmParameterSpec,int,int)
     * </code> ctor<br>
     * Assertion: constructs using valid parameters
     * <code>PSSParameterSpec<code> object
     */
public final void testPSSParameterSpec0201() {
    AlgorithmParameterSpec aps = new PSSParameterSpec("SHA-1", "MGF1", MGF1ParameterSpec.SHA1, 20, 1);
    assertTrue(aps instanceof PSSParameterSpec);
}
Also used : PSSParameterSpec(java.security.spec.PSSParameterSpec) AlgorithmParameterSpec(java.security.spec.AlgorithmParameterSpec)

Example 15 with PSSParameterSpec

use of java.security.spec.PSSParameterSpec in project robovm by robovm.

the class PSSParameterSpecTest method testGetSaltLength.

/**
     * Test for <code>getSaltLength()</code> method<br>
     * Assertion: returns salt length value
     */
public final void testGetSaltLength() {
    PSSParameterSpec pssps = new PSSParameterSpec(20);
    assertEquals(20, pssps.getSaltLength());
}
Also used : PSSParameterSpec(java.security.spec.PSSParameterSpec)

Aggregations

PSSParameterSpec (java.security.spec.PSSParameterSpec)20 AlgorithmParameterSpec (java.security.spec.AlgorithmParameterSpec)4 Signature (java.security.Signature)2 SignatureAlgorithm (io.jsonwebtoken.SignatureAlgorithm)1 IOException (java.io.IOException)1 AlgorithmParameters (java.security.AlgorithmParameters)1 GeneralSecurityException (java.security.GeneralSecurityException)1 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)1 InvalidKeyException (java.security.InvalidKeyException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 NoSuchProviderException (java.security.NoSuchProviderException)1 CertificateException (java.security.cert.CertificateException)1 MGF1ParameterSpec (java.security.spec.MGF1ParameterSpec)1 HashMap (java.util.HashMap)1 Mac (javax.crypto.Mac)1 DHGenParameterSpec (javax.crypto.spec.DHGenParameterSpec)1 SecretKeySpec (javax.crypto.spec.SecretKeySpec)1 OperatorCreationException (org.bouncycastle.operator.OperatorCreationException)1