/** * EdDSA-Java by str4d * * To the extent possible under law, the person who associated CC0 with * EdDSA-Java has waived all copyright and related or neighboring rights * to EdDSA-Java. * * You should have received a copy of the CC0 legalcode along with this * work. If not, see . * */ package net.i2p.crypto.eddsa; import java.security.AccessController; import java.security.PrivilegedAction; import java.security.Provider; import java.security.Security; /** * A security {@link Provider} that can be registered via {@link Security#addProvider(Provider)} * * @author str4d */ public class EdDSASecurityProvider extends Provider { private static final long serialVersionUID = 1210027906682292307L; public static final String PROVIDER_NAME = "EdDSA"; public EdDSASecurityProvider() { super(PROVIDER_NAME, 0.3 /* should match POM major.minor version */, "str4d " + PROVIDER_NAME + " security provider wrapper"); AccessController.doPrivileged(new PrivilegedAction() { @Override public Object run() { setup(); return null; } }); } protected void setup() { // See https://docs.oracle.com/javase/8/docs/technotes/guides/security/crypto/HowToImplAProvider.html put("KeyFactory." + EdDSAKey.KEY_ALGORITHM, "net.i2p.crypto.eddsa.KeyFactory"); put("KeyPairGenerator." + EdDSAKey.KEY_ALGORITHM, "net.i2p.crypto.eddsa.KeyPairGenerator"); put("Signature." + EdDSAEngine.SIGNATURE_ALGORITHM, "net.i2p.crypto.eddsa.EdDSAEngine"); // OID Mappings // See section "Mapping from OID to name". // The Key* -> OID mappings correspond to the default algorithm in KeyPairGenerator. // // From RFC 8410 section 3: // id-Ed25519 OBJECT IDENTIFIER ::= { 1 3 101 112 } put("Alg.Alias.KeyFactory.1.3.101.112", EdDSAKey.KEY_ALGORITHM); put("Alg.Alias.KeyFactory.OID.1.3.101.112", EdDSAKey.KEY_ALGORITHM); put("Alg.Alias.KeyPairGenerator.1.3.101.112", EdDSAKey.KEY_ALGORITHM); put("Alg.Alias.KeyPairGenerator.OID.1.3.101.112", EdDSAKey.KEY_ALGORITHM); put("Alg.Alias.Signature.1.3.101.112", EdDSAEngine.SIGNATURE_ALGORITHM); put("Alg.Alias.Signature.OID.1.3.101.112", EdDSAEngine.SIGNATURE_ALGORITHM); } }