/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* This class implements the OAEP parameters used with the RSA
* algorithm in OAEP padding. Here is its ASN.1 definition:
* RSAES-OAEP-params ::= SEQUENCE {
* hashAlgorithm [0] HashAlgorithm DEFAULT sha1,
* maskGenAlgorithm [1] MaskGenAlgorithm DEFAULT mgf1SHA1,
* pSourceAlgorithm [2] PSourceAlgorithm DEFAULT pSpecifiedEmpty
* }
*
* @author Valerie Peng
*
*/
private byte[] p;
static {
try {
} catch (IOException ioe) {
// should not happen
}
try {
} catch (IOException ioe) {
// should not happen
}
}
public OAEPParameters() {
}
throws InvalidParameterSpecException {
if (!(paramSpec instanceof OAEPParameterSpec)) {
throw new InvalidParameterSpecException
("Inappropriate parameter specification");
}
throw new InvalidParameterSpecException("Unsupported mgf " +
mgfName + "; MGF1 only");
}
if (!(mgfSpec instanceof MGF1ParameterSpec)) {
throw new InvalidParameterSpecException("Inappropriate mgf " +
"parameters; non-null MGF1ParameterSpec only");
}
} else {
throw new InvalidParameterSpecException("Unsupported pSource " +
}
}
return "SHA-1";
return "SHA-256";
return "SHA-384";
return "SHA-512";
} else {
return internalName;
}
}
throws IOException {
mdName = "SHA-1";
p = new byte[0];
// hash algid
// mgf algid
throw new IOException("Only MGF1 mgf is supported");
}
} else {
throw new IOException(
"Unrecognized message digest algorithm");
}
// pSource algid
throw new IOException("Wrong OID for pSpecified");
}
p = dis.getOctetString();
throw new IOException("Extra data for pSpecified");
}
} else {
throw new IOException("Invalid encoded OAEPParameters");
}
}
}
throws IOException {
if ((decodingMethod != null) &&
throw new IllegalArgumentException("Only support ASN.1 format");
}
}
throws InvalidParameterSpecException {
new PSource.PSpecified(p));
} else {
throw new InvalidParameterSpecException
("Inappropriate parameter specification");
}
}
// MD
try {
} catch (NoSuchAlgorithmException nsae) {
" impl not found");
}
tmp2 = new DerOutputStream();
tmp2);
// MGF
tmp2 = new DerOutputStream();
try {
} catch (NoSuchAlgorithmException nase) {
throw new IOException("AlgorithmId " +
}
tmp3 = new DerOutputStream();
tmp3);
// PSource
tmp2 = new DerOutputStream();
tmp2.putOctetString(p);
tmp3 = new DerOutputStream();
tmp3);
// Put all together under a SEQUENCE tag
return out.toByteArray();
}
throws IOException {
if ((encodingMethod != null) &&
throw new IllegalArgumentException("Only support ASN.1 format");
}
return engineGetEncoded();
}
}
}