Search in sources :

Example 1 with PSSParameterSpec

use of java.security.spec.PSSParameterSpec in project jjwt by jwtk.

the class RsaProvider method createSignatureInstance.

protected Signature createSignatureInstance() {
    Signature sig = super.createSignatureInstance();
    PSSParameterSpec spec = PSS_PARAMETER_SPECS.get(alg);
    if (spec != null) {
        setParameter(sig, spec);
    }
    return sig;
}
Also used : PSSParameterSpec(java.security.spec.PSSParameterSpec) Signature(java.security.Signature)

Example 2 with PSSParameterSpec

use of java.security.spec.PSSParameterSpec in project jjwt by jwtk.

the class RsaProvider method createPssParameterSpecs.

private static Map<SignatureAlgorithm, PSSParameterSpec> createPssParameterSpecs() {
    Map<SignatureAlgorithm, PSSParameterSpec> m = new HashMap<SignatureAlgorithm, PSSParameterSpec>();
    MGF1ParameterSpec ps = MGF1ParameterSpec.SHA256;
    PSSParameterSpec spec = new PSSParameterSpec(ps.getDigestAlgorithm(), "MGF1", ps, 32, 1);
    m.put(SignatureAlgorithm.PS256, spec);
    ps = MGF1ParameterSpec.SHA384;
    spec = new PSSParameterSpec(ps.getDigestAlgorithm(), "MGF1", ps, 48, 1);
    m.put(SignatureAlgorithm.PS384, spec);
    ps = MGF1ParameterSpec.SHA512;
    spec = new PSSParameterSpec(ps.getDigestAlgorithm(), "MGF1", ps, 64, 1);
    m.put(SignatureAlgorithm.PS512, spec);
    return m;
}
Also used : HashMap(java.util.HashMap) PSSParameterSpec(java.security.spec.PSSParameterSpec) SignatureAlgorithm(io.jsonwebtoken.SignatureAlgorithm) MGF1ParameterSpec(java.security.spec.MGF1ParameterSpec)

Example 3 with PSSParameterSpec

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

the class PSSParameterSpecTest method testGetTrailerField.

/**
     * Test for <code>getTrailerField()</code> method<br>
     * Assertion: returns trailer field value
     */
public final void testGetTrailerField() {
    PSSParameterSpec pssps = new PSSParameterSpec("SHA-1", "MGF1", MGF1ParameterSpec.SHA1, 20, 1);
    assertEquals(1, pssps.getTrailerField());
}
Also used : PSSParameterSpec(java.security.spec.PSSParameterSpec)

Example 4 with PSSParameterSpec

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

the class OperatorHelper method createRawSignature.

public Signature createRawSignature(AlgorithmIdentifier algorithm) {
    Signature sig;
    try {
        String algName = getSignatureName(algorithm);
        algName = "NONE" + algName.substring(algName.indexOf("WITH"));
        sig = helper.createSignature(algName);
        // the AlgorithmIdentifier parameters field MUST contain RSASSA-PSS-params.
        if (algorithm.getAlgorithm().equals(PKCSObjectIdentifiers.id_RSASSA_PSS)) {
            AlgorithmParameters params = helper.createAlgorithmParameters(algName);
            params.init(algorithm.getParameters().toASN1Primitive().getEncoded(), "ASN.1");
            PSSParameterSpec spec = (PSSParameterSpec) params.getParameterSpec(PSSParameterSpec.class);
            sig.setParameter(spec);
        }
    } catch (Exception e) {
        return null;
    }
    return sig;
}
Also used : PSSParameterSpec(java.security.spec.PSSParameterSpec) Signature(java.security.Signature) OperatorCreationException(org.bouncycastle.operator.OperatorCreationException) GeneralSecurityException(java.security.GeneralSecurityException) IOException(java.io.IOException) CertificateException(java.security.cert.CertificateException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) NoSuchProviderException(java.security.NoSuchProviderException) AlgorithmParameters(java.security.AlgorithmParameters)

Example 5 with PSSParameterSpec

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

the class PSSParameterSpecTest method testGetTrailerField.

/**
     * Test for <code>getTrailerField()</code> method<br>
     * Assertion: returns trailer field value
     */
public final void testGetTrailerField() {
    PSSParameterSpec pssps = new PSSParameterSpec("SHA-1", "MGF1", MGF1ParameterSpec.SHA1, 20, 1);
    assertEquals(1, pssps.getTrailerField());
}
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