|
5 | 5 | import java.io.IOException; |
6 | 6 |
|
7 | 7 | import org.bouncycastle.asn1.ASN1Encodable; |
| 8 | +import org.bouncycastle.asn1.ASN1Enumerated; |
8 | 9 | import org.bouncycastle.asn1.ASN1InputStream; |
| 10 | +import org.bouncycastle.asn1.ASN1Integer; |
9 | 11 | import org.bouncycastle.asn1.ASN1OutputStream; |
10 | 12 | import org.bouncycastle.asn1.ASN1Primitive; |
11 | 13 | import org.bouncycastle.asn1.BERSequence; |
@@ -67,6 +69,46 @@ public void shouldFailOnExtraData() |
67 | 69 | } |
68 | 70 | } |
69 | 71 |
|
| 72 | + public void derIntegerTest() |
| 73 | + throws Exception |
| 74 | + { |
| 75 | + try |
| 76 | + { |
| 77 | + new ASN1Integer(new byte[] { 0, 0, 0, 1}); |
| 78 | + } |
| 79 | + catch (IllegalArgumentException e) |
| 80 | + { |
| 81 | + isTrue("wrong exc", "malformed integer".equals(e.getMessage())); |
| 82 | + } |
| 83 | + |
| 84 | + try |
| 85 | + { |
| 86 | + new ASN1Integer(new byte[] {(byte)0xff, (byte)0x80, 0, 1}); |
| 87 | + } |
| 88 | + catch (IllegalArgumentException e) |
| 89 | + { |
| 90 | + isTrue("wrong exc", "malformed integer".equals(e.getMessage())); |
| 91 | + } |
| 92 | + |
| 93 | + try |
| 94 | + { |
| 95 | + new ASN1Enumerated(new byte[] { 0, 0, 0, 1}); |
| 96 | + } |
| 97 | + catch (IllegalArgumentException e) |
| 98 | + { |
| 99 | + isTrue("wrong exc", "malformed enumerated".equals(e.getMessage())); |
| 100 | + } |
| 101 | + |
| 102 | + try |
| 103 | + { |
| 104 | + new ASN1Enumerated(new byte[] {(byte)0xff, (byte)0x80, 0, 1}); |
| 105 | + } |
| 106 | + catch (IllegalArgumentException e) |
| 107 | + { |
| 108 | + isTrue("wrong exc", "malformed enumerated".equals(e.getMessage())); |
| 109 | + } |
| 110 | + } |
| 111 | + |
70 | 112 | public void performTest() |
71 | 113 | throws Exception |
72 | 114 | { |
@@ -115,6 +157,7 @@ public void performTest() |
115 | 157 | } |
116 | 158 |
|
117 | 159 | shouldFailOnExtraData(); |
| 160 | + derIntegerTest(); |
118 | 161 | } |
119 | 162 |
|
120 | 163 | public String getName() |
|
0 commit comments