|
| 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.KeyFactory; |
| 15 | +import java.security.KeyPairGenerator; |
| 16 | +import java.security.NoSuchProviderException; |
| 17 | +import java.security.Security; |
| 18 | +import java.security.Signature; |
| 19 | + |
| 20 | +import net.i2p.crypto.eddsa.EdDSASecurityProvider; |
| 21 | + |
| 22 | +import org.junit.Rule; |
| 23 | +import org.junit.Test; |
| 24 | +import org.junit.rules.ExpectedException; |
| 25 | + |
| 26 | +/** |
| 27 | + * @author str4d |
| 28 | + * |
| 29 | + */ |
| 30 | +public class EdDSASecurityProviderTest { |
| 31 | + |
| 32 | + @Rule |
| 33 | + public ExpectedException exception = ExpectedException.none(); |
| 34 | + |
| 35 | + @Test |
| 36 | + public void canGetInstancesWhenProviderIsPresent() throws Exception { |
| 37 | + Security.addProvider(new EdDSASecurityProvider()); |
| 38 | + |
| 39 | + KeyPairGenerator keyGen = KeyPairGenerator.getInstance("EdDSA", "EdDSA"); |
| 40 | + KeyFactory keyFac = KeyFactory.getInstance("EdDSA", "EdDSA"); |
| 41 | + Signature sgr = Signature.getInstance("SHA512withEd25519", "EdDSA"); |
| 42 | + |
| 43 | + Security.removeProvider("EdDSA"); |
| 44 | + } |
| 45 | + |
| 46 | + @Test |
| 47 | + public void cannotGetInstancesWhenProviderIsNotPresent() throws Exception { |
| 48 | + exception.expect(NoSuchProviderException.class); |
| 49 | + KeyPairGenerator keyGen = KeyPairGenerator.getInstance("EdDSA", "EdDSA"); |
| 50 | + } |
| 51 | +} |
0 commit comments