Debian Codegraph @

ext/ed25519_jruby/net/i2p/crypto/eddsa/EdDSASecurityProvider.java

raw symbols SCIP
1 /**
2 * EdDSA-Java by str4d
3 *
4 * To the extent possible under law, the person who associated CC0 with
5 * EdDSA-Java has waived all copyright and related or neighboring rights
6 * to EdDSA-Java.
7 *
8 * You should have received a copy of the CC0 legalcode along with this
9 * work. If not, see <https://creativecommons.org/publicdomain/zero/1.0/>.
10 *
11 */
12 package net.i2p.crypto.eddsa;
13
14 import java.security.AccessController;
15 import java.security.PrivilegedAction;
16 import java.security.Provider;
17 import java.security.Security;
18
19 /**
20 * A security {@link Provider} that can be registered via {@link Security#addProvider(Provider)}
21 *
22 * @author str4d
23 */
24 public class EdDSASecurityProvider extends Provider {
25 private static final long serialVersionUID = 1210027906682292307L;
26 public static final String PROVIDER_NAME = "EdDSA";
27
28 public EdDSASecurityProvider() {
29 super(PROVIDER_NAME, 0.2 /* should match POM major.minor version */, "str4d " + PROVIDER_NAME + " security provider wrapper");
30
31 AccessController.doPrivileged(new PrivilegedAction<Object>() {
32 @Override
33 public Object run() {
34 setup();
35 return null;
36 }
37 });
38 }
39
40 protected void setup() {
41 // See https://docs.oracle.com/javase/8/docs/technotes/guides/security/crypto/HowToImplAProvider.html
42 put("KeyFactory." + EdDSAKey.KEY_ALGORITHM, "net.i2p.crypto.eddsa.KeyFactory");
43 put("KeyPairGenerator." + EdDSAKey.KEY_ALGORITHM, "net.i2p.crypto.eddsa.KeyPairGenerator");
44 put("Signature." + EdDSAEngine.SIGNATURE_ALGORITHM, "net.i2p.crypto.eddsa.EdDSAEngine");
45
46 // OID Mappings
47 // See section "Mapping from OID to name".
48 // The Key* -> OID mappings correspond to the default algorithm in KeyPairGenerator.
49 //
50 // From draft-ieft-curdle-pkix-04:
51 // id-Ed25519 OBJECT IDENTIFIER ::= { 1 3 101 112 }
52 put("Alg.Alias.KeyFactory.1.3.101.112", EdDSAKey.KEY_ALGORITHM);
53 put("Alg.Alias.KeyFactory.OID.1.3.101.112", EdDSAKey.KEY_ALGORITHM);
54 put("Alg.Alias.KeyPairGenerator.1.3.101.112", EdDSAKey.KEY_ALGORITHM);
55 put("Alg.Alias.KeyPairGenerator.OID.1.3.101.112", EdDSAKey.KEY_ALGORITHM);
56 put("Alg.Alias.Signature.1.3.101.112", EdDSAEngine.SIGNATURE_ALGORITHM);
57 put("Alg.Alias.Signature.OID.1.3.101.112", EdDSAEngine.SIGNATURE_ALGORITHM);
58 }
59 }