Browse Source

devicechannel: decrypt encrypted data

bboozzoo/device-cache
Maciek Borzecki 10 years ago
parent
commit
bd2e59e9e0
1 changed files with 17 additions and 0 deletions
  1. +17
    -0
      src/devicechannel.vala

+ 17
- 0
src/devicechannel.vala View File

@ -142,6 +142,23 @@ class DeviceChannel : Object {
}
private void handle_encrypted_packet(Packet pkt) {
// Ecypted packets have 'data' member in body. The 'data'
// member is an array of strings, each string is base64
// encoded data, of length appropriate for channel ecryption
// method.
Json.Array arr = pkt.body.get_array_member("data");
if (arr == null) {
critical("missing data member in encrypted packet");
return;
}
var msgbytes = new ByteArray();
arr.foreach_element((a, i, node) => {
debug("node data: %s", node.get_string());
uchar[] data = Base64.decode(node.get_string());
var dbytes = new Bytes.take(data);
Bytes decrypted = this._crypt.decrypt(dbytes);
msgbytes.append(decrypted.get_data());
});
}
}

Loading…
Cancel
Save