public static RSAESOAEPparams getInstance( Object obj) { if (obj instanceof RSAESOAEPparams) { return (RSAESOAEPparams)obj; } else if (obj != null) { return new RSAESOAEPparams(ASN1Sequence.getInstance(obj)); } return null; }
protected void engineInit( byte[] params) throws IOException { try { RSAESOAEPparams oaepP = RSAESOAEPparams.getInstance(params); if (!oaepP.getMaskGenAlgorithm().getAlgorithm().equals(PKCSObjectIdentifiers.id_mgf1)) { throw new IOException("unknown mask generation function: " + oaepP.getMaskGenAlgorithm().getAlgorithm()); } currentSpec = new OAEPParameterSpec( MessageDigestUtils.getDigestName(oaepP.getHashAlgorithm().getAlgorithm()), OAEPParameterSpec.DEFAULT.getMGFAlgorithm(), new MGF1ParameterSpec(MessageDigestUtils.getDigestName(AlgorithmIdentifier.getInstance(oaepP.getMaskGenAlgorithm().getParameters()).getAlgorithm())), new PSource.PSpecified(ASN1OctetString.getInstance(oaepP.getPSourceAlgorithm().getParameters()).getOctets())); } catch (ClassCastException e) { throw new IOException("Not a valid OAEP Parameter encoding."); } catch (ArrayIndexOutOfBoundsException e) { throw new IOException("Not a valid OAEP Parameter encoding."); } }
/** * 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"); } }
RSAESOAEPparams params = RSAESOAEPparams.getInstance(keyAlg.getParameters()); ASN1ObjectIdentifier oid = params.getHashAlgorithm().getAlgorithm(); if (!oid.equals(RSAESOAEPparams.DEFAULT_HASH_ALGORITHM.getAlgorithm())) { throw new Exception( oid = params.getMaskGenAlgorithm().getAlgorithm(); if (!oid.equals(RSAESOAEPparams.DEFAULT_MASK_GEN_FUNCTION.getAlgorithm())) { throw new Exception( oid = params.getPSourceAlgorithm().getAlgorithm(); if (!params.getPSourceAlgorithm().equals(RSAESOAEPparams.DEFAULT_P_SOURCE_ALGORITHM)) { throw new Exception( "unsupported RSAESOAEPparams.PSourceAlgorithm " + oid.getId());
RSAESOAEPparams params = RSAESOAEPparams.getInstance(keyAlg.getParameters()); ASN1ObjectIdentifier oid = params.getHashAlgorithm().getAlgorithm(); if (!oid.equals(RSAESOAEPparams.DEFAULT_HASH_ALGORITHM.getAlgorithm())) { throw new XiSecurityException( oid = params.getMaskGenAlgorithm().getAlgorithm(); if (!oid.equals(RSAESOAEPparams.DEFAULT_MASK_GEN_FUNCTION.getAlgorithm())) { throw new XiSecurityException( oid = params.getPSourceAlgorithm().getAlgorithm(); if (!params.getPSourceAlgorithm().equals(RSAESOAEPparams.DEFAULT_P_SOURCE_ALGORITHM)) { throw new XiSecurityException( "unsupported RSAESOAEPparams.PSourceAlgorithm " + oid.getId());
public static RSAESOAEPparams getInstance( Object obj) { if (obj instanceof RSAESOAEPparams) { return (RSAESOAEPparams)obj; } else if (obj != null) { return new RSAESOAEPparams(ASN1Sequence.getInstance(obj)); } return null; }