|
| 1 | +package org.bouncycastle.jcajce.provider.asymmetric; |
| 2 | + |
| 3 | +import java.io.IOException; |
| 4 | +import java.security.spec.AlgorithmParameterSpec; |
| 5 | +import java.security.spec.InvalidParameterSpecException; |
| 6 | + |
| 7 | +import org.bouncycastle.jcajce.provider.config.ConfigurableProvider; |
| 8 | +import org.bouncycastle.jcajce.provider.util.AsymmetricAlgorithmProvider; |
| 9 | +import org.bouncycastle.jcajce.spec.ContextParameterSpec; |
| 10 | + |
| 11 | +public class CONTEXT |
| 12 | +{ |
| 13 | + private static final String PREFIX = "org.bouncycastle.jcajce.provider.asymmetric" + ".CONTEXT$"; |
| 14 | + |
| 15 | + public static class ContextAlgorithmParametersSpi |
| 16 | + extends java.security.AlgorithmParametersSpi |
| 17 | + { |
| 18 | + private ContextParameterSpec contextParameterSpec; |
| 19 | + |
| 20 | + protected boolean isASN1FormatString(String format) |
| 21 | + { |
| 22 | + return format == null || format.equals("ASN.1"); |
| 23 | + } |
| 24 | + |
| 25 | + protected AlgorithmParameterSpec engineGetParameterSpec( |
| 26 | + Class paramSpec) |
| 27 | + throws InvalidParameterSpecException |
| 28 | + { |
| 29 | + if (paramSpec == null) |
| 30 | + { |
| 31 | + throw new NullPointerException("argument to getParameterSpec must not be null"); |
| 32 | + } |
| 33 | + if (paramSpec != ContextParameterSpec.class) |
| 34 | + { |
| 35 | + throw new IllegalArgumentException("argument to getParameterSpec must be ContextParameterSpec.class"); |
| 36 | + } |
| 37 | + |
| 38 | + return contextParameterSpec; |
| 39 | + } |
| 40 | + |
| 41 | + @Override |
| 42 | + protected void engineInit(AlgorithmParameterSpec algorithmParameterSpec) |
| 43 | + throws InvalidParameterSpecException |
| 44 | + { |
| 45 | + if (!(algorithmParameterSpec instanceof ContextParameterSpec)) |
| 46 | + { |
| 47 | + throw new IllegalArgumentException("argument to engineInit must be a ContextParameterSpec"); |
| 48 | + } |
| 49 | + |
| 50 | + this.contextParameterSpec = (ContextParameterSpec)algorithmParameterSpec; |
| 51 | + } |
| 52 | + |
| 53 | + @Override |
| 54 | + protected void engineInit(byte[] bytes) |
| 55 | + throws IOException |
| 56 | + { |
| 57 | + throw new IllegalStateException("not implemented"); |
| 58 | + } |
| 59 | + |
| 60 | + @Override |
| 61 | + protected void engineInit(byte[] bytes, String s) |
| 62 | + throws IOException |
| 63 | + { |
| 64 | + throw new IllegalStateException("not implemented"); |
| 65 | + } |
| 66 | + |
| 67 | + @Override |
| 68 | + protected byte[] engineGetEncoded() |
| 69 | + throws IOException |
| 70 | + { |
| 71 | + throw new IllegalStateException("not implemented"); |
| 72 | + } |
| 73 | + |
| 74 | + @Override |
| 75 | + protected byte[] engineGetEncoded(String s) |
| 76 | + throws IOException |
| 77 | + { |
| 78 | + throw new IllegalStateException("not implemented"); |
| 79 | + } |
| 80 | + |
| 81 | + @Override |
| 82 | + protected String engineToString() |
| 83 | + { |
| 84 | + return "ContextParameterSpec"; |
| 85 | + } |
| 86 | + } |
| 87 | + |
| 88 | + public static class Mappings |
| 89 | + extends AsymmetricAlgorithmProvider |
| 90 | + { |
| 91 | + public Mappings() |
| 92 | + { |
| 93 | + } |
| 94 | + |
| 95 | + public void configure(ConfigurableProvider provider) |
| 96 | + { |
| 97 | + provider.addAlgorithm("AlgorithmParameters.CONTEXT", PREFIX + "ContextAlgorithmParametersSpi"); |
| 98 | + } |
| 99 | + } |
| 100 | +} |
0 commit comments