/*
* 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.
*/
/**
* Key implementation for EC private keys.
*
* ASN.1 syntax for EC private keys from SEC 1 v1.5 (draft):
*
* <pre>
* EXPLICIT TAGS
*
* ECPrivateKey ::= SEQUENCE {
* version INTEGER { ecPrivkeyVer1(1) } (ecPrivkeyVer1),
* privateKey OCTET STRING,
* parameters [0] ECDomainParameters {{ SECGCurveNames }} OPTIONAL,
* publicKey [1] BIT STRING OPTIONAL
* }
* </pre>
*
* We currently ignore the optional parameters and publicKey fields. We
* require that the parameters are encoded as part of the AlgorithmIdentifier,
* not in the private key structure.
*
* @since 1.6
* @author Andreas Sterbenz
*/
private BigInteger s; // private value
/**
* Construct a key from its encoding. Called by the ECKeyFactory and
* the SunPKCS11 code.
*/
}
/**
* Construct a key from its components. Used by the
* KeyFactory and the SunPKCS11 code.
*/
throws InvalidKeyException {
this.s = s;
// generate the encoding
algid = new AlgorithmId
try {
} catch (IOException exc) {
// should never occur
throw new InvalidKeyException(exc);
}
}
// see JCA doc
return "EC";
}
// see JCA doc
return s;
}
// see JCA doc
return params;
}
/**
* Parse the key. Called by PKCS8Key.
*/
try {
throw new IOException("Not a SEQUENCE");
}
if (version != 1) {
throw new IOException("Version must be 1");
}
// ignore for now
// ignore for now
} else {
}
}
throw new InvalidKeyException("EC domain parameters must be "
+ "encoded in the algorithm identifier");
}
} catch (IOException e) {
throw new InvalidKeyException("Invalid EC private key", e);
} catch (InvalidParameterSpecException e) {
throw new InvalidKeyException("Invalid EC private key", e);
}
}
// return a string representation of this key for debugging
+ " bits\n private value: "
+ s + "\n parameters: " + params;
}
}