summaryrefslogtreecommitdiff
path: root/sys/src/liboventi/venti.txt
blob: 3e1a8c78513664ac699a5d77f4a7316f6bc2beaa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
protocol version id

both client and server send '\n' terminated ascii of the form

venti-<versions>-<software>


<software> = is a software id which is ignored but may be useful for debugging

If the server and client have the same version number then this
version is used.  Otherwise backup to the greatest common
major version number, e.g. 1.00 2.00 etc.  If no version in
common then abort.  The idea is both client and server should
support a continusous range of major versions.  The minor version
numbers are used for development purposes.

After protocol negotiation switch to binary format

all numbers sent big endian

strings are sent with 2 byte length without nulls and in utf-8 max size of 1K

RPC protocol

header 
	op[1]	byte op
	tid[2]	transation id

client manages the tid space.  Until session is established tid must equal 0.
i.e. only one outstanding op.

CipherStrength
	None,
	Auth,
	Weak,
	Strong
CipherAlgorithms
	None
	SSL3
	TLS1
CompressionAlgorithms
	None
	Deflate
	Thwack?

BlockTypes
	Root
	Pointer
	Data

==============================================

TPing
RPing

RError
	error: string

THello
	version:string;		know to be supported by both
	uid: string
	uhash[20]		use for cipher boot strapping
	cipherstrength[1]
	ncipher[1];
	cipher[ncipher];
	ncompressor[1];
	compressor[ncompressor];
RHello
	sid: string
	shash[20];		use for cipher bott strapping
	cipher[1];
	compressor[1];

use srp style authentication
	g=2
	N is safe prime 1024 bits - find a good prime!

	x = H("venti" H(sid) H(uid) H(password))
	v = g^x
	a = random
	b = random
	B = (v + g^b)
	A = g^a
	u = first four bytes of H(B)
	S = (B - g^x) ^ (a + u*x) = (A * v^u) ^ b
	K = H(S)
	M1 = H(H(versions) H(THello) H(RHello) A B K)
	M2 = H(A M1 K)

TAuth0
	A[128]
RAuth0
	B[128]
TAuth1
	M1[20]
RAuth1
	M2[20]

push cipher
push compression

TWrite
	length[2] max 56*1024
	type[1]
	data[length]
RWrite
	hash[20]

TRead
	hash[20]
	type[1]
	length[2]
RRead
	length[2]
	data[length]

============================================================

simplified access when trusting the server
reduces network bandwidth since pointer blocks are not
sent to the client - can also enable permission checking

RReadRoot
	root[20]
TReadRoot
	name: string
	type: string
	blocksize[2]
	nblock[8]
	time[4]
	uid: string;
	gid: string

RReadData
	root[20]
	block[8]
	length[2]
TReadData
	length[2]
	collision[1]
	data[length]

==============================================

maybe some clients should be required to navigate to block via root nodes.
This would enable permission checking via access to the root node.

RTagOpen
	tag[2]
	root[20]
TTagOpen

QTagRead
	tag[2]
	type[1]
	length[2]
RTagRead
	length[2]
	data[length]
	
QTagWalkRead
	tag[2]
	ntag[2]		can reuse a tag to do an implict clunk
	index[2]
	type[1]
	length[2]
RTagWalkRead
	length[2]
	data[length]

RTagClunk
	tag[2]
TTagClunk

============================

Types of blocks

Data

Root
	name[128]
	type[128]
	score[20]	- DirBlock

Pointer
	score[20]*	the number of hashes can be less than fanout when the
			tree is not full
DirBlock
	DirEntry[32]*

DirEntry	
	pointersize[2]	- pointer block size
	datasize[2]	- data blocks size
	flag[1]		directory
	size[7]		in bytes - determines pointer depth - intermidate truncated block count as full
	score[20]	root of pointer blocks or data block 

============================

mode flags
	(1<<0)	ModeOtherExec
	(1<<1)	ModeOtherWrite
	(1<<2)	ModeOtherRead
	(1<<3)	ModeGroupExec
	(1<<4)	ModeGroupWrite
	(1<<5)	ModeGroupRead
	(1<<6)	ModeOwnerExec
	(1<<7)	ModeOwnerWrite
	(1<<8)	ModeOwnerRead
	(1<<9)	ModeSticky
	(1<<10)	ModeSetUid
	(1<<11)	ModeSetGid
	(1<<12)	ModeAppend
	(1<<13)	ModeExclusive
	(1<<14)	ModeLink
	(1<<15)	ModeDir	- duplicates dir entry
	(1<<16) ModeHidden
	(1<<17) ModeSystem
	(1<<18) ModeArchive
	(1<<19) ModeTemporary
	(1<<18) ModeCompressed
	(1<<19) ModeEncrypted

extraType
	2	Plan9
	version[4]
	muid: string

	3 NT Time
	createTime[8];
	modifyTime[8];
	accessTime[8]
	

MetaEntry
	name: string	/* must be first */
	direntry[4]

	id[8]

	uid: string
	gui: string
	mtime[4]
	ctime[4]
	atime[4]
	
	mode[4] 
	
	extratype;
	extrasize[2]
	extra:[nextra]

MetaEntry Block
	magic[4]
	size[2]
	free[2]	- used to determine if work compacting
	maxindex[2] - size of index table in bytes
	nindex[2]
	index[2*nindex]

per OS directory entries?

inode...