Package COSE
Class Signer
- java.lang.Object
-
- COSE.Attribute
-
- COSE.Signer
-
- Direct Known Subclasses:
CounterSign,CounterSign1
public class Signer extends Attribute
The Signer class is used to implement the COSE_Signer object. This provides the information dealing with a single signature for the SignMessage class.Create a Signer object for adding a new signature to a message, existing signers will have a Signer object created for them when a SignMessage object is created by Message.DecodeFromBytes.
Examples of using this class can be found in
Single Signer Example an example of signing and verify a message with a single signature.
Multiple Signer Example an example of signing and verifying a message which has multiple signatures.- Author:
- jimsch
-
-
Field Summary
Fields Modifier and Type Field Description protected StringcontextStringprotected byte[]rgbSignature-
Fields inherited from class COSE.Attribute
DO_NOT_SEND, DontSendAttributes, externalData, objDontSend, objProtected, objUnprotected, PROTECTED, ProtectedAttributes, rgbProtected, UNPROTECTED, UnprotectedAttributes
-
-
Method Summary
Modifier and Type Method Description voidaddCountersignature(CounterSign countersignature)voidclearKey()Remove the key object from the signerprotected voidDecodeFromCBORObject(com.upokecenter.cbor.CBORObject obj)Internal function used in creating a Sign1Message object from a byte string.protected com.upokecenter.cbor.CBORObjectEncodeToCBORObject()Internal function used to create a serialization of a COSE_Sign1 messageCounterSign1getCountersign1()List<CounterSign>getCountersignerList()protected voidProcessCounterSignatures()voidsetCountersign1(CounterSign1 value)voidsetKey(OneKey keyIn)Set a key object on a signervoidsign(byte[] rgbBodyProtected, byte[] rgbContent)booleanvalidate(byte[] rgbBodyProtected, byte[] rgbContent)booleanvalidate(CounterSign countersignature)booleanvalidate(CounterSign1 countersignature)-
Methods inherited from class COSE.Attribute
addAttribute, addAttribute, addAttribute, AddProtected, AddProtected, AddProtected, AddUnprotected, AddUnprotected, AddUnprotected, findAttribute, findAttribute, findAttribute, findAttribute, getDoNotSendAttributes, getExternal, getProtectedAttributes, getUnprotectedAttributes, removeAttribute, removeAttribute, setExternal
-
-
-
-
Field Detail
-
rgbSignature
protected byte[] rgbSignature
-
contextString
protected String contextString
-
-
Constructor Detail
-
Signer
public Signer()
Create a new signer object to add to a SignMessage
-
Signer
public Signer(OneKey key)
Create a new signer object for a SignMessage and set the key to be used.- Parameters:
key- key to use for signing.
-
-
Method Detail
-
clearKey
public void clearKey()
Remove the key object from the signer- Since:
- COSE 0.9.1
-
setKey
public void setKey(OneKey keyIn) throws CoseException
Set a key object on a signer- Parameters:
keyIn- key to be used for signing or verification- Throws:
CoseException- - Invalid key passed in- Since:
- COSE 0.9.1
-
DecodeFromCBORObject
protected void DecodeFromCBORObject(com.upokecenter.cbor.CBORObject obj) throws CoseExceptionInternal function used in creating a Sign1Message object from a byte string.- Parameters:
obj- COSE_Sign1 encoded object.- Throws:
CoseException- Errors generated by the COSE module
-
EncodeToCBORObject
protected com.upokecenter.cbor.CBORObject EncodeToCBORObject() throws CoseExceptionInternal function used to create a serialization of a COSE_Sign1 message- Returns:
- CBOR object which can be encoded.
- Throws:
CoseException- Errors generated by the COSE module
-
sign
public void sign(byte[] rgbBodyProtected, byte[] rgbContent) throws CoseException- Throws:
CoseException
-
validate
public boolean validate(byte[] rgbBodyProtected, byte[] rgbContent) throws CoseException- Throws:
CoseException
-
addCountersignature
public void addCountersignature(CounterSign countersignature)
-
getCountersignerList
public List<CounterSign> getCountersignerList()
-
getCountersign1
public CounterSign1 getCountersign1()
-
setCountersign1
public void setCountersign1(CounterSign1 value)
-
ProcessCounterSignatures
protected void ProcessCounterSignatures() throws CoseException- Throws:
CoseException
-
validate
public boolean validate(CounterSign1 countersignature) throws CoseException
- Throws:
CoseException
-
validate
public boolean validate(CounterSign countersignature) throws CoseException
- Throws:
CoseException
-
-