Commit Graph

32 Commits

Author SHA1 Message Date
akwizgran
46ed0cc4b1 Minor changes to serialisation library (mostly renaming). 2012-05-09 13:17:04 +02:00
akwizgran
78e18fb373 Simplified serialisation format. 2012-05-08 11:02:49 +02:00
akwizgran
f9f41acde9 Added a connection registry to avoid creating redundant connections. 2011-12-09 17:34:58 +00:00
akwizgran
f7360cddde Renamed "user-defined types" as "structs" in the serialisation format. 2011-12-02 11:36:45 +00:00
akwizgran
4da7a685cd Minor code cleanups. 2011-11-16 18:15:32 +00:00
akwizgran
df054b1743 Store each connection window slot as a database row.
This is less memory-efficient but necessary for the coming forward
secrecy changes.
2011-11-15 13:08:20 +00:00
akwizgran
73aa7d14d7 Split transport identifiers into two: TransportId (globally unique)
and TransportIndex (locally unique).

This is the first step towards forward secrecy. Also removed the
Writable interface and unnecessary user-defined types, moved various
constants to ProtocolConstants and renamed some classes.
2011-11-14 21:40:05 +00:00
akwizgran
8940dc83cb Replaced assertTrue(Arrays.equals()) with assertArrayEquals(). 2011-10-05 17:07:52 +01:00
akwizgran
a8b96f11fd Added Consumer support to Writer, to avoid redundant copying. 2011-09-28 18:47:24 +01:00
akwizgran
b65d6631f1 Removed writer's count of bytes written and renamed a method. 2011-09-21 18:22:14 +01:00
akwizgran
70b1487140 Renamed user-defined tags "user-defined type identifiers". 2011-09-12 16:32:25 +01:00
akwizgran
e80ede4429 Map keys must be unique. 2011-09-07 11:04:03 +01:00
akwizgran
2411e2008b Frame the encrypted data independently of inter-packet boundaries and
authenticate each frame before parsing its contents. Each connection
starts with a tag, followed by any number of frames, each starting
with the frame number (32 bits) and payload length (16 bits), and
ending with a MAC (256 bits).

Tags have the following format: 32 bits reserved, 16 bits for the
transport ID, 32 bits for the connection number, 32 bits (set to zero
in the tag) for the frame number, and 16 bits (set to zero in the tag)
for the block number. The tag is encrypted with the tag key in
ECB mode.

Frame numbers for each connection must start from zero and must be
contiguous and strictly increasing. Each frame is encrypted with the
frame key in CTR mode, using the plaintext tag with the appropriate
frame number to initialise the counter.

The maximum frame size is 64 KiB, including header and footer. The
maximum amount of data that can be sent over a connection is 2^32
frames - roughly 2^48 bytes, or 8 terabytes, with the maximum frame
size of 64 KiB. If that isn't sufficient we can add another 16 bits to
the frame counter.
2011-08-19 01:46:51 +02:00
akwizgran
254da2da27 Removed the restriction that transport updates have to be written in
delimited form.
2011-08-14 11:41:56 +02:00
akwizgran
7545a1cc8f Moved Bytes to the main package. Added a SharedSecret class to parse
encrypted secrets retrieved from the database.
2011-08-11 19:14:20 +01:00
akwizgran
5be9d953ee Use fail() instead of assertTrue(false). 2011-08-03 21:19:04 +01:00
akwizgran
c90a18278b Allow a maximum length to be specified when reading strings or byte
arrays, check it before allocating the buffer, and always specify the
maximum length when reading untrusted data - otherwise
CountingConsumer will reject the packet, but not before we've tried to
allocate a buffer of the specified size (up to 2 GB).
2011-08-03 19:29:30 +01:00
akwizgran
c98c968b87 Removed unnecessary Raw interface. 2011-07-24 17:47:17 +01:00
akwizgran
a573e87c04 ReaderImpl now maintains either one or two bytes of lookahead,
depending on the value of the first byte, so that an object's initial
tag is included in the data seen by the ObjectReader. Digests and
signatures can therefore be calculated over objects by their readers
without any risk of ambiguity.
2011-07-22 17:39:59 +01:00
akwizgran
45b4bef348 Catch ClassCastException when the encountered type doesn't match the
expected type, and re-throw as FormatException.
2011-07-20 15:07:17 +01:00
akwizgran
6b61cfa1bc Factored out header reading and batch reading into separate classes
for easier testing.
2011-07-19 19:13:27 +01:00
akwizgran
fb528a85ad Nested user-defined objects (and collections of them) can now be read
by registering ObjectReaders with the Reader.
2011-07-19 17:17:45 +01:00
akwizgran
30fc6c1a92 Defined some user-defined tags for protocol elements. Currently they're just adding redundancy, but in future they'll be used for parsing nested elements. 2011-07-18 17:44:18 +01:00
akwizgran
427142ae51 Read and write user-defined tags. 2011-07-18 16:46:03 +01:00
akwizgran
7a4171f3ba A more efficient encoding for short strings, raws, lists and maps. Now we can encode a list of three small integers in 4 bytes like MessagePack does, should that ever turn out to be useful. 2011-07-18 16:06:09 +01:00
akwizgran
0bc8a31749 Cleaned up serial and protocol packages in preparation for user-defined types. 2011-07-18 14:33:41 +01:00
akwizgran
836d30f6df Retrieve messages from the database in raw form to avoid creating unnecessary short-lived objects. Added timestamps to headers. 2011-07-14 12:01:35 +01:00
akwizgran
c3643a037b Added accessors for the amount of raw data read and written by readers and writers - this fixes a fixme in MessageParserImpl. 2011-07-12 20:27:37 +01:00
akwizgran
4977695a79 Refactored readers and writers. 2011-07-12 11:28:26 +01:00
akwizgran
51e371f7ca Added start/end methods for writing indefinite lists and maps. 2011-07-11 10:07:01 +01:00
akwizgran
0f4ffe9fbc Added type-safe accessors and iterator accessors for lists and maps. 2011-07-10 18:31:18 +01:00
akwizgran
1f5e52c31b Modifying Protocol Buffers (or Thrift, or MessagePack, or any of the free ASN.1 implementations I could find) to support length constraints was more work than writing a custom serialisation format, so I wrote a custom format. 2011-07-10 14:44:15 +01:00