3.2.7.2 Session Socket Successfully Set Up
When a Share Sender's Socket object has been successfully set up (section 3.1.7), the Share Sender state MUST transition to SendingBody, and the following actions MUST be performed:
Create a Share header (section 2.2.2) with the following values:
HeaderSize: The value 10 in little-endian encoding (0x0A, 0x00). No other value is valid.
TotalContentSizeEstimate: An estimate of the size of the OPC package. If an estimate cannot be determined, this value MUST be zero.
Send the Share header over the Socket.
Synchronously read 2 bytes for the HeaderSize field of a Reply header (section 2.2.3) from the Socket.
Interpret the 2 bytes as a little-endian encoded 16-bit unsigned integer that specifies how many bytes to read for the rest of the message.
If nonzero length, synchronously read (HeaderSize – 2) bytes from the Socket.
Note If the HeaderSize is exactly 2, there is nothing to read.
Set the Share Sender's SymmetricKey element to a 128-bit key derived by taking the SHA256 hash of the Session object's SharedSecretKey element.
Send the IV as the first block on the Socket.
The Near Field Proximity: Sharing Protocol requires a specific encryption scheme. Each block MUST be encrypted by using a standard AES 128-block cipher with the IV and SymmetricKey objects as input.
Each complete block (16 full bytes) of the OPC package MUST be encrypted and then sent on the Socket.
After all complete blocks of data have been encrypted and sent, the following actions MUST be performed:
Create a Share Protocol footer (section 2.2.4) and initialize to all zeros.
Place any remaining (less than 16 bytes) OPC package data at the beginning of the Share Protocol footer.
Set the RemainderLength field to be the number of OPC package data bytes placed into the Share Protocol footer.
Encrypt the three final blocks that comprise the Share Protocol footer.
Send the final three blocks that comprise the Share Protocol footer on the Socket.
Gracefully close the Socket.