Main Page | Data Structures | File List | Data Fields | Globals

ss-util.c File Reference

Secure Storage util functions source file. More...

#include <sys/mman.h>
#include <unistd.h>
#include <assert.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <fcntl.h>
#include <openssl/rand.h>
#include <uuid/uuid.h>
#include "lcg_util.h"
#include "ss-util.h"
#include "keystore_client.h"

Go to the source code of this file.

Functions

void ivec_inc (unsigned char *counter)
void ivec_dec (unsigned char *counter)
void securestorage_AES_ctr (const unsigned char *in, unsigned char *out, const unsigned long length, const AES_KEY *key, unsigned char ivec[16], unsigned char ecount_buf[16], unsigned int *num)
 Encrypt input string using AES_ctr algorithm.

size_t lock_memory (char *addr, size_t size)
size_t unlock_memory (char *addr, size_t size)
int ss_rand (int size, unsigned char *out)
 Generate random data function.

int ss_generate_surl (char **dest_surl, char *dest_file, char *vo, char *guid)
 Generate SURL.

int ss_get_lfchome (const char *input_lfn, char **lfn_new)
 Get LFC Home.

int ss_get_surl (char *lfn, char **surl, char *vo, char *se, int insecure)
 Get SURL.

int ss_check_lfn (char *lfn, char *vo)
 Check LFN existence.

const char * securestorage_error (int errnum)
 Return descriptive string of error.


Variables

int securestorage_nerr = 56
int errno


Detailed Description

Secure Storage util functions source file.

Author:
Giordano Scuderi and Nicola Dominante
Date:
23-03-07

Definition in file ss-util.c.


Function Documentation

void ivec_dec unsigned char *  counter  ) 
 

decrement counter (128-bit int) by 1.

Author:
Giordano Scuderi
See also:
ivec_inc()
Parameters:
counter is the counter to decrement

Definition at line 136 of file ss-util.c.

References GETU32, and PUTU32.

Referenced by securestorage_lseek().

void ivec_inc unsigned char *  counter  ) 
 

increment counter (128-bit int) by 1.

Author:
Giordano Scuderi
See also:
ivec_dec()
Parameters:
counter is the counter to increment

Definition at line 97 of file ss-util.c.

References GETU32, and PUTU32.

Referenced by securestorage_AES_ctr(), and securestorage_lseek().

size_t lock_memory char *  addr,
size_t  size
 

Lock memory.

Author:
Giordano Scuderi
See also:
unlock_memory()
Parameters:
addr is the start address of the memory to lock
size is the memory size to lock
Returns:
locked memory size if success or -1 if fail

Definition at line 223 of file ss-util.c.

Referenced by lcg_scp(), and lcg_scr().

void securestorage_AES_ctr const unsigned char *  in,
unsigned char *  out,
const unsigned long  length,
const AES_KEY key,
unsigned char  ivec[16],
unsigned char  ecount_buf[16],
unsigned int *  num
 

Encrypt input string using AES_ctr algorithm.

The input encrypted as though 128bit counter mode is being used. The extra state information to record how much of the 128bit block we have used is contained in *num, and the encrypted counter is kept in ecount_buf. Both *num and ecount_buf must be initialised with zeros before the first call to securestorage_AES_ctr().

This algorithm assumes that the counter is in the x lower bits of the IV (ivec), and that the application has full control over overflow and the rest of the IV. This implementation takes NO responsability for checking that the counter doesn't overflow into the rest of the IV when incremented.

Author:
OpenSSL authors, modified by Giordano Scuderi
Parameters:
in is the input buffer to encrypt
out is encrypted output buffer
length is the input buffer lenght
key is the AES_KEY struct initialized with AES_set_encrypt_key function
ivec is the current ivec
ecount_buf is the current encrypted ivec
num is the current position inside block of 16 byte

Definition at line 193 of file ss-util.c.

References AES_BLOCK_SIZE, AES_encrypt(), AES_KEY, and ivec_inc().

Referenced by lcg_scp(), lcg_scr(), securestorage_read(), and securestorage_write().

const char* securestorage_error int  errnum  ) 
 

Return descriptive string of error.

for errnum provided

Author:
Giordano Scuderi
Parameters:
errnum is the Secure Storage error number
Returns:
A descriptive String of error number provided or "Unknown Error 'errnum'" if error number is wrong.

Definition at line 547 of file ss-util.c.

References ss_errlist.

Referenced by lcg_scp(), lcg_scr(), and main().

int ss_check_lfn char *  lfn,
char *  vo
 

Check LFN existence.

This function check if provided lfn exist in LFC Catalog

Author:
Giordano Scuderi
Parameters:
lfn is the Logical File Name (LFN)
vo is the Virtual Organization name
Returns:
0 if not exist, 1 if exist or < 0 if fail (errno is set appropriately).

Definition at line 504 of file ss-util.c.

References errno, and insecure.

Referenced by lcg_scr(), lcg_sdel(), securestorage_del_extended(), and securestorage_open_extended().

int ss_generate_surl char **  dest_surl,
char *  dest_file,
char *  vo,
char *  guid
 

Generate SURL.

This function generate a valid SURL ( in srm:// format ).

Author:
Giordano Scuderi
See also:
ss_get_surl()
Parameters:
dest_surl is the buffer that contain generated SURL
dest_file is the hostname of Storage Element
vo is the Virtual Organization name
guid is the Grid Unique Identifier (if NULL, a new GUID will be generated)
Returns:
0 if success or -1 if fail

Definition at line 293 of file ss-util.c.

References errno.

Referenced by lcg_scr(), and securestorage_open_extended().

int ss_get_lfchome const char *  input_lfn,
char **  lfn_new
 

Get LFC Home.

This function add LFC_HOME To your current LFN.

Author:
Giordano Scuderi
Parameters:
input_lfn is the Input Logical File Name (LFN)
lfn_new is the output buffer that contain complete LFN path (with LFC_HOME environment variable added)
Returns:
0 if success or -1 if fail

Definition at line 363 of file ss-util.c.

References LCG_MAXPATHLEN.

Referenced by lcg_scp(), lcg_scr(), lcg_sdel(), securestorage_del_extended(), securestorage_mkdir(), securestorage_open_extended(), securestorage_opendir(), securestorage_rmdir(), and securestorage_statg().

int ss_get_surl char *  lfn,
char **  surl,
char *  vo,
char *  se,
int  insecure
 

Get SURL.

This function get the SURL for the input LFN given.

Author:
Giordano Scuderi
Parameters:
lfn is the Logical File Name (LFN)
surl is the output buffer that contain SURL
vo is the Virtual Organization name
se is the destination Storage Element name
insecure 
Returns:
0 if success or -1 if fail

Definition at line 438 of file ss-util.c.

References errno, insecure, and SS_ENOENT.

Referenced by lcg_scp(), and securestorage_open_extended().

int ss_rand int  size,
unsigned char *  out
 

Generate random data function.

This function generate random data for the specified size, for using it on encryption process.

Author:
Giordano Scuderi
See also:
ss_delete_key()

ss_send_key()

ss_get_key()

Parameters:
size the size of random data to generate.
out output array (static) will be contains generated random data.
Returns:
0 if success or -1 if fail

Definition at line 252 of file ss-util.c.

References errno.

Referenced by lcg_scr(), and securestorage_open_extended().

size_t unlock_memory char *  addr,
size_t  size
 

Unlock memory.

Author:
Giordano Scuderi
See also:
lock_memory()
Parameters:
addr is the start address of the memory to unlock
size is the memory size to unlock
Returns:
unlocked memory size if success or -1 if fail

Definition at line 236 of file ss-util.c.


Variable Documentation

int errno
 

Definition at line 93 of file ss-util.c.

int securestorage_nerr = 56
 

Definition at line 92 of file ss-util.c.


Generated on Wed May 30 09:56:31 2007 for Secure Storage Service by doxygen 1.3.5