Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/sun/security/ec/SunEC.java
38830 views
/*1* Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.security.ec;2627import java.util.*;28import java.security.*;29import sun.security.action.PutAllAction;3031/**32* Provider class for the Elliptic Curve provider.33* Supports EC keypair and parameter generation, ECDSA signing and34* ECDH key agreement.35*36* IMPLEMENTATION NOTE:37* The Java classes in this provider access a native ECC implementation38* via JNI to a C++ wrapper class which in turn calls C functions.39* The Java classes are packaged into the signed sunec.jar in the JRE40* extensions directory and the C++ and C functions are packaged into41* libsunec.so or sunec.dll in the JRE native libraries directory.42* If the native library is not present then this provider is registered43* with support for fewer ECC algorithms (KeyPairGenerator, Signature and44* KeyAgreement are omitted).45*46* @since 1.747*/48public final class SunEC extends Provider {4950private static final long serialVersionUID = -2279741672933606418L;5152// flag indicating whether the full EC implementation is present53// (when native library is absent then fewer EC algorithms are available)54private static boolean useFullImplementation = true;55static {56try {57AccessController.doPrivileged(new PrivilegedAction<Void>() {58public Void run() {59System.loadLibrary("sunec"); // check for native library60return null;61}62});63} catch (UnsatisfiedLinkError e) {64useFullImplementation = false;65}66}6768public SunEC() {69super("SunEC", 1.8d, "Sun Elliptic Curve provider (EC, ECDSA, ECDH)");7071// if there is no security manager installed, put directly into72// the provider. Otherwise, create a temporary map and use a73// doPrivileged() call at the end to transfer the contents74if (System.getSecurityManager() == null) {75SunECEntries.putEntries(this, useFullImplementation);76} else {77Map<Object, Object> map = new HashMap<Object, Object>();78SunECEntries.putEntries(map, useFullImplementation);79AccessController.doPrivileged(new PutAllAction(this, map));80}81}8283}848586