0N/A/*
665N/A * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
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
0N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
0N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
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 *
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.
0N/A *
0N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0N/A * or visit www.oracle.com if you need additional information or have any
0N/A * questions.
0N/A */
0N/A
0N/Apackage sun.security.ec;
0N/A
0N/Aimport java.util.*;
0N/Aimport java.security.*;
0N/Aimport sun.security.action.PutAllAction;
0N/A
0N/A/**
0N/A * Provider class for the Elliptic Curve provider.
0N/A * Supports EC keypair and parameter generation, ECDSA signing and
0N/A * ECDH key agreement.
0N/A *
0N/A * IMPLEMENTATION NOTE:
0N/A * The Java classes in this provider access a native ECC implementation
0N/A * via JNI to a C++ wrapper class which in turn calls C functions.
0N/A * The Java classes are packaged into the signed sunec.jar in the JRE
0N/A * extensions directory and the C++ and C functions are packaged into
0N/A * libsunec.so or sunec.dll in the JRE native libraries directory.
0N/A * If the native library is not present then this provider is registered
0N/A * with support for fewer ECC algorithms (KeyPairGenerator, Signature and
0N/A * KeyAgreement are omitted).
0N/A *
0N/A * @since 1.7
0N/A */
0N/Apublic final class SunEC extends Provider {
0N/A
0N/A private static final long serialVersionUID = -2279741672933606418L;
0N/A
0N/A // flag indicating whether the full EC implementation is present
0N/A // (when native library is absent then fewer EC algorithms are available)
0N/A private static boolean useFullImplementation = true;
0N/A static {
0N/A try {
0N/A AccessController.doPrivileged(new PrivilegedAction<Void>() {
0N/A public Void run() {
0N/A System.loadLibrary("sunec"); // check for native library
0N/A return null;
116N/A }
116N/A });
116N/A } catch (UnsatisfiedLinkError e) {
116N/A useFullImplementation = false;
0N/A }
0N/A }
0N/A
0N/A public SunEC() {
0N/A super("SunEC", 1.7d, "Sun Elliptic Curve provider (EC, ECDSA, ECDH)");
0N/A
0N/A // if there is no security manager installed, put directly into
0N/A // the provider. Otherwise, create a temporary map and use a
0N/A // doPrivileged() call at the end to transfer the contents
0N/A if (System.getSecurityManager() == null) {
0N/A SunECEntries.putEntries(this, useFullImplementation);
0N/A } else {
0N/A Map<Object, Object> map = new HashMap<Object, Object>();
0N/A SunECEntries.putEntries(map, useFullImplementation);
0N/A AccessController.doPrivileged(new PutAllAction(this, map));
0N/A }
0N/A }
0N/A
0N/A}
0N/A