SNMP++  3.3.11
PrivAES Class Reference

Encryption module using AES. More...

#include <auth_priv.h>

Inheritance diagram for PrivAES:
Collaboration diagram for PrivAES:

Public Member Functions

 PrivAES (const int aes_type_)
 
int encrypt (const unsigned char *key, const unsigned int key_len, const unsigned char *buffer, const unsigned int buffer_len, unsigned char *out_buffer, unsigned int *out_buffer_len, unsigned char *privacy_params, unsigned int *privacy_params_len, const unsigned long engine_boots, const unsigned long engine_time)
 Encrypt the buffer with the given key. More...
 
int decrypt (const unsigned char *key, const unsigned int key_len, const unsigned char *buffer, const unsigned int buffer_len, unsigned char *out_buffer, unsigned int *out_buffer_len, const unsigned char *privacy_params, const unsigned int privacy_params_len, const unsigned long engine_boots, const unsigned long engine_time)
 Decrypt the buffer with the given key. More...
 
int extend_short_key (const unsigned char *password, const unsigned int password_len, const unsigned char *engine_id, const unsigned int engine_id_len, unsigned char *key, unsigned int *key_len, const unsigned int max_key_len, Auth *auth)
 Extend a localized key that is too short. More...
 
int get_id () const
 Get the uniqhe id of the privacy protocol. More...
 
const char * get_id_string () const
 Get the unique identifier string of the privacy protocol. More...
 
int get_priv_params_len () const
 Get the maximum length that is needed for the msgPrivacyParameters field. More...
 
int get_min_key_len () const
 Get the minimum key length needed for encryption and decryption. More...
 
void fix_key_len (unsigned int &key_len) const
 Decrease a too long length to the right value. More...
 
- Public Member Functions inherited from Priv
virtual ~Priv ()
 
virtual void set_salt (pp_uint64 *new_salt)
 Set the pointer to the salt that should be used. More...
 

Private Attributes

int aes_type
 
int key_bytes
 
int rounds
 
bool need_byteswap
 

Additional Inherited Members

- Protected Attributes inherited from Priv
pp_uint64salt
 

Detailed Description

Encryption module using AES.

See also
Priv

Definition at line 709 of file auth_priv.h.

Constructor & Destructor Documentation

◆ PrivAES()

PrivAES::PrivAES ( const int  aes_type_)

Member Function Documentation

◆ decrypt()

int PrivAES::decrypt ( const unsigned char *  key,
const unsigned int  key_len,
const unsigned char *  buffer,
const unsigned int  buffer_len,
unsigned char *  out_buffer,
unsigned int *  out_buffer_len,
const unsigned char *  privacy_params,
const unsigned int  privacy_params_len,
const unsigned long  engine_boots,
const unsigned long  engine_time 
)
virtual

Decrypt the buffer with the given key.

This method needs the privacy parameters field for the given message.

Parameters
key- pointer to the (fixed length) dencryption key
key_len- length of encryption key
buffer- pointer to the encrypted buffer
buffer_len- length of the buffer
out_buffer- pointer to the buffer for the decryptet data
out_buffer_len- Input: Length of the output buffer. Output: Bytes written
privacy_params- Buffer, where the privacy parameters are read from.
privacy_params_len- Length of the privacy parameters buffer
engine_boots- The engine boots value for the message
engine_time- The engine time value for the message
Returns
SNMPv3_USM_OK on success

Implements Priv.

◆ encrypt()

int PrivAES::encrypt ( const unsigned char *  key,
const unsigned int  key_len,
const unsigned char *  buffer,
const unsigned int  buffer_len,
unsigned char *  out_buffer,
unsigned int *  out_buffer_len,
unsigned char *  privacy_params,
unsigned int *  privacy_params_len,
const unsigned long  engine_boots,
const unsigned long  engine_time 
)
virtual

Encrypt the buffer with the given key.

This method fills the privacy parameters field of the given message.

Parameters
key- pointer to the encryption key
key_len- length of encryption key
buffer- pointer to the unencrypted buffer
buffer_len- length of the buffer
out_buffer- pointer to the buffer for the encryptet data
out_buffer_len- Input: Length of the output buffer. Output: Bytes written
privacy_params- Buffer, where the privacy parameters are written to.
privacy_params_len- Length of the privacy parameters buffer
engine_boots- The engine boots value for the message
engine_time- The engine time value for the message
Returns
SNMPv3_USM_OK on success

Implements Priv.

◆ extend_short_key()

int PrivAES::extend_short_key ( const unsigned char *  password,
const unsigned int  password_len,
const unsigned char *  engine_id,
const unsigned int  engine_id_len,
unsigned char *  key,
unsigned int *  key_len,
const unsigned int  max_key_len,
Auth auth 
)
virtual

Extend a localized key that is too short.

Some privacy protocols require a key that is longer than the key generated by the pasword to key algorithm of the authentication protocol. This function extends a short key to the required length.

Parameters
password- the password
password_len- the length of the password
engine_id- pointer to snmpEngineID
engine_id_len- length of snmpEngineID
key- pointer to the short key that was generated using Auth::password_to_key() function
key_len- IN: length of the short key OUT: length of the extended key
max_key_len- Length of the key buffer
auth- Pointer of the authentication protocol that should be used
Returns
SNMPv3_USM_OK on success

Implements Priv.

Reimplemented in PrivAESW3DESKeyExt.

◆ fix_key_len()

void PrivAES::fix_key_len ( unsigned int &  key_len) const
inlinevirtual

Decrease a too long length to the right value.

Implements Priv.

Definition at line 750 of file auth_priv.h.

◆ get_id()

int PrivAES::get_id ( ) const
inlinevirtual

Get the uniqhe id of the privacy protocol.

Implements Priv.

Reimplemented in PrivAESW3DESKeyExt.

Definition at line 746 of file auth_priv.h.

◆ get_id_string()

const char* PrivAES::get_id_string ( ) const
virtual

Get the unique identifier string of the privacy protocol.

Implements Priv.

Reimplemented in PrivAESW3DESKeyExt.

◆ get_min_key_len()

int PrivAES::get_min_key_len ( ) const
inlinevirtual

Get the minimum key length needed for encryption and decryption.

Implements Priv.

Definition at line 749 of file auth_priv.h.

◆ get_priv_params_len()

int PrivAES::get_priv_params_len ( ) const
inlinevirtual

Get the maximum length that is needed for the msgPrivacyParameters field.

Implements Priv.

Definition at line 748 of file auth_priv.h.

Member Data Documentation

◆ aes_type

int PrivAES::aes_type
private

Definition at line 751 of file auth_priv.h.

◆ key_bytes

int PrivAES::key_bytes
private

Definition at line 755 of file auth_priv.h.

◆ need_byteswap

bool PrivAES::need_byteswap
private

Definition at line 760 of file auth_priv.h.

◆ rounds

int PrivAES::rounds
private

Definition at line 756 of file auth_priv.h.


The documentation for this class was generated from the following file: