corosync  2.4.6
Data Structures | Macros | Enumerations | Functions | Variables
totemcrypto.c File Reference
#include "config.h"
#include <nss.h>
#include <pk11pub.h>
#include <pkcs11.h>
#include <prerror.h>
#include <blapit.h>
#include <hasht.h>
#include <corosync/logsys.h>
#include <corosync/totem/totem.h>
#include "totemcrypto.h"
Include dependency graph for totemcrypto.c:

Go to the source code of this file.

Data Structures

struct  crypto_config_header
 
struct  crypto_instance
 

Macros

#define LOGSYS_UTILS_ONLY   1
 
#define SALT_SIZE   16
 
#define AES_256_KEY_LENGTH   32
 
#define AES_192_KEY_LENGTH   24
 
#define AES_128_KEY_LENGTH   16
 
#define log_printf(level, format, args...)
 
#define MAX_WRAPPED_KEY_LEN   128
 

Enumerations

enum  crypto_crypt_t {
  CRYPTO_CIPHER_TYPE_NONE = 0, CRYPTO_CIPHER_TYPE_AES256 = 1, CRYPTO_CIPHER_TYPE_AES192 = 2, CRYPTO_CIPHER_TYPE_AES128 = 3,
  CRYPTO_CIPHER_TYPE_3DES = 4, CRYPTO_CIPHER_TYPE_2_3 = UINT8_MAX - 1, CRYPTO_CIPHER_TYPE_2_2 = UINT8_MAX
}
 
enum  crypto_hash_t {
  CRYPTO_HASH_TYPE_NONE = 0, CRYPTO_HASH_TYPE_MD5 = 1, CRYPTO_HASH_TYPE_SHA1 = 2, CRYPTO_HASH_TYPE_SHA256 = 3,
  CRYPTO_HASH_TYPE_SHA384 = 4, CRYPTO_HASH_TYPE_SHA512 = 5, CRYPTO_HASH_TYPE_2_3 = UINT8_MAX - 1, CRYPTO_HASH_TYPE_2_2 = UINT8_MAX
}
 
enum  sym_key_type { SYM_KEY_TYPE_CRYPT, SYM_KEY_TYPE_HASH }
 

Functions

struct crypto_config_header __attribute__ ((packed))
 
size_t crypto_sec_header_size (const char *crypto_cipher_type, const char *crypto_hash_type)
 
size_t crypto_get_current_sec_header_size (const struct crypto_instance *instance)
 
int crypto_encrypt_and_sign (struct crypto_instance *instance, const unsigned char *buf_in, const size_t buf_in_len, unsigned char *buf_out, size_t *buf_out_len)
 
int crypto_authenticate_and_decrypt (struct crypto_instance *instance, unsigned char *buf, int *buf_len)
 
struct crypto_instancecrypto_init (const unsigned char *private_key, unsigned int private_key_len, const char *crypto_cipher_type, const char *crypto_hash_type, void(*log_printf_func)(int level, int subsys, const char *function, const char *file, int line, const char *format, ...) __attribute__((format(printf, 6, 7))), int log_level_security, int log_level_notice, int log_level_error, int log_subsys_id)
 

Variables

uint8_t crypto_cipher_type
 
uint8_t crypto_hash_type
 
uint8_t __pad0
 
uint8_t __pad1
 
enum crypto_crypt_t __attribute__
 
CK_MECHANISM_TYPE cipher_to_nss []
 
size_t cipher_key_len []
 
size_t cypher_block_len []
 
CK_MECHANISM_TYPE hash_to_nss []
 
size_t hash_len []
 
size_t hash_block_len []
 

Macro Definition Documentation

#define AES_128_KEY_LENGTH   16

Definition at line 81 of file totemcrypto.c.

#define AES_192_KEY_LENGTH   24

Definition at line 77 of file totemcrypto.c.

#define AES_256_KEY_LENGTH   32

Definition at line 73 of file totemcrypto.c.

#define log_printf (   level,
  format,
  args... 
)
Value:
do { \
instance->log_printf_func ( \
level, instance->log_subsys_id, \
__FUNCTION__, __FILE__, __LINE__, \
(const char *)format, ##args); \
} while (0);

Definition at line 201 of file totemcrypto.c.

Referenced by crypto_authenticate_and_decrypt().

#define LOGSYS_UTILS_ONLY   1

Definition at line 47 of file totemcrypto.c.

#define MAX_WRAPPED_KEY_LEN   128

Definition at line 214 of file totemcrypto.c.

#define SALT_SIZE   16

Definition at line 67 of file totemcrypto.c.

Referenced by crypto_sec_header_size().

Enumeration Type Documentation

Enumerator
CRYPTO_CIPHER_TYPE_NONE 
CRYPTO_CIPHER_TYPE_AES256 
CRYPTO_CIPHER_TYPE_AES192 
CRYPTO_CIPHER_TYPE_AES128 
CRYPTO_CIPHER_TYPE_3DES 
CRYPTO_CIPHER_TYPE_2_3 
CRYPTO_CIPHER_TYPE_2_2 

Definition at line 90 of file totemcrypto.c.

Enumerator
CRYPTO_HASH_TYPE_NONE 
CRYPTO_HASH_TYPE_MD5 
CRYPTO_HASH_TYPE_SHA1 
CRYPTO_HASH_TYPE_SHA256 
CRYPTO_HASH_TYPE_SHA384 
CRYPTO_HASH_TYPE_SHA512 
CRYPTO_HASH_TYPE_2_3 
CRYPTO_HASH_TYPE_2_2 

Definition at line 134 of file totemcrypto.c.

Enumerator
SYM_KEY_TYPE_CRYPT 
SYM_KEY_TYPE_HASH 

Definition at line 209 of file totemcrypto.c.

Function Documentation

struct crypto_config_header __attribute__ ( (packed)  )
int crypto_authenticate_and_decrypt ( struct crypto_instance instance,
unsigned char *  buf,
int *  buf_len 
)
int crypto_encrypt_and_sign ( struct crypto_instance instance,
const unsigned char *  buf_in,
const size_t  buf_in_len,
unsigned char *  buf_out,
size_t *  buf_out_len 
)
size_t crypto_get_current_sec_header_size ( const struct crypto_instance instance)

Definition at line 836 of file totemcrypto.c.

References crypto_instance::crypto_header_size.

struct crypto_instance* crypto_init ( const unsigned char *  private_key,
unsigned int  private_key_len,
const char *  crypto_cipher_type,
const char *  crypto_hash_type,
void(*)(int level,int subsys, const char *function, const char *file, int line, const char *format, ...) __attribute__ log_printf_func((format(printf, 6, 7)))  ,
int  log_level_security,
int  log_level_notice,
int  log_level_error,
int  log_subsys_id 
)
size_t crypto_sec_header_size ( const char *  crypto_cipher_type,
const char *  crypto_hash_type 
)

Definition at line 801 of file totemcrypto.c.

References SALT_SIZE.

Referenced by crypto_init(), totemudp_net_mtu_adjust(), and totemudpu_net_mtu_adjust().

Variable Documentation

enum crypto_crypt_t __attribute__
uint8_t __pad0

Definition at line 67 of file totemcrypto.c.

uint8_t __pad1

Definition at line 68 of file totemcrypto.c.

size_t cipher_key_len[]
Initial value:
= {
0,
24
}
#define AES_256_KEY_LENGTH
Definition: totemcrypto.c:73
#define AES_192_KEY_LENGTH
Definition: totemcrypto.c:77
#define AES_128_KEY_LENGTH
Definition: totemcrypto.c:81

Definition at line 108 of file totemcrypto.c.

CK_MECHANISM_TYPE cipher_to_nss[]
Initial value:
= {
0,
CKM_AES_CBC_PAD,
CKM_AES_CBC_PAD,
CKM_AES_CBC_PAD,
CKM_DES3_CBC_PAD
}

Definition at line 100 of file totemcrypto.c.

uint8_t crypto_cipher_type

Definition at line 65 of file totemcrypto.c.

uint8_t crypto_hash_type

Definition at line 66 of file totemcrypto.c.

size_t cypher_block_len[]
Initial value:
= {
0,
AES_BLOCK_SIZE,
AES_BLOCK_SIZE,
AES_BLOCK_SIZE,
0
}

Definition at line 116 of file totemcrypto.c.

size_t hash_block_len[]
Initial value:
= {
0,
MD5_BLOCK_LENGTH,
SHA1_BLOCK_LENGTH,
SHA256_BLOCK_LENGTH,
SHA384_BLOCK_LENGTH,
SHA512_BLOCK_LENGTH
}

Definition at line 163 of file totemcrypto.c.

size_t hash_len[]
Initial value:
= {
0,
MD5_LENGTH,
SHA1_LENGTH,
SHA256_LENGTH,
SHA384_LENGTH,
SHA512_LENGTH
}

Definition at line 154 of file totemcrypto.c.

CK_MECHANISM_TYPE hash_to_nss[]
Initial value:
= {
0,
CKM_MD5_HMAC,
CKM_SHA_1_HMAC,
CKM_SHA256_HMAC,
CKM_SHA384_HMAC,
CKM_SHA512_HMAC
}

Definition at line 145 of file totemcrypto.c.