Appendix

Diffie-Hellman Usage notes

Request: Connect, Input parameter: PublicKey

Base64 encoded byte array representing the public key constructed by the client. The key generation parameters shall be the SKIP modulus 1024 or 2048 ones, which means that the byte array will have a length of 128/256. Before being sent to the server. The byte array shall be arranged in little-endian order: That is the least significant byte shall be at index 0, the most significant one at index 127. At index 128 a zero byte should be added before the resulting 129 bytes are base64 encoded. If the most significant byte is < 0x80, the zero byte may be omitted.

Response: Connect, Output parameter: PublicKey

Base64 encoded byte array representing the public key constructed by the server. The key generation parameters shall be the SKIP modulus 1024 or 2048 ones, which means that the byte array will have a length of 128/256. Before being sent by the server, the byte array shall be arranged in little-endian order: That is the least significant byte shall be at index 0, the most significant one at index 127. At index 128 a zero byte should be added before the resulting 129 bytes are base64 encoded. If the most significant byte is < 0x80, the zero byte may be omitted.

Both the server and the client will now use the Diffie-Hellman algorithm to generate the same shared secret key. Each side uses its own private key and the opposite side's public key. Be careful when converting keys from strings to big integer objects, you may need to reverse it. The zero bytes appended above are to ensure that little-endian systems decode the byte array correctly into a positive big integer number.

Request: LogIn, Input parameter: Username, Password

Base64 encoded byte array, holding an encrypted representation of the user name/password. The encryption method must be AES using CBC for chaining and PKCS7 for padding. The initialization vector (IV) is constructed from the 16 least significant bytes of the shared secret, the least significant byte at index 0, the next-to-least significant byte at index 1 and so on. The encryption key is constructed from the 17th – 32nd least significant bytes of the shared secret, the 17th least significant byte at index 0, the 18th least significant byte at index 1 and so on.

Command error codes

If not successful, command response will output subset of the following:

0 = OK
1 = Not implemented
2 = Not fully implemented

10 = Bad command type
11 = Bad command name
12 = Wrong connection ID
13 = Missing input parameter
14 = Wrong input parameter
15 = Incorrect user password
16 = Incorrect public key
17 = Surveillance server down
18 = License not valid
19 = Security error
20 = Unknown camera ID
21 = Unknown item ID
22 = No presets available
23 = Not allowed in this state
24 = Feature is disabled
25 = Insufficient user rights
26 = User limitation reached
27 = New configuration not available
28 = Addresses not reachable
29 = Playback streams limit reached

30 = Redirection

31 = Temporary Unavailable
32 = No Recordings found
33 = No Recordings found in specified time interval
34 = SecondStepVerificationRequired
35 = OnlyUsersWithTwoStepsVerificationAreAllowed
36 = IncorrectSecondStepVerificationCode
37 = SecondStepVerificationCodeHasExpired
38 = FileSizeOverLimit
39 = FileTypeNotAllowed
40 = ParserError
41 = BadMethodType
42 = NoDataInRequest

43 = InputParameterTooLong
44 = MaximumLiveConnectionsLimitationReached

50 = AccessControlCommandFailed
51 = MaxChallengesLimitationReached
52 = UknownIdOrInsufficientRightForSomeItems
53 = UknownIdOrInsufficientRightForAllItems
54 = ItemNotPlayable
55 = FeatureNoLongerSupported

60 = ChangePassword
61 = AccountLockedOut
62 = TimeOutOfRange

Unknown - 21 = Incorrect server response
Unknown - 20 = Sdk not connected

Unknown - 11 = Http response error
Unknown - 10 = Http request error

0x7FFFFFFF = Unknown

Unknown – 2 = Command timed out
Unknown – 1 = Internal Error

Export success codes

Success codes that are returned when creating an export completes:

0 = Export has been queued for processing
1 - 99 = Export is under processing (number shows percentage)
100 = Export has been completed
101 = Export is ready to be downloaded

Export error codes

Error codes that are returned as OutputParameter if creating an export fails:

-1 = Error occurred during the export operation.

-10 = Export not performed due to folder size limitation reached.
-11 = Unsupported export type.
-12 = Export stopped by user.
-13 = No video in selected time (Valid only for AVI exports).
-14 = Insufficient user rights for one of more devices.

-101 = Error opening video stream from image server.
-102 = Error opening audio stream from image server.
-103 = Error initializing export (parameters are wrong).
-104 = Error starting AVI encoder.
-105 = Error getting next image from image stream.
-106 = Error getting audio from audio stream.
-107 = Error adding image to AVI encoder.
-108 = Error adding audio to AVI encoder.
-109 = Export has been cancelled.
-110 = Unknown error.

-201 = Detailed error export canceled.
-202 = Detailed error cannot write file
-203 = Detailed error cannot override existing file
-204 = Detailed error cannot create destination file.
-205 = Detailed error invalid file name.
-206 = Detailed error getting video from source.
-207 = Detailed error setting video format.
-208 = Detailed error setting video dimentions.
-209 = Detailed error starting video encoder.
-210 = Detailed error encoding video.
-211 = Detailed error unexpected failiure during video export.
-212 = Detailed error video stream already open.
-213 = Detailed error cannot connect to video source.
-214 = Detailed error setting audio format.
-215 = Detailed error starting audio encoder.
-216 = Detailed error getting audio from source.
-217 = Detailed error encoding audio.
-218 = Detailed error unexpected failiure during audio export.
-219 = Detailed error audio stream already open.
-220 = Detailed error cannot connect to audio source.
-221 = Detailed error invalid number of audio channels.
-222 = Detailed error invalid audio sampling rate.
-223 = Detailed error invalid audio sampling rate.
-224 = Detailed error invalid number of audio sources.
-225 = Detailed error export exceeds max avi file size.
-226 = Detailed error no streams to export.
-227 = Detailed error illegal export time interval.
-228 = Detailed error cannot determine video fps and dimentions.
-229 = Detailed error video dimentions not supported.
-230 = Detailed error unexpected failiure.