author | vinnie |
Tue, 11 Aug 2009 16:52:26 +0100 | |
changeset 3492 | e549cea58864 |
child 3863 | 8e0f58b1c072 |
permissions | -rw-r--r-- |
3492
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
1 |
/* |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
2 |
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
4 |
* |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Sun designates this |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
9 |
* by Sun in the LICENSE file that accompanied this code. |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
10 |
* |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
15 |
* accompanied this code). |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
16 |
* |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
20 |
* |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
21 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
23 |
* have any questions. |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
24 |
*/ |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
25 |
|
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
26 |
package sun.security.ec; |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
27 |
|
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
28 |
import java.util.*; |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
29 |
import java.security.*; |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
30 |
import sun.security.action.PutAllAction; |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
31 |
|
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
32 |
/** |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
33 |
* Provider class for the Elliptic Curve provider. |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
34 |
* Supports EC keypair and parameter generation, ECDSA signing and |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
35 |
* ECDH key agreement. |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
36 |
* |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
37 |
* IMPLEMENTATION NOTE: |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
38 |
* The Java classes in this provider access a native ECC implementation |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
39 |
* via JNI to a C++ wrapper class which in turn calls C functions. |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
40 |
* The Java classes are packaged into the signed sunec.jar in the JRE |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
41 |
* extensions directory and the C++ and C functions are packaged into |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
42 |
* libsunecc.so or sunecc.dll in the JRE native libraries directory. |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
43 |
* |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
44 |
* @since 1.7 |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
45 |
*/ |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
46 |
public final class SunEC extends Provider { |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
47 |
|
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
48 |
private static final long serialVersionUID = -2279741672933606418L; |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
49 |
|
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
50 |
public SunEC() { |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
51 |
super("SunEC", 1.7d, "Sun Elliptic Curve provider (EC, ECDSA, ECDH)"); |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
52 |
|
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
53 |
// if there is no security manager installed, put directly into |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
54 |
// the provider. Otherwise, create a temporary map and use a |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
55 |
// doPrivileged() call at the end to transfer the contents |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
56 |
if (System.getSecurityManager() == null) { |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
57 |
SunECEntries.putEntries(this); |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
58 |
} else { |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
59 |
Map<Object, Object> map = new HashMap<Object, Object>(); |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
60 |
SunECEntries.putEntries(map); |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
61 |
AccessController.doPrivileged(new PutAllAction(this, map)); |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
62 |
} |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
63 |
} |
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
64 |
|
e549cea58864
6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff
changeset
|
65 |
} |