Java Code Examples for javax.crypto.spec.PSource#PSpecified
The following examples show how to use
javax.crypto.spec.PSource#PSpecified .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestOAEPParameterSpec.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
private static boolean runTest(String mdName, MGF1ParameterSpec mgfSpec, byte[] p) throws Exception { OAEPParameterSpec spec = new OAEPParameterSpec(mdName, "MGF1", mgfSpec, new PSource.PSpecified(p)); cp = Security.getProvider("SunJCE"); System.out.println("Testing provider " + cp.getName() + "..."); AlgorithmParameters ap = AlgorithmParameters.getInstance("OAEP", cp); ap.init(spec); byte[] encoding = ap.getEncoded(); AlgorithmParameters ap2 = AlgorithmParameters.getInstance("OAEP", cp); ap2.init(encoding); OAEPParameterSpec spec2 = (OAEPParameterSpec) ap2.getParameterSpec (OAEPParameterSpec.class); return compareSpec(spec, spec2); }
Example 2
Source File: AlgorithmParametersSpi.java From ripple-lib-java with ISC License | 6 votes |
/** * Return the PKCS#1 ASN.1 structure RSAES-OAEP-params. */ protected byte[] engineGetEncoded() { AlgorithmIdentifier hashAlgorithm = new AlgorithmIdentifier( DigestFactory.getOID(currentSpec.getDigestAlgorithm()), DERNull.INSTANCE); MGF1ParameterSpec mgfSpec = (MGF1ParameterSpec)currentSpec.getMGFParameters(); AlgorithmIdentifier maskGenAlgorithm = new AlgorithmIdentifier( PKCSObjectIdentifiers.id_mgf1, new AlgorithmIdentifier(DigestFactory.getOID(mgfSpec.getDigestAlgorithm()), DERNull.INSTANCE)); PSource.PSpecified pSource = (PSource.PSpecified)currentSpec.getPSource(); AlgorithmIdentifier pSourceAlgorithm = new AlgorithmIdentifier( PKCSObjectIdentifiers.id_pSpecified, new DEROctetString(pSource.getValue())); RSAESOAEPparams oaepP = new RSAESOAEPparams(hashAlgorithm, maskGenAlgorithm, pSourceAlgorithm); try { return oaepP.getEncoded(ASN1Encoding.DER); } catch (IOException e) { throw new RuntimeException("Error encoding OAEPParameters"); } }
Example 3
Source File: AlgorithmParametersSpi.java From RipplePower with Apache License 2.0 | 6 votes |
/** * Return the PKCS#1 ASN.1 structure RSAES-OAEP-params. */ protected byte[] engineGetEncoded() { AlgorithmIdentifier hashAlgorithm = new AlgorithmIdentifier( DigestFactory.getOID(currentSpec.getDigestAlgorithm()), DERNull.INSTANCE); MGF1ParameterSpec mgfSpec = (MGF1ParameterSpec)currentSpec.getMGFParameters(); AlgorithmIdentifier maskGenAlgorithm = new AlgorithmIdentifier( PKCSObjectIdentifiers.id_mgf1, new AlgorithmIdentifier(DigestFactory.getOID(mgfSpec.getDigestAlgorithm()), DERNull.INSTANCE)); PSource.PSpecified pSource = (PSource.PSpecified)currentSpec.getPSource(); AlgorithmIdentifier pSourceAlgorithm = new AlgorithmIdentifier( PKCSObjectIdentifiers.id_pSpecified, new DEROctetString(pSource.getValue())); RSAESOAEPparams oaepP = new RSAESOAEPparams(hashAlgorithm, maskGenAlgorithm, pSourceAlgorithm); try { return oaepP.getEncoded(ASN1Encoding.DER); } catch (IOException e) { throw new RuntimeException("Error encoding OAEPParameters"); } }
Example 4
Source File: PSourceTest.java From j2objc with Apache License 2.0 | 6 votes |
/** * PSpecified(byte[] p) method testing. Tests that NullPointerException * is thrown in the case of null p array. Also it checks the value of * DEFAULT field, and that input p array is copied to protect against * subsequent modification. */ public void testPSpecified() { try { new PSource.PSpecified(null); fail("NullPointerException should be thrown in the case of " + "null p array."); } catch (NullPointerException e) { } assertEquals("The PSource.PSpecified DEFAULT value should be byte[0]", 0, PSource.PSpecified.DEFAULT.getValue().length); byte[] p = new byte[] {1, 2, 3, 4, 5}; PSource.PSpecified ps = new PSource.PSpecified(p); p[0]++; assertFalse("The change of p specified in the constructor " + "should not cause the change of internal array.", p[0] == ps .getValue()[0]); }
Example 5
Source File: TestOAEPParameterSpec.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
private static boolean runTest(String mdName, MGF1ParameterSpec mgfSpec, byte[] p) throws Exception { OAEPParameterSpec spec = new OAEPParameterSpec(mdName, "MGF1", mgfSpec, new PSource.PSpecified(p)); cp = Security.getProvider("SunJCE"); System.out.println("Testing provider " + cp.getName() + "..."); AlgorithmParameters ap = AlgorithmParameters.getInstance("OAEP", cp); ap.init(spec); byte[] encoding = ap.getEncoded(); AlgorithmParameters ap2 = AlgorithmParameters.getInstance("OAEP", cp); ap2.init(encoding); OAEPParameterSpec spec2 = (OAEPParameterSpec) ap2.getParameterSpec (OAEPParameterSpec.class); return compareSpec(spec, spec2); }
Example 6
Source File: TestOAEPParameterSpec.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
private static boolean runTest(String mdName, MGF1ParameterSpec mgfSpec, byte[] p) throws Exception { OAEPParameterSpec spec = new OAEPParameterSpec(mdName, "MGF1", mgfSpec, new PSource.PSpecified(p)); cp = Security.getProvider("SunJCE"); System.out.println("Testing provider " + cp.getName() + "..."); AlgorithmParameters ap = AlgorithmParameters.getInstance("OAEP", cp); ap.init(spec); byte[] encoding = ap.getEncoded(); AlgorithmParameters ap2 = AlgorithmParameters.getInstance("OAEP", cp); ap2.init(encoding); OAEPParameterSpec spec2 = (OAEPParameterSpec) ap2.getParameterSpec (OAEPParameterSpec.class); return compareSpec(spec, spec2); }
Example 7
Source File: TestOAEPParameterSpec.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
private static boolean runTest(String mdName, MGF1ParameterSpec mgfSpec, byte[] p) throws Exception { OAEPParameterSpec spec = new OAEPParameterSpec(mdName, "MGF1", mgfSpec, new PSource.PSpecified(p)); cp = Security.getProvider("SunJCE"); System.out.println("Testing provider " + cp.getName() + "..."); AlgorithmParameters ap = AlgorithmParameters.getInstance("OAEP", cp); ap.init(spec); byte[] encoding = ap.getEncoded(); AlgorithmParameters ap2 = AlgorithmParameters.getInstance("OAEP", cp); ap2.init(encoding); OAEPParameterSpec spec2 = (OAEPParameterSpec) ap2.getParameterSpec (OAEPParameterSpec.class); return compareSpec(spec, spec2); }
Example 8
Source File: TestOAEPParameterSpec.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
private static boolean runTest(String mdName, MGF1ParameterSpec mgfSpec, byte[] p) throws Exception { OAEPParameterSpec spec = new OAEPParameterSpec(mdName, "MGF1", mgfSpec, new PSource.PSpecified(p)); cp = Security.getProvider("SunJCE"); System.out.println("Testing provider " + cp.getName() + "..."); AlgorithmParameters ap = AlgorithmParameters.getInstance("OAEP", cp); ap.init(spec); byte[] encoding = ap.getEncoded(); AlgorithmParameters ap2 = AlgorithmParameters.getInstance("OAEP", cp); ap2.init(encoding); OAEPParameterSpec spec2 = (OAEPParameterSpec) ap2.getParameterSpec (OAEPParameterSpec.class); return compareSpec(spec, spec2); }
Example 9
Source File: TestOAEPParameterSpec.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
private static boolean runTest(String mdName, MGF1ParameterSpec mgfSpec, byte[] p) throws Exception { OAEPParameterSpec spec = new OAEPParameterSpec(mdName, "MGF1", mgfSpec, new PSource.PSpecified(p)); cp = Security.getProvider("SunJCE"); System.out.println("Testing provider " + cp.getName() + "..."); AlgorithmParameters ap = AlgorithmParameters.getInstance("OAEP", cp); ap.init(spec); byte[] encoding = ap.getEncoded(); AlgorithmParameters ap2 = AlgorithmParameters.getInstance("OAEP", cp); ap2.init(encoding); OAEPParameterSpec spec2 = (OAEPParameterSpec) ap2.getParameterSpec (OAEPParameterSpec.class); return compareSpec(spec, spec2); }
Example 10
Source File: TestOAEPParameterSpec.java From hottub with GNU General Public License v2.0 | 6 votes |
private static boolean runTest(String mdName, MGF1ParameterSpec mgfSpec, byte[] p) throws Exception { OAEPParameterSpec spec = new OAEPParameterSpec(mdName, "MGF1", mgfSpec, new PSource.PSpecified(p)); cp = Security.getProvider("SunJCE"); System.out.println("Testing provider " + cp.getName() + "..."); AlgorithmParameters ap = AlgorithmParameters.getInstance("OAEP", cp); ap.init(spec); byte[] encoding = ap.getEncoded(); AlgorithmParameters ap2 = AlgorithmParameters.getInstance("OAEP", cp); ap2.init(encoding); OAEPParameterSpec spec2 = (OAEPParameterSpec) ap2.getParameterSpec (OAEPParameterSpec.class); return compareSpec(spec, spec2); }
Example 11
Source File: TestOAEPParameterSpec.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
private static boolean runTest(String mdName, MGF1ParameterSpec mgfSpec, byte[] p) throws Exception { OAEPParameterSpec spec = new OAEPParameterSpec(mdName, "MGF1", mgfSpec, new PSource.PSpecified(p)); cp = Security.getProvider("SunJCE"); System.out.println("Testing provider " + cp.getName() + "..."); AlgorithmParameters ap = AlgorithmParameters.getInstance("OAEP", cp); ap.init(spec); byte[] encoding = ap.getEncoded(); AlgorithmParameters ap2 = AlgorithmParameters.getInstance("OAEP", cp); ap2.init(encoding); OAEPParameterSpec spec2 = (OAEPParameterSpec) ap2.getParameterSpec (OAEPParameterSpec.class); return compareSpec(spec, spec2); }
Example 12
Source File: TestOAEPParameterSpec.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private static boolean runTest(String mdName, MGF1ParameterSpec mgfSpec, byte[] p) throws Exception { OAEPParameterSpec spec = new OAEPParameterSpec(mdName, "MGF1", mgfSpec, new PSource.PSpecified(p)); cp = Security.getProvider("SunJCE"); System.out.println("Testing provider " + cp.getName() + "..."); AlgorithmParameters ap = AlgorithmParameters.getInstance("OAEP", cp); ap.init(spec); byte[] encoding = ap.getEncoded(); AlgorithmParameters ap2 = AlgorithmParameters.getInstance("OAEP", cp); ap2.init(encoding); OAEPParameterSpec spec2 = (OAEPParameterSpec) ap2.getParameterSpec (OAEPParameterSpec.class); return compareSpec(spec, spec2); }
Example 13
Source File: TestOAEPParameterSpec.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
private static boolean runTest(String mdName, MGF1ParameterSpec mgfSpec, byte[] p) throws Exception { OAEPParameterSpec spec = new OAEPParameterSpec(mdName, "MGF1", mgfSpec, new PSource.PSpecified(p)); cp = Security.getProvider("SunJCE"); System.out.println("Testing provider " + cp.getName() + "..."); AlgorithmParameters ap = AlgorithmParameters.getInstance("OAEP", cp); ap.init(spec); byte[] encoding = ap.getEncoded(); AlgorithmParameters ap2 = AlgorithmParameters.getInstance("OAEP", cp); ap2.init(encoding); OAEPParameterSpec spec2 = (OAEPParameterSpec) ap2.getParameterSpec (OAEPParameterSpec.class); return compareSpec(spec, spec2); }
Example 14
Source File: TestOAEPParameterSpec.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private static boolean runTest(String mdName, MGF1ParameterSpec mgfSpec, byte[] p) throws Exception { OAEPParameterSpec spec = new OAEPParameterSpec(mdName, "MGF1", mgfSpec, new PSource.PSpecified(p)); cp = Security.getProvider("SunJCE"); System.out.println("Testing provider " + cp.getName() + "..."); AlgorithmParameters ap = AlgorithmParameters.getInstance("OAEP", cp); ap.init(spec); byte[] encoding = ap.getEncoded(); AlgorithmParameters ap2 = AlgorithmParameters.getInstance("OAEP", cp); ap2.init(encoding); OAEPParameterSpec spec2 = (OAEPParameterSpec) ap2.getParameterSpec (OAEPParameterSpec.class); return compareSpec(spec, spec2); }
Example 15
Source File: TestOAEPParameterSpec.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private static boolean runTest(String mdName, MGF1ParameterSpec mgfSpec, byte[] p) throws Exception { OAEPParameterSpec spec = new OAEPParameterSpec(mdName, "MGF1", mgfSpec, new PSource.PSpecified(p)); cp = Security.getProvider("SunJCE"); System.out.println("Testing provider " + cp.getName() + "..."); AlgorithmParameters ap = AlgorithmParameters.getInstance("OAEP", cp); ap.init(spec); byte[] encoding = ap.getEncoded(); AlgorithmParameters ap2 = AlgorithmParameters.getInstance("OAEP", cp); ap2.init(encoding); OAEPParameterSpec spec2 = (OAEPParameterSpec) ap2.getParameterSpec (OAEPParameterSpec.class); return compareSpec(spec, spec2); }
Example 16
Source File: TestOAEPParameterSpec.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private static boolean runTest(String mdName, MGF1ParameterSpec mgfSpec, byte[] p) throws Exception { OAEPParameterSpec spec = new OAEPParameterSpec(mdName, "MGF1", mgfSpec, new PSource.PSpecified(p)); cp = Security.getProvider("SunJCE"); System.out.println("Testing provider " + cp.getName() + "..."); AlgorithmParameters ap = AlgorithmParameters.getInstance("OAEP", cp); ap.init(spec); byte[] encoding = ap.getEncoded(); AlgorithmParameters ap2 = AlgorithmParameters.getInstance("OAEP", cp); ap2.init(encoding); OAEPParameterSpec spec2 = (OAEPParameterSpec) ap2.getParameterSpec (OAEPParameterSpec.class); return compareSpec(spec, spec2); }
Example 17
Source File: RsaOaepTest.java From wycheproof with Apache License 2.0 | 5 votes |
protected static OAEPParameterSpec getOaepParameters(JsonObject group, JsonObject test) throws Exception { String sha = getString(group, "sha"); String mgf = getString(group, "mgf"); String mgfSha = getString(group, "mgfSha"); PSource p = PSource.PSpecified.DEFAULT; if (test.has("label")) { p = new PSource.PSpecified(getBytes(test, "label")); } return new OAEPParameterSpec(sha, mgf, new MGF1ParameterSpec(mgfSha), p); }
Example 18
Source File: PSourceTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * getValue() method testing. Tests that returned array is equal to the * array specified in the constructor. Checks that modification * of returned array does not affect the internal array. */ public void testGetValue() { byte[] p = new byte[] {1, 2, 3, 4, 5}; PSource.PSpecified ps = new PSource.PSpecified(p); byte[] result = ps.getValue(); if (!Arrays.equals(p, result)) { fail("The returned array does not equal to the specified " + "in the constructor."); } result[0]++; assertFalse("The change of returned by getValue() array " + "should not cause the change of internal array.", result[0] == ps.getValue()[0]); }