PTPSecureClient can be used to connect to PTPSecureServer and execute some commands, in particular, it can be used to download and upload remote files.
CCore-PTPSecureClient.exe <config.dll>
To run the PTPSecureClient you must specify a configuration file as the argument. This file uses DDL to describe various client parameters. Here is an example:
PTPSecureConfig config = { .server_key = { Key#SHA512 , { 000h, 019h, 09Bh, 0FAh, 013h, 064h, 0D0h, 0F4h, 061h, 01Eh, 055h, 050h, 057h, 052h, 0FBh, 00Ch, 04Ah, 0A0h, 04Ah, 0F2h, 083h, 037h, 06Eh, 001h, 050h, 013h, 06Dh, 0B1h, 004h, 0A7h, 082h, 010h } }, .name = 'Sergey', .key = { Key#SHA512 , { 032h, 0E3h, 095h, 080h, 0D7h, 029h, 06Ch, 0F5h, 00Fh, 027h } } };
A configuration file must define a constant of the type PTPSecureConfig with the name config. This type is defined as the following:
struct Key { const uint8 SHA1 = 0 ; const uint8 SHA224 = 1 ; const uint8 SHA256 = 2 ; const uint8 SHA384 = 3 ; const uint8 SHA512 = 4 ; uint8 hash_id; uint8[] key; }; struct PTPSecureConfig { uint16 server_pke_port = 52102 ; uint16 server_psec_port = 52103 ; uint16 pke_port = 52100 ; uint16 psec_port = 52101 ; uint16 keyset_len = 10 ; uint32 ttl = 3600 ; uint32 utl = 100000000 ; ip server_ip = 127.0.0.1 ; Key server_key; text name; Key key; };
server_pke_port is the server UDP port for the PKE communication.
server_psec_port is the server UDP port for the PSec communication.
pke_port is the client UDP port for the PKE communication.
psec_port is the client UDP port for the PSec communication.
keyset_len is the number of keys in the session keyset.
ttl is the lifetime limit for the session key.
utl is the traffic limit for the session key.
ip is the IP address of the server.
server_key is the server primary key.
name is the client name in the server client database.
key is the client primary key.
A primary key is described by the structure Key with two fields:
hash_id determines the hash algorithm. One of the predefined constants can be used: SHA1, SHA224, SHA256, SHA384, SHA512.
key is a byte sequence key.
Once client is started, it tries to establish a connection to the server. If it is done it opens a console prompt to enter commands.
--- Copyright (c) 2015 Sergey Strukov. All rights reserved. --- Server PKE port = 52102 Server PSec port = 52103 PKE port = 52100 PSec port = 52101 Keyset len = 10 TTL = 3600 sec UTL = 100000000 bytes Server IP = 127.0.0.1 Client name = Sergey /> dir ----- . .. home ----- /> pwd / /> cd ~ ~> dir ----- . .. temp ----- ~> cd temp ~/temp> dir ----- . .. ----- ~/temp> mkfile temp.txt ~/temp> dir ----- . .. ----- temp.txt ~/temp>
The following commands are accepted:
pwd prints the current directory on the server file tree. This directory is also printed in the prompt string.
dir [<path>] shows the content of the given directory or the current directory if the path is not specified.
cd <path> changes the current directory.
mkdir <path> makes the new directory.
rmdir [-r] <path> removes the existing directory. If the option -r is specified the directory is removed with all its content.
mkfile <path> makes the empty file.
del <path> deletes the existing file.
type <path> types the file content.
add <path> <line> adds the given line to the file.
put <local file> <path> uploads the file to the server. The local file is searched with respect to the working directory of the client.
get <local file> <path> downloads the file from the server. The local file is searched with respect to the working directory of the client.
fileinfo <path> prints the file type and the last modification file time.
help prints the list of commands.