/*
* 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.
*/
/**
* DSA KeyFactory implemenation.
*
* @author Andreas Sterbenz
* @since 1.5
*/
}
try {
if (key instanceof DSAPublicKey) {
return generatePublic(
);
// let Sun provider parse for us, then recurse
return implTranslatePublicKey(key);
} else {
throw new InvalidKeyException("PublicKey must be instance "
+ "of DSAPublicKey or have X.509 encoding");
}
} catch (PKCS11Exception e) {
throw new InvalidKeyException("Could not create DSA public key", e);
}
}
throws InvalidKeyException {
try {
if (key instanceof DSAPrivateKey) {
return generatePrivate(
);
// let Sun provider parse for us, then recurse
return implTranslatePrivateKey(key);
} else {
throw new InvalidKeyException("PrivateKey must be instance "
+ "of DSAPrivateKey or have PKCS#8 encoding");
}
} catch (PKCS11Exception e) {
throw new InvalidKeyException("Could not create DSA private key", e);
}
}
// see JCA spec
throws InvalidKeySpecException {
token.ensureValid();
if (keySpec instanceof X509EncodedKeySpec) {
try {
return implTranslatePublicKey(key);
} catch (InvalidKeyException e) {
throw new InvalidKeySpecException
("Could not create DSA public key", e);
}
}
if (keySpec instanceof DSAPublicKeySpec == false) {
throw new InvalidKeySpecException("Only DSAPublicKeySpec and "
+ "X509EncodedKeySpec supported for DSA public keys");
}
try {
return generatePublic(
);
} catch (PKCS11Exception e) {
throw new InvalidKeySpecException
("Could not create DSA public key", e);
}
}
// see JCA spec
throws InvalidKeySpecException {
token.ensureValid();
if (keySpec instanceof PKCS8EncodedKeySpec) {
try {
return implTranslatePrivateKey(key);
} catch (GeneralSecurityException e) {
throw new InvalidKeySpecException
("Could not create DSA private key", e);
}
}
if (keySpec instanceof DSAPrivateKeySpec == false) {
throw new InvalidKeySpecException("Only DSAPrivateKeySpec and "
+ "PKCS8EncodedKeySpec supported for DSA private keys");
}
try {
return generatePrivate(
);
} catch (PKCS11Exception e) {
throw new InvalidKeySpecException
("Could not create DSA private key", e);
}
}
BigInteger g) throws PKCS11Exception {
new CK_ATTRIBUTE(CKA_VALUE, y),
new CK_ATTRIBUTE(CKA_PRIME, p),
new CK_ATTRIBUTE(CKA_SUBPRIME, q),
new CK_ATTRIBUTE(CKA_BASE, g),
};
try {
} finally {
}
}
new CK_ATTRIBUTE(CKA_VALUE, x),
new CK_ATTRIBUTE(CKA_PRIME, p),
new CK_ATTRIBUTE(CKA_SUBPRIME, q),
new CK_ATTRIBUTE(CKA_BASE, g),
};
try {
return P11Key.privateKey
} finally {
}
}
throws PKCS11Exception, InvalidKeySpecException {
new CK_ATTRIBUTE(CKA_VALUE),
new CK_ATTRIBUTE(CKA_PRIME),
new CK_ATTRIBUTE(CKA_SUBPRIME),
new CK_ATTRIBUTE(CKA_BASE),
};
);
return spec;
} else { // X.509 handled in superclass
throw new InvalidKeySpecException("Only DSAPublicKeySpec and "
+ "X509EncodedKeySpec supported for DSA public keys");
}
}
throws PKCS11Exception, InvalidKeySpecException {
new CK_ATTRIBUTE(CKA_VALUE),
new CK_ATTRIBUTE(CKA_PRIME),
new CK_ATTRIBUTE(CKA_SUBPRIME),
new CK_ATTRIBUTE(CKA_BASE),
};
);
return spec;
} else { // PKCS#8 handled in superclass
throw new InvalidKeySpecException("Only DSAPrivateKeySpec "
+ "and PKCS8EncodedKeySpec supported for DSA private keys");
}
}
}
}