Skip to content

Commit 93d3803

Browse files
author
Ivan Stoev
committed
Merge branch 'master' of /home/tuba/pclsync
2 parents cd02e53 + 7f13ccb commit 93d3803

File tree

166 files changed

+78453
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

166 files changed

+78453
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.o
2+
*.a

LICENSE

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/* Copyright (c) 2013-2014 Anton Titov.
2+
* Copyright (c) 2013-2014 pCloud Ltd.
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
* * Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* * Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
* * Neither the name of pCloud Ltd nor the
13+
* names of its contributors may be used to endorse or promote products
14+
* derived from this software without specific prior written permission.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
* DISCLAIMED. IN NO EVENT SHALL pCloud Ltd BE LIABLE FOR ANY
20+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
*/
27+

Makefile

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#CC=cc
2+
AR=ar rcu
3+
RANLIB=ranlib
4+
#USESSL=openssl
5+
USESSL=mbed
6+
7+
#CFLAGS=-Wall -Wpointer-arith -O2 -g -fsanitize=address -mtune=core2
8+
CFLAGS=-Wall -Wpointer-arith -O2 -g -fno-stack-protector -fomit-frame-pointer -mtune=core2 -I../sqlite
9+
#CFLAGS=-O2 -g -pg
10+
11+
LIB_A=psynclib.a
12+
13+
ifeq ($(OS),Windows_NT)
14+
CFLAGS += -DP_OS_WINDOWS
15+
LIB_A=psynclib.dll
16+
AR=$(CC) -shared -o
17+
RANLIB=strip --strip-unneeded
18+
LDFLAGS=-s
19+
else
20+
UNAME_S := $(shell uname -s)
21+
UNAME_V := $(shell uname -v)
22+
ifeq ($(UNAME_S),Linux)
23+
CFLAGS += -DP_OS_LINUX
24+
ifneq (,$(findstring Debian,$(UNAME_V)))
25+
CFLAGS += -DP_OS_DEBIAN
26+
endif
27+
LDFLAGS += -lssl -lcrypto -lfuse -lpthread -lsqlite3 -lzlib
28+
endif
29+
ifeq ($(UNAME_S),Darwin)
30+
CFLAGS += -DP_OS_MACOSX -I/usr/local/ssl/include/
31+
CFLAGS += -DP_OS_MACOSX -I/usr/local/include/osxfuse/
32+
LDFLAGS += -lssl -lcrypto -losxfuse -lsqlite3 -framework Cocoa -L/usr/local/ssl/lib
33+
#USESSL=securetransport
34+
endif
35+
endif
36+
37+
OBJ=pcompat.o psynclib.o plocks.o plibs.o pcallbacks.o pdiff.o pstatus.o papi.o ptimer.o pupload.o pdownload.o pfolder.o\
38+
psyncer.o ptasks.o psettings.o pnetlibs.o pcache.o pscanner.o plist.o plocalscan.o plocalnotify.o pp2p.o\
39+
pcrypto.o pssl.o pfileops.o ptree.o ppassword.o prunratelimit.o pmemlock.o pnotifications.o pexternalstatus.o publiclinks.o\
40+
pbusinessaccount.o pcontacts.o poverlay.o poverlay_lin.o poverlay_mac.o poverlay_win.o pcompression.o pasyncnet.o ppathstatus.o
41+
42+
OBJFS=pfs.o ppagecache.o pfsfolder.o pfstasks.o pfsupload.o pintervaltree.o pfsxattr.o pcloudcrypto.o pfscrypto.o pcrc32c.o pfsstatic.o plocks.o
43+
44+
OBJNOFS=pfsfake.o
45+
46+
ifeq ($(USESSL),openssl)
47+
OBJ += pssl-openssl.o
48+
CFLAGS += -DP_SSL_OPENSSL
49+
endif
50+
ifeq ($(USESSL),securetransport)
51+
OBJ += pssl-securetransport.o
52+
CFLAGS += -DP_SSL_SECURETRANSPORT
53+
endif
54+
ifeq ($(USESSL),mbed)
55+
OBJ += pssl-mbedtls.o
56+
CFLAGS += -DP_SSL_MBEDTLS -I../../mbedtls-1.3.10/include/
57+
endif
58+
59+
OBJ1=overlay_client.o
60+
61+
all: $(LIB_A)
62+
63+
$(LIB_A): $(OBJ) $(OBJNOFS)
64+
$(AR) $@ $(OBJ) $(OBJNOFS)
65+
$(RANLIB) $@
66+
67+
fs: $(OBJ) $(OBJFS)
68+
$(AR) $(LIB_A) $(OBJ) $(OBJFS)
69+
$(RANLIB) $(LIB_A)
70+
71+
cli: fs
72+
$(CC) $(CFLAGS) -o cli cli.c $(LIB_A) $(LDFLAGS)
73+
74+
overlay_client:
75+
cd ./lib/poverlay_linux && make
76+
77+
clean:
78+
rm -f *~ *.o $(LIB_A) ./lib/poverlay_linux/*.o ./lib/poverlay_linux/overlay_client
79+

cli.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <stdio.h>
2+
3+
#include "psynclib.h"
4+
5+
int main()
6+
{
7+
psync_init();
8+
psync_start_sync(NULL, NULL);
9+
psync_fs_start();
10+
printf("Press enter to exit/umount\n");
11+
getc(stdin);
12+
psync_fs_stop();
13+
psync_destroy();
14+
return 0;
15+
}

doc/crypto.txt

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
File encryption format
2+
3+
We have a global AES-256 key and 128 bit global (for the file) IV.
4+
5+
Sector = 4096 bytes.
6+
7+
The file is split in 4096-byte blocks. Each block is encrypted using
8+
AES256-CTR.
9+
10+
For every block there's one SIGN 128-bit block, the format for which is:
11+
12+
hmac-sha1
13+
and over it, in the beginning:
14+
2 bits revision length (1, 2 or 3 bytes)
15+
next 6 bits as from hmac-sha
16+
1,2 or 3 bytes revision
17+
18+
the hmac-sha1 is calculated on the following, concatenated:
19+
data;
20+
sector id (64 bit);
21+
revision id (32 bit).
22+
23+
the secret is the per-file IV.
24+
25+
(sector id is the consecutive number of 4k sector of DATA/plaintext in
26+
the file, starting from 0 (zero) )
27+
28+
For the AES256-CTR, the IV is the 128 bit SIGN block.
29+
30+
The SIGN blocks are written for every 256 blocks after them in a 4KB
31+
block, encrypted using AES-ECB. They cannot repeat, as the sector number
32+
is different for each one.
33+
34+
35+
The SIGN blocks create a hash tree. The first level is the SIGN blocks,
36+
the second level is blocks of hmac-sha1 of every 256 lower-level SIGN
37+
blocks (a sector), the third is hmac-sha1 of the lower level of 256
38+
hmac-sha1 blocks, and up to until you're left with only one block, which
39+
is at the end of the file. All such blocks are encrypted with
40+
AES256-ECB.
41+
42+
43+
On every change of a block, the revision is increased with 1. On
44+
revision overflow (2^24) the file SHOULD be reencrypted with a different
45+
IV.
46+
47+
Every read reads at least 4KB, the block with the SIGN block related to
48+
it, and the upper level of the SIGN, to verify them.

lib/poverlay/1.ico

54 KB
Binary file not shown.

lib/poverlay/2.ico

53.6 KB
Binary file not shown.

lib/poverlay/3.ico

54.2 KB
Binary file not shown.

lib/poverlay/ClassDiagram.cd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<ClassDiagram />

lib/poverlay/Guids.h

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/* Copyright (c) 2013 pCloud Ltd.
2+
* All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions are met:
6+
* * Redistributions of source code must retain the above copyright
7+
* notice, this list of conditions and the following disclaimer.
8+
* * Redistributions in binary form must reproduce the above copyright
9+
* notice, this list of conditions and the following disclaimer in the
10+
* documentation and/or other materials provided with the distribution.
11+
* * Neither the name of pCloud Ltd nor the
12+
* names of its contributors may be used to endorse or promote products
13+
* derived from this software without specific prior written permission.
14+
*
15+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18+
* DISCLAIMED. IN NO EVENT SHALL pCloud Ltd BE LIABLE FOR ANY
19+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25+
*/
26+
#pragma once
27+
28+
#pragma warning( disable: 4049 ) /* more than 64k source lines */
29+
30+
31+
#ifdef __cplusplus
32+
extern "C"{
33+
#endif
34+
35+
36+
#include <rpc.h>
37+
#include <rpcndr.h>
38+
39+
#ifdef _MIDL_USE_GUIDDEF_
40+
41+
#ifndef INITGUID
42+
#define INITGUID
43+
#include <guiddef.h>
44+
#undef INITGUID
45+
#else
46+
#include <guiddef.h>
47+
#endif
48+
49+
#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \
50+
DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8)
51+
52+
#else // !_MIDL_USE_GUIDDEF_
53+
54+
#ifndef __IID_DEFINED__
55+
#define __IID_DEFINED__
56+
57+
typedef struct _IID
58+
{
59+
unsigned long x;
60+
unsigned short s1;
61+
unsigned short s2;
62+
unsigned char c[8];
63+
} IID;
64+
65+
#endif // __IID_DEFINED__
66+
67+
#ifndef CLSID_DEFINED
68+
#define CLSID_DEFINED
69+
typedef IID CLSID;
70+
#endif // CLSID_DEFINED
71+
72+
#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \
73+
const type name = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }
74+
75+
#endif !_MIDL_USE_GUIDDEF_
76+
77+
// {8D0C0582-552A-4A6B-9455-DA63E1F329C0}
78+
MIDL_DEFINE_GUID(CLSID, CLSID_pCloud_INSYNC,
79+
0x8d0c0582, 0x552a, 0x4a6b, 0x94, 0x55, 0xda, 0x63, 0xe1, 0xf3, 0x29, 0xc0);
80+
81+
// {3858ED1B-8F1C-42ED-A8A9-FDBF591E3C6B}
82+
MIDL_DEFINE_GUID(CLSID, CLSID_pCloud_NOSYNC,
83+
0x3858ed1b, 0x8f1c, 0x42ed, 0xa8, 0xa9, 0xfd, 0xbf, 0x59, 0x1e, 0x3c, 0x6b);
84+
85+
// {D8BFAFBD-B670-4252-9C17-9CF1C64C2BAF}
86+
MIDL_DEFINE_GUID(CLSID, CLSID_pCloud_INPROGRESS,
87+
0xd8bfafbd, 0xb670, 0x4252, 0x9c, 0x17, 0x9c, 0xf1, 0xc6, 0x4c, 0x2b, 0xaf);
88+
89+
#undef MIDL_DEFINE_GUID
90+
91+
#ifdef __cplusplus
92+
}
93+
#endif
94+
95+

0 commit comments

Comments
 (0)