Teonet library  0.4.7
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
crypt.h File Reference

Go to the source code of this file.

Data Structures

struct  ksnCryptClass
 ksnetCrypt Class data More...
 

Macros

#define BLOCK_SIZE   16
 File: crypt.h Author: Kirill Scherba kiril.nosp@m.l@sc.nosp@m.herba.nosp@m..ru More...
 
#define KEY_SIZE   32
 

Typedefs

typedef struct ksnCryptClass ksnCryptClass
 ksnetCrypt Class data More...
 

Functions

ksnCryptClassksnCryptInit (void *ke)
 Module initialize. More...
 
void ksnCryptDestroy (ksnCryptClass *kcr)
 Module destroy. More...
 
void * ksnEncryptPackage (ksnCryptClass *kcr, void *package, size_t package_len, void *buffer, size_t *encrypt_len)
 Encrypt KSNet package. More...
 
void * ksnDecryptPackage (ksnCryptClass *kcr, void *package, size_t package_len, size_t *decrypt_len)
 Decrypt received package. More...
 
int ksnCheckEncrypted (void *package, size_t package_len)
 Simple check if the packet is encrypted. More...
 

Macro Definition Documentation

#define BLOCK_SIZE   16

File: crypt.h Author: Kirill Scherba kiril.nosp@m.l@sc.nosp@m.herba.nosp@m..ru

Created on July 14, 2015, 4:04 PM

Referenced by ksnCheckEncrypted(), and ksnCryptInit().

#define KEY_SIZE   32

Referenced by ksnCryptInit().

Typedef Documentation

typedef struct ksnCryptClass ksnCryptClass

ksnetCrypt Class data

Function Documentation

int ksnCheckEncrypted ( void *  package,
size_t  package_len 
)

Simple check if the packet is encrypted.

Parameters
packagePointer to package
package_lenPackage length
Returns

References BLOCK_SIZE.

Referenced by ksnCoreProcessPacket(), and trudp_send_event_ack_to_app().

void ksnCryptDestroy ( ksnCryptClass kcr)

Module destroy.

Parameters
kcr

References free(), ksnCryptClass::key, and num_crypt_module.

Referenced by ksnCoreDestroy(), test_1_1(), and test_1_2().

ksnCryptClass* ksnCryptInit ( void *  ke)
void* ksnDecryptPackage ( ksnCryptClass kcr,
void *  package,
size_t  package_len,
size_t *  decrypt_len 
)

Decrypt received package.

Parameters
kcrPointer to ksnetCryptClass object
packagePointer to received package data
package_lenPackage data length
[out]decrypt_lenDecrypted length of package data
Returns
Pointer to decrypted package data

References _decrypt(), DEBUG_VV, free(), ksnCryptClass::iv, ksnCryptClass::ke, ksnCryptClass::key, ksn_printf, malloc(), and MODULE.

Referenced by ksnCoreProcessPacket(), and trudp_send_event_ack_to_app().

void* ksnEncryptPackage ( ksnCryptClass kcr,
void *  package,
size_t  package_len,
void *  buffer,
size_t *  encrypt_len 
)

Encrypt KSNet package.

Parameters
kcrPointer to ksnetCryptClass object
packagePackage to send
package_lenPackage length
bufferBuffer to encrypt, enough to hold encrypted data (package_len + 16)
[out]encrypt_lenLength of encrypted data
Returns
If buffer = NULL this function return allocated pointer to encrypted buffer with data. Should be free after use. Other way it return pointer to input buffer.

References _encrypt(), ksnCryptClass::blocksize, DEBUG_VV, ksnCryptClass::iv, ksnCryptClass::ke, ksnCryptClass::key, ksn_printf, malloc(), and MODULE.

Referenced by test_1_2().