2362N/A * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * KeyFactory for EC keys. Keys must be instances of PublicKey or PrivateKey 0N/A * and getAlgorithm() must return "EC". For such keys, it supports conversion 0N/A * between the following: 0N/A * . PublicKey with an X.509 encoding 0N/A * . X509EncodedKeySpec 0N/A * . PrivateKey with a PKCS#8 encoding 0N/A * . ECPrivateKeySpec 0N/A * . PKCS8EncodedKeySpec 0N/A * @author Andreas Sterbenz 0N/A // Used by translateKey() and the SunPKCS11 provider 0N/A // Internal provider object we can obtain the KeyFactory and 0N/A // AlgorithmParameters from. Used by ECParameters and AlgorithmId. 0N/A // This can go away once we have EC always available in the SUN provider. 0N/A // Used by ECParameters and AlgorithmId. 0N/A p.
put(
"KeyFactory.EC",
"sun.security.ec.ECKeyFactory");
0N/A p.
put(
"AlgorithmParameters.EC",
"sun.security.ec.ECParameters");
0N/A p.
put(
"Alg.Alias.AlgorithmParameters.1.2.840.10045.2.1",
"EC");
0N/A * Static method to convert Key into a useable instance of 0N/A * ECPublicKey or ECPrivateKey. Check the key and convert it 0N/A * to a Sun key if necessary. If the key is not an EC key 0N/A * or cannot be used, throw an InvalidKeyException. 0N/A * The difference between this method and engineTranslateKey() is that 0N/A * we do not convert keys of other providers that are already an 0N/A * instance of ECPublicKey or ECPrivateKey. 0N/A * To be used by future Java ECDSA and ECDH implementations. 0N/A * Check that the given EC key is valid. 0N/A // check for subinterfaces, omit additional checks for our keys 0N/A // ECKey does not extend Key, so we need to do a cast 0N/A // XXX further sanity checks about whether this key uses supported 0N/A // fields, point formats, etc. would go here 0N/A * Translate an EC key into a Sun EC key. If conversion is 0N/A * not possible, throw an InvalidKeyException. 0N/A // internal implementation of translateKey() for public keys. See JCA doc 0N/A +
"of ECPublicKey or have X.509 encoding");
0N/A // internal implementation of translateKey() for private keys. See JCA doc 0N/A +
"of ECPrivateKey or have PKCS#8 encoding");
0N/A // internal implementation of generatePublic. See JCA doc 0N/A +
"and X509EncodedKeySpec supported for EC public keys");
0N/A // internal implementation of generatePrivate. See JCA doc 0N/A +
"and PKCS8EncodedKeySpec supported for EC private keys");
0N/A // convert key to one of our keys 0N/A // this also verifies that the key is a valid EC key and ensures 0N/A (
"KeySpec must be ECPublicKeySpec or " 0N/A +
"X509EncodedKeySpec for EC public keys");
0N/A (
"KeySpec must be ECPrivateKeySpec or " 0N/A +
"PKCS8EncodedKeySpec for EC private keys");
0N/A // should not occur, caught in engineTranslateKey()