public new CBORObject EncodeToCBORObject() { CBORObject cborBodyAttributes = null; byte[] rgbBody = null; if (m_msgToSign != null) { if (m_msgToSign.GetType() == typeof(EncryptMessage)) { EncryptMessage msg = (EncryptMessage)m_msgToSign; msg.Encrypt(); CBORObject obj = msg.EncodeToCBORObject(); if (obj[1].Type != CBORType.ByteString) { throw new Exception("Internal error"); } if (obj[3].Type != CBORType.ByteString) { throw new Exception("Internal error"); } rgbBody = obj[3].GetByteString(); cborBodyAttributes = obj[1]; } } else if (m_signerToSign != null) { CBORObject obj = m_signerToSign.EncodeToCBORObject(); } return(base.EncodeToCBORObject(cborBodyAttributes.GetByteString(), rgbBody)); }
public new CBORObject EncodeToCBORObject() { CBORObject cborBodyAttributes = null; byte[] rgbBody = null; if (m_msgToSign != null) { if (m_msgToSign.GetType() == typeof(EncryptMessage)) { EncryptMessage msg = (EncryptMessage)m_msgToSign; msg.Encrypt(); rgbBody = msg.GetEncryptedContent(); } else if (m_msgToSign.GetType() == typeof(Encrypt0Message)) { Encrypt0Message msg = (Encrypt0Message)m_msgToSign; rgbBody = msg.GetEncryptedContent(); if (rgbBody == null) { throw new CoseException("Need to encrypt message before countersignatures can be processed."); } } cborBodyAttributes = m_msgToSign.ProtectedMap; } else if (m_signerToSign != null) { CBORObject obj = m_signerToSign.EncodeToCBORObject(); cborBodyAttributes = m_signerToSign.ProtectedMap; } else { throw new CoseException("Internal state error - NYI"); } CBORObject signed = base.EncodeToCBORObject(cborBodyAttributes.EncodeToBytes(), rgbBody); return(signed[2]); }