CounterSign1.java
/*
s * To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.eclipse.californium.cose;
import com.upokecenter.cbor.CBORObject;
import com.upokecenter.cbor.CBORType;
/**
*
* @author Jim
*/
public class CounterSign1 extends Signer {
public CounterSign1()
{
contextString = "CounterSignature0";
}
public CounterSign1(byte[] rgb) {
contextString = "CounterSignature0";
rgbSignature = rgb;
rgbProtected = new byte[0];
}
public CounterSign1(OneKey key) {
super(key);
contextString = "CounterSignature0";
}
@SuppressWarnings("unused")
private Message m_msgToSign;
@SuppressWarnings("unused")
private Signer m_signerToSign;
public void setObject(Message msg)
{
m_msgToSign = msg;
}
public void setObject(Signer signer)
{
m_signerToSign = signer;
}
@Override
public void DecodeFromCBORObject(CBORObject cbor) throws CoseException {
if (cbor.getType() != CBORType.ByteString) {
throw new CoseException("Invalid format for Countersignature0");
}
rgbSignature = cbor.GetByteString();
rgbProtected = new byte[0];
}
public CBORObject EncodeToCBORObject() throws CoseException {
if (!objProtected.getValues().isEmpty() || !objUnprotected.getValues().isEmpty()) {
throw new CoseException("CoutnerSign1 object cannot have protected or unprotected attributes");
}
return CBORObject.FromObject(rgbSignature);
}
}