debugged transport of encrypted items. Still needs work.

This commit is contained in:
csoler 2016-02-15 23:24:18 -05:00
parent 0513e71c68
commit 763108f5fa
3 changed files with 42 additions and 7 deletions

View file

@ -425,6 +425,8 @@ bool RsNxsSessionKeyItem::serialise(void *data, uint32_t& size) const
if(!serialise_header(data,size,tlvsize,offset))
return false ;
ok &= setRawUInt32(data, size, &offset, transactionNumber);
if(offset + EVP_MAX_IV_LENGTH >= size)
{
std::cerr << "RsNxsSessionKeyItem::serialize(): error. Not enough room for IV !" << std::endl;
@ -460,6 +462,7 @@ bool RsNxsEncryptedDataItem::serialise(void *data, uint32_t& size) const
if(!serialise_header(data,size,tlvsize,offset))
return false ;
ok &= setRawUInt32(data, size, &offset, transactionNumber);
ok &= aes_encrypted_data.SetTlv(data, size, &offset) ;
if(offset != tlvsize)
@ -840,6 +843,8 @@ RsNxsSessionKeyItem *RsNxsSerialiser::deserialNxsSessionKeyItem(void* data,
uint32_t offset = 8 ;
RsNxsSessionKeyItem* item = new RsNxsSessionKeyItem(SERVICE_TYPE);
ok &= getRawUInt32(data, *size, &offset, &(item->transactionNumber));
if(offset + EVP_MAX_IV_LENGTH >= *size)
{
@ -891,6 +896,9 @@ RsNxsEncryptedDataItem *RsNxsSerialiser::deserialNxsEncryptedDataItem(void* da
RsNxsEncryptedDataItem* item = new RsNxsEncryptedDataItem(SERVICE_TYPE);
ok &= getRawUInt32(data, *size, &offset, &(item->transactionNumber));
item->aes_encrypted_data.tlvtype = TLV_TYPE_BIN_ENCRYPTED ;
ok &= item->aes_encrypted_data.GetTlv(data,*size,&offset) ;
if (offset != *size)
@ -1037,6 +1045,7 @@ uint32_t RsNxsEncryptedDataItem::serial_size() const
{
uint32_t s = 8; // header size
s += 4; // transaction number
s += aes_encrypted_data.TlvSize() ;
return s;
@ -1045,6 +1054,7 @@ uint32_t RsNxsSessionKeyItem::serial_size() const
{
uint32_t s = 8; // header size
s += 4; // transaction number
s += EVP_MAX_IV_LENGTH ; // iv
s += 4 ; // encrypted_session_keys.size() ;

View file

@ -277,7 +277,11 @@ class RsNxsEncryptedDataItem : public RsNxsItem
public:
RsNxsEncryptedDataItem(uint16_t servtype) : RsNxsItem(servtype, RS_PKT_SUBTYPE_NXS_SESSION_KEY_ITEM),aes_encrypted_data(servtype) { clear(); }
RsNxsEncryptedDataItem(uint16_t servtype) : RsNxsItem(servtype, RS_PKT_SUBTYPE_NXS_ENCRYPTED_DATA_ITEM),aes_encrypted_data(servtype)
{
aes_encrypted_data.tlvtype = TLV_TYPE_BIN_ENCRYPTED ;
clear();
}
virtual ~RsNxsEncryptedDataItem() {}
virtual bool serialise(void *data,uint32_t& size) const;