Skip to content

Commit b8641e6

Browse files
committed
Update to new version of CBOR-JAVA
Update to newest version of CBOR-JAVA to deal with the latest security bug in the library.
1 parent d3a8ef0 commit b8641e6

File tree

6 files changed

+19
-12
lines changed

6 files changed

+19
-12
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.augustcellars.cose</groupId>
88
<artifactId>cose-java</artifactId>
9-
<version>0.9.10</version>
9+
<version>1.0.0</version>
1010

1111
<name>com.augustcellars.cose:cose-java</name>
1212
<description>A Java implementation that supports the COSE secure message specification.</description>
@@ -109,7 +109,7 @@
109109
<dependency>
110110
<groupId>com.upokecenter</groupId>
111111
<artifactId>cbor</artifactId>
112-
<version>3.5.0</version>
112+
<version>4.0.1</version>
113113
</dependency>
114114

115115
<dependency>

src/main/java/COSE/Attribute.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public class Attribute {
111111

112112
public void addAttribute(CBORObject label, CBORObject value, int where) throws CoseException {
113113
removeAttribute(label);
114-
if ((label.getType() != CBORType.Number) && (label.getType() != CBORType.TextString)) {
114+
if ((label.getType() != CBORType.Integer) && (label.getType() != CBORType.TextString)) {
115115
throw new CoseException("Labels must be integers or strings");
116116
}
117117
switch (where) {

src/main/java/COSE/CounterSign1.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ public CounterSign1(byte[] rgb) {
2727
public CounterSign1(OneKey key) {
2828
super(key);
2929
contextString = "CounterSignature0";
30+
objUnprotected.Clear();
31+
objProtected.Clear();
3032
}
3133

3234
private Message m_msgToSign;
@@ -42,6 +44,11 @@ public void setObject(Signer signer)
4244
m_signerToSign = signer;
4345
}
4446

47+
public void setKey(OneKey key)
48+
{
49+
cnKey = key;
50+
}
51+
4552
@Override
4653
public void DecodeFromCBORObject(CBORObject cbor) throws CoseException {
4754
if (cbor.getType() != CBORType.ByteString) {
@@ -54,7 +61,7 @@ public void DecodeFromCBORObject(CBORObject cbor) throws CoseException {
5461

5562
public CBORObject EncodeToCBORObject() throws CoseException {
5663
if (!objProtected.getValues().isEmpty() || !objUnprotected.getValues().isEmpty()) {
57-
throw new CoseException("CoutnerSign1 object cannot have protected or unprotected attributes");
64+
throw new CoseException("CounterSign1 object cannot have protected or unprotected attributes");
5865
}
5966

6067
return CBORObject.FromObject(rgbSignature);

src/main/java/COSE/OneKey.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public CBORObject get(KeyKeys keyValue) {
140140
}
141141

142142
public CBORObject get(CBORObject keyValue) throws CoseException {
143-
if ((keyValue.getType() != CBORType.Number) && (keyValue.getType() != CBORType.TextString)) throw new CoseException("keyValue type is incorrect");
143+
if ((keyValue.getType() != CBORType.Integer) && (keyValue.getType() != CBORType.TextString)) throw new CoseException("keyValue type is incorrect");
144144
return keyMap.get(keyValue);
145145
}
146146

@@ -232,13 +232,13 @@ public boolean HasKeyOp(Integer that) {
232232
result = (thisObj == null);
233233
} else {
234234
result = false;
235-
if (thisObj.getType() == CBORType.Number) {
235+
if (thisObj.getType() == CBORType.Integer) {
236236
if (thisObj.AsInt32() == that) {
237237
result = true;
238238
}
239239
} else if (thisObj.getType() == CBORType.Array) {
240240
for (int i = 0; i < thisObj.size(); i++) {
241-
if ((thisObj.get(i).getType() == CBORType.Number) && (thisObj.get(i).AsInt32() == that)) {
241+
if ((thisObj.get(i).getType() == CBORType.Integer) && (thisObj.get(i).AsInt32() == that)) {
242242
result = true;
243243
break;
244244
}
@@ -253,7 +253,7 @@ private void CheckKeyState() throws CoseException {
253253

254254
// Must have a key type
255255
val = OneKey.this.get(KeyKeys.KeyType);
256-
if ((val == null) || (val.getType() != CBORType.Number)) throw new CoseException("Missing or incorrect key type field");
256+
if ((val == null) || (val.getType() != CBORType.Integer)) throw new CoseException("Missing or incorrect key type field");
257257

258258
if (val.equals(KeyKeys.KeyType_Octet)) {
259259
val = OneKey.this.get(KeyKeys.Octet_K);
@@ -652,7 +652,7 @@ else if (val.equals(KeyKeys.KeyType_OKP)) {
652652

653653
for (CBORObject obj : keyMap.getKeys()) {
654654
val = keyMap.get(obj);
655-
if (obj.getType() == CBORType.Number) {
655+
if (obj.getType() == CBORType.Integer) {
656656
if (obj.AsInt32() > 0) {
657657
newKey.add(obj, val);
658658
}

src/test/java/COSE/RegressionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@ public byte[] hexStringToByteArray(String s) {
985985

986986
static CBORObject AlgorithmMap(CBORObject old)
987987
{
988-
if (old.getType() == CBORType.Number) {
988+
if (old.getType() == CBORType.Integer) {
989989
return old;
990990
}
991991

src/test/java/COSE/SignWikiTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,13 @@ public static boolean MultiValidateSignedMessage(byte[] message, KeySet keys, bo
157157

158158
CBORObject ops = k.get(KeyKeys.Key_Ops);
159159
if (ops != null) {
160-
if (ops.getType() == CBORType.Number) {
160+
if (ops.getType() == CBORType.Integer) {
161161
if (ops.AsInt32() != 2) continue;
162162
}
163163
else if (ops.getType() == CBORType.Array) {
164164
boolean found = false;
165165
for (int i=0; i<ops.size(); i++) {
166-
if ((ops.get(i).getType() == CBORType.Number) && (ops.get(i).AsInt32() == 2)) {
166+
if ((ops.get(i).getType() == CBORType.Integer) && (ops.get(i).AsInt32() == 2)) {
167167
found = true;
168168
break;
169169
}

0 commit comments

Comments
 (0)